Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: 🐼 Samrose Ahmed 🐼 <[email protected]>
  • Loading branch information
Samrose-Ahmed committed Nov 13, 2023
1 parent b162051 commit 5f90a3d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/assets/iac/MatanoCrossAccountS3Access.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ Resources:
except Exception as J:print('send(..) failed executing request.urlopen(..): '+str(J))
def create_matano_sns_topic_if_not_exists(bucket,master_account_id,account_id,region):
I='Allow';H='Resource';G='Action';F='Principal';E='Effect';D='Sid';B=region;J=boto3.client('sns',region_name=B);C='matano-s3-notifications';A=f"arn:aws:sns:{B}:{account_id}:{C}"
try:J.create_topic(Name=C,Attributes={'Policy':json.dumps({'Version':'2012-10-17','Statement':[{D:'0',E:I,F:{'Service':'s3.amazonaws.com'},G:'SNS:Publish',H:A,'Condition':{'ArnLike':{'aws:SourceArn':f"arn:aws:s3:::{bucket}"}}},{D:'GrantAutomationAccess',E:I,F:{'AWS':f"arn:aws:iam::{master_account_id}:root"},G:['SNS:Subscribe','SNS:ListSubscriptionsByTopic'],H:A}]})});print(f"Created topic {A}")
try:J.create_topic(Name=C,Attributes={'Policy':json.dumps({'Version':'2012-10-17','Statement':[{D:'0',E:I,F:{'Service':'s3.amazonaws.com'},G:'SNS:Publish',H:A,'Condition':{'StringEquals':{'aws:SourceAccount':account_id}}},{D:'GrantAutomationAccess',E:I,F:{'AWS':f"arn:aws:iam::{master_account_id}:root"},G:['SNS:Subscribe','SNS:ListSubscriptionsByTopic'],H:A}]})});print(f"Created topic {A}")
except Exception as K:
if _C not in str(K):raise
print(f"SNS topic {A} already exists w/ different attributes, skipping creation")
Expand Down

1 comment on commit 5f90a3d

@vercel
Copy link

@vercel vercel bot commented on 5f90a3d Nov 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.