Skip to content

Commit

Permalink
[integ-test] Fix build_image_custom_resource fixture
Browse files Browse the repository at this point in the history
Before this commit, `instance_role_arn` of another role could be returned just because the other role has the same role name prefix "dummyInstanceRole". This commit uses the complete role name to get the `instance_role_arn`

Signed-off-by: Hanwen <[email protected]>
  • Loading branch information
hanwen-cluster authored and hanwen-pcluste committed Aug 16, 2024
1 parent 8641f35 commit 6671b64
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions tests/integration-tests/tests/createami/test_createami.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,6 @@ def _custom_resource(image_id):
]
},
)
role_name = "".join(["dummyInstanceRole", generate_random_string()])
instance_role = iam.Role(
"CustomInstanceRole",
AssumeRolePolicyDocument={
Expand All @@ -430,7 +429,6 @@ def _custom_resource(image_id):
ManagedPolicyArns=managed_policy_arns,
Path="/parallelcluster/",
Policies=[policy_document],
RoleName=role_name,
)

custom_resource_template.add_resource(instance_role)
Expand All @@ -442,6 +440,7 @@ def _custom_resource(image_id):
)
cfn_stacks_factory.create_stack(custom_resource_stack)

role_name = custom_resource_stack.cfn_resources["CustomInstanceRole"]
instance_role_arn = boto3.client("iam").get_role(RoleName=role_name).get("Role").get("Arn")
logging.info("Custom instance role arn %s", instance_role_arn)

Expand Down

0 comments on commit 6671b64

Please sign in to comment.