Skip to content

Commit

Permalink
add condition for sns and sqs for s3 integration
Browse files Browse the repository at this point in the history
  • Loading branch information
daidokoro committed Jul 15, 2024
1 parent d8700e5 commit a53abfd
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions custom-resource/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,30 @@ def delete(self):

def handle(self):
responseStatus = self.cfn.SUCCESS
match self.event['RequestType']:
case 'Create':
err = self.create()
case 'Update':
err = self.update()
case 'Delete':
err = self.delete()
if err:
if 'ResourceNotFoundException' in err: err = None
on_sns_or_sqs = False

# Skip S3 trigger configuration if SQS Topic ARN is not a placeholder or empty
if all([
self.params.SNSTopicArn != 'arn:aws:sns:us-east-1:123456789012:placeholder',
self.params.SNSTopicArn != ''
]): on_sns_or_sqs = True

if all([
self.params.SQSTopicArn != 'arn:aws:sqs:us-east-1:123456789012:placeholder',
self.params.SQSTopicArn != ''
]): on_sns_or_sqs = True

err = None
if not on_sns_or_sqs:
match self.event['RequestType']:
case 'Create':
err = self.create()
case 'Update':
err = self.update()
case 'Delete':
err = self.delete()
if err:
if 'ResourceNotFoundException' in err: err = None

if err:
print(f"[ConfigureS3Trigger] failed to process: {err}")
Expand Down Expand Up @@ -461,7 +476,6 @@ def handle(self):
)



def lambda_handler(event, context):
'''
AWS Lambda handler function
Expand Down

0 comments on commit a53abfd

Please sign in to comment.