Skip to content
This repository has been archived by the owner on Sep 12, 2022. It is now read-only.

Commit

Permalink
Ignore AWS_UNSET_PROFILE in [profile:...]
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabrizio Branca committed Oct 18, 2016
1 parent 97ad8ac commit d9d0f8d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/StackFormation/ValueResolver/Stage/ProfileSwitcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,25 @@ public function invoke($string)
$string = preg_replace_callback(
'/\[profile:([^:\]\[]+?):([^\]\[]+?)\]/',
function ($matches) {

// [profile:...] ignores AWS_UNSET_PROFILE. Backup up value here
$unsetProfileBackup = getenv('AWS_UNSET_PROFILE');
putenv('AWS_UNSET_PROFILE');

// recursively create another ValueResolver, but this time with a different profile
$subValueResolver = new \StackFormation\ValueResolver\ValueResolver(
$this->valueResolver->getDependencyTracker(),
$this->valueResolver->getProfileManager(),
$this->valueResolver->getConfig(),
$matches[1]
);
return $subValueResolver->resolvePlaceholders($matches[2], $this->sourceBlueprint, $this->sourceType, $this->sourceKey);
$value = $subValueResolver->resolvePlaceholders($matches[2], $this->sourceBlueprint, $this->sourceType, $this->sourceKey);

// restoring AWS_UNSET_PROFILE value if it was set before
if ($unsetProfileBackup) {
putenv('AWS_UNSET_PROFILE=1');
}
return $value;
},
$string
);
Expand Down

0 comments on commit d9d0f8d

Please sign in to comment.