Skip to content

Commit 855266f

Browse files
committed
small fixes on CLI behavior [AWS SSO + Cloudformation Exception]
1 parent ebbfd97 commit 855266f

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/Commands/Connect.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
3838
/** @var string $awsProfile */
3939
$awsProfile = $input->getOption('profile');
4040

41+
putenv('AWS_PROFILE=' . $awsProfile);
42+
4143
$accountId = $this->getCurrentAwsAccountId($awsProfile);
4244
// TODO verbose only
4345
IO::writeln('Current AWS account ID: ' . $accountId);
@@ -100,7 +102,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
100102
IO::spin('connecting');
101103

102104
$cloudFormationClient = new CloudFormationClient([
103-
'profile' => $awsProfile,
104105
'region' => $details['region'],
105106
]);
106107
IO::verbose(['Deploying CloudFormation stack']);
@@ -139,13 +140,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
139140
private function getCurrentAwsAccountId(string $profile): string
140141
{
141142
$sts = new StsClient([
142-
'profile' => $profile,
143+
'region' => 'us-east-1',
143144
]);
144-
$accountId = $sts->getCallerIdentity()->toArray()['Account'] ?? null;
145-
if (! $accountId) {
145+
146+
return $sts->getCallerIdentity()->toArray()['Account'] ??
146147
throw new RuntimeException('Could not determine the AWS account ID');
147-
}
148-
return $accountId;
149148
}
150149

151150
private function selectTeam(BrefCloudClient $brefCloud): int

src/Helpers/CloudFormation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ private function retrieveDetailedDeployError(string $stackName): ?string
122122
'StackName' => $stackName,
123123
])->toArray();
124124
if (! empty($stack['Stacks'][0]['StackStatusReason'])) {
125-
throw $stack['Stacks'][0]['StackStatusReason'];
125+
throw new Exception($stack['Stacks'][0]['StackStatusReason']);
126126
}
127127

128128
// Else try to retrieve the events

0 commit comments

Comments
 (0)