Skip to content

Commit c4f0849

Browse files
author
Taniya Mathur
committed
Add CFN prefix to service role and permission boundary ARNs for stack uniqueness
- Updated permission boundary policy name to include CFN prefix - Updated service role name to include stack name for uniqueness - Updated uninstall service to use CFN prefix for permission boundary cleanup - Ensures multiple stack deployments don't conflict in same AWS account
1 parent 9d38018 commit c4f0849

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

iam-roles/cloudformation-management/IDP-Cloudformation-Service-Role.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Resources:
1313
CloudFormationServiceRole:
1414
Type: AWS::IAM::Role
1515
Properties:
16-
RoleName: IDPAcceleratorCloudFormationServiceRole
16+
RoleName: !Sub '${AWS::StackName}-IDPAcceleratorCloudFormationServiceRole'
1717
AssumeRolePolicyDocument:
1818
Version: '2012-10-17'
1919
Statement:

scripts/sdlc/idp-cli/src/idp_cli/service/install_service.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,6 @@ def deploy_service_role(self):
256256
logger.debug(f"Command stdout: {e.stdout}")
257257
if e.stderr:
258258
logger.debug(f"Command stderr: {e.stderr}")
259-
260-
logger.info(f"Service role deployment failed. Stack '{service_role_stack_name}' left for debugging.")
261259
return None
262260
except Exception as e:
263261
logger.error(f"Unexpected error during service role deployment: {e}")
@@ -302,7 +300,7 @@ def _get_service_role_arn_from_stack(self, stack_name):
302300
def create_permission_boundary_policy(self):
303301
"""Create an 'allow everything' permission boundary policy"""
304302

305-
policy_name = "IDPPermissionBoundary"
303+
policy_name = f"{self.cfn_prefix}-IDPPermissionBoundary"
306304
iam = boto3.client('iam')
307305

308306
try:

scripts/sdlc/idp-cli/src/idp_cli/service/uninstall_service.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,11 @@ def delete_service_role_stack(self):
7373

7474
def delete_permission_boundary_policy(self):
7575
"""Delete the permission boundary policy if it exists"""
76-
policy_name = "IDPPermissionBoundary"
76+
policy_name = f"{self.cfn_prefix}-IDPPermissionBoundary"
7777

7878
try:
7979
iam = boto3.client('iam')
80-
account_id = boto3.client('sts').get_caller_identity()['Account']
81-
policy_arn = f"arn:aws:iam::{account_id}:policy/{policy_name}"
80+
policy_arn = f"arn:aws:iam::{self.account_id}:policy/{policy_name}"
8281

8382
logger.info(f"Attempting to delete permission boundary policy: {policy_arn}")
8483
iam.delete_policy(PolicyArn=policy_arn)

0 commit comments

Comments
 (0)