Skip to content

Commit 9220140

Browse files
authored
Fix assume role for the fresh account (#628)
New accounts doesn't have cdk-hnb659fds-lookup-role it leads to issue Implementation details: According to description of ``` For first deployments it returns False, for existing deployments it returns the ssm parameter value generated in the first deployment for prior to V1.5.1 upgrades it returns the secret from secrets manager ``` For first deployments it fails because there is no role to assume By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 1af8f08 commit 9220140

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

deploy/stacks/param_store_stack.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,17 @@ def _get_external_id_value(envname, account_id, region):
130130
region_name=region,
131131
endpoint_url=f"https://sts.{region}.amazonaws.com"
132132
)
133-
response = sts.assume_role(**assume_role_dict)
134-
session = boto3.Session(
135-
aws_access_key_id=response['Credentials']['AccessKeyId'],
136-
aws_secret_access_key=response['Credentials']['SecretAccessKey'],
137-
aws_session_token=response['Credentials']['SessionToken'],
138-
)
139-
140-
secret_id = f"dataall-externalId-{envname}"
141-
parameter_path = f"/dataall/{envname}/pivotRole/externalId"
142133
try:
134+
response = sts.assume_role(**assume_role_dict)
135+
session = boto3.Session(
136+
aws_access_key_id=response['Credentials']['AccessKeyId'],
137+
aws_secret_access_key=response['Credentials']['SecretAccessKey'],
138+
aws_session_token=response['Credentials']['SessionToken'],
139+
)
140+
141+
secret_id = f"dataall-externalId-{envname}"
142+
parameter_path = f"/dataall/{envname}/pivotRole/externalId"
143+
143144
ssm_client = session.client('ssm', region_name=region)
144145
parameter_value = ssm_client.get_parameter(Name=parameter_path)['Parameter']['Value']
145146
return parameter_value

0 commit comments

Comments
 (0)