Skip to content

Commit

Permalink
Removes unneeded permissions for the Lambda function; uses WaiterConf…
Browse files Browse the repository at this point in the history
…ig to set the max attempts to 30
  • Loading branch information
jaehyi-aws committed Dec 5, 2024
1 parent a06be91 commit 33367d4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cfn-templates/data-exports-aggregation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -632,8 +632,6 @@ Resources:
Action:
- iam:GetRole
- iam:CreateServiceLinkedRole
- iam:DeleteServiceLinkedRole
- iam:GetServiceLinkedRoleDeletionStatus
Resource: !Sub 'arn:${AWS::Partition}:iam::${AWS::AccountId}:role/aws-service-role/bcm-data-exports.amazonaws.com/AWSServiceRoleForBCMDataExports'
- Effect: Allow
Action:
Expand Down Expand Up @@ -730,13 +728,17 @@ Resources:
def create_service_linked_role(service_name: str, description: str):
try:
logger.info(f"Creating a service-linked role for {service_name}...")
role_name = iam_client.create_service_linked_role(
AWSServiceName=service_name,
Description=description
)["Role"]["RoleName"]
logger.info(f"Waiting for the service-linked role to be available...")
waiter = iam_client.get_waiter("role_exists")
waiter.wait(RoleName=role_name)
waiter.wait(
RoleName=role_name,
WaiterConfig={'Delay': 1, 'MaxAttempts': 30}
)
time.sleep(10) # Additional wait time, just in case
logger.info(
Expand Down

0 comments on commit 33367d4

Please sign in to comment.