@@ -3872,9 +3872,7 @@ boto_config = Config(
38723872 }
38733873 )
38743874
3875- failureFeedbackRoleValue = "LambdaFailureFeedbackRoleArn"
3876- successFeedbackRoleValue = "LambdaSuccessFeedbackRoleArn"
3877- successRateRoleValue = "LambdaSuccessFeedbackSampleRate"
3875+ endpointTypes = ['HTTP', 'Firehose', 'Lambda', 'Application', 'SQS']
38783876
38793877def connect_to_sns():
38803878 return boto3.client('sns', config=boto_config)
@@ -3900,9 +3898,21 @@ def lambda_handler(event, _):
39003898 topic_attributes = get_topic_attributes(topic_arn)
39013899
39023900 return {
3903- "FailureFeedbackRole": topic_attributes["Attributes"][failureFeedbackRoleValue],
3904- "SuccessFeedbackRole": topic_attributes["Attributes"][successFeedbackRoleValue],
3905- "SuccessSampleRate": topic_attributes["Attributes"][successRateRoleValue]
3901+ "HTTPFailureFeedbackRoleArn": topic_attributes["Attributes"]["HTTPFailureFeedbackRoleArn"],
3902+ "HTTPSuccessFeedbackRoleArn": topic_attributes["Attributes"]["HTTPSuccessFeedbackRoleArn"],
3903+ "HTTPSuccessFeedbackSampleRate": topic_attributes["Attributes"]["HTTPSuccessFeedbackSampleRate"],
3904+ "FirehoseFailureFeedbackRoleArn": topic_attributes["Attributes"]["FirehoseFailureFeedbackRoleArn"],
3905+ "FirehoseSuccessFeedbackRoleArn": topic_attributes["Attributes"]["FirehoseSuccessFeedbackRoleArn"],
3906+ "FirehoseSuccessFeedbackSampleRate": topic_attributes["Attributes"]["FirehoseSuccessFeedbackSampleRate"],
3907+ "LambdaFailureFeedbackRoleArn": topic_attributes["Attributes"]["LambdaFailureFeedbackRoleArn"],
3908+ "LambdaSuccessFeedbackRoleArn": topic_attributes["Attributes"]["LambdaSuccessFeedbackRoleArn"],
3909+ "LambdaSuccessFeedbackSampleRate": topic_attributes["Attributes"]["LambdaSuccessFeedbackSampleRate"],
3910+ "ApplicationFailureFeedbackRoleArn": topic_attributes["Attributes"]["ApplicationFailureFeedbackRoleArn"],
3911+ "ApplicationSuccessFeedbackRoleArn": topic_attributes["Attributes"]["ApplicationSuccessFeedbackRoleArn"],
3912+ "ApplicationSuccessFeedbackSampleRate": topic_attributes["Attributes"]["ApplicationSuccessFeedbackSampleRate"],
3913+ "SQSFailureFeedbackRoleArn": topic_attributes["Attributes"]["SQSFailureFeedbackRoleArn"],
3914+ "SQSSuccessFeedbackRoleArn": topic_attributes["Attributes"]["SQSSuccessFeedbackRoleArn"],
3915+ "SQSSuccessFeedbackSampleRate": topic_attributes["Attributes"]["SQSSuccessFeedbackSampleRate"]
39063916 }
39073917
39083918def add_roles_to_topic(logging_role, topic_arn):
@@ -3911,24 +3921,26 @@ def add_roles_to_topic(logging_role, topic_arn):
39113921 """
39123922 sns = connect_to_sns()
39133923 try:
3914- sns.set_topic_attributes(TopicArn=topic_arn, AttributeName=successFeedbackRoleValue, AttributeValue=logging_role)
3915- sns.set_topic_attributes(TopicArn=topic_arn, AttributeName=failureFeedbackRoleValue, AttributeValue=logging_role)
3924+ for endpoint in endpointTypes:
3925+ sns.set_topic_attributes(TopicArn=topic_arn, AttributeName=f'{endpoint}SuccessFeedbackRoleArn', AttributeValue=logging_role)
3926+ sns.set_topic_attributes(TopicArn=topic_arn, AttributeName=f'{endpoint}FailureFeedbackRoleArn', AttributeValue=logging_role)
39163927
39173928 except Exception as e:
39183929 reset_to_recognized_state(topic_arn)
3919- exit(f'Failed to set success/failure role of topic '+ topic_arn+': '+ str(e))
3930+ exit(f'Failed to set success/failure role of topic { topic_arn}: { str(e)}' )
39203931
39213932def add_sample_rate_to_topic(topic_arn, sample_rate):
39223933 """
39233934 Configures the Success sample rate, the percentage of successful messages for which you want to receive CloudWatch Logs.
39243935 """
39253936 sns = connect_to_sns()
39263937 try:
3927- sns.set_topic_attributes(TopicArn=topic_arn, AttributeName=successRateRoleValue, AttributeValue=sample_rate)
3938+ for endpoint in endpointTypes:
3939+ sns.set_topic_attributes(TopicArn=topic_arn, AttributeName=f'{endpoint}SuccessFeedbackSampleRate', AttributeValue=sample_rate)
39283940
39293941 except Exception as e:
39303942 reset_to_recognized_state(topic_arn)
3931- exit(f'Failed to set success sample rate of SNS topic '+ topic_arn+': '+ str(e))
3943+ exit(f'Failed to set success sample rate of SNS topic { topic_arn}: { str(e)}' )
39323944
39333945def get_topic_attributes(topic_arn):
39343946 """
@@ -3940,16 +3952,19 @@ def get_topic_attributes(topic_arn):
39403952 return topic_attributes
39413953
39423954 except Exception as e:
3943- exit(f'Failed to get attributes of SNS topic '+ topic_arn+': '+ str(e))
3955+ exit(f'Failed to get attributes of SNS topic { topic_arn}: { str(e)}' )
39443956
39453957def reset_to_recognized_state(topic_arn):
39463958 """
39473959 Used in case of error, will unset all delivery status logging parameters.
39483960 """
39493961 sns = connect_to_sns()
3950-
3951- sns.set_topic_attributes(TopicArn=topic_arn, AttributeName=successFeedbackRoleValue, AttributeValue='')
3952- sns.set_topic_attributes(TopicArn=topic_arn, AttributeName=failureFeedbackRoleValue, AttributeValue='')",
3962+ for endpoint in endpointTypes:
3963+ try:
3964+ sns.set_topic_attributes(TopicArn=topic_arn, AttributeName=f'{endpoint}SuccessFeedbackRoleArn', AttributeValue='')
3965+ sns.set_topic_attributes(TopicArn=topic_arn, AttributeName=f'{endpoint}FailureFeedbackRoleArn', AttributeValue='')
3966+ except Exception:
3967+ print(f'There was an error while resetting SNS Topic {topic_arn}, please manually turn off delivery status logging for protocol {endpoint}')",
39533968 },
39543969 "isEnd": true,
39553970 "name": "EnableDeliveryStatusLogging",
@@ -7737,7 +7752,7 @@ def add_ssl_bucket_policy(event, _):
77377752 "Properties": {
77387753 "CreateIntervalSeconds": 1,
77397754 "DeleteIntervalSeconds": 0,
7740- "DocumentPropertiesHash": "76a143310018a965418e9379eb90670ea780456ea33047bd55f0b597443d59ba ",
7755+ "DocumentPropertiesHash": "dff26ffe5bc8a2eb7a84297f591aa46181b17efa8b7c977636db9cf3beeec61c ",
77417756 "ServiceToken": {
77427757 "Ref": "WaitProviderServiceToken",
77437758 },
@@ -7931,7 +7946,7 @@ def add_ssl_bucket_policy(event, _):
79317946 "Properties": {
79327947 "CreateIntervalSeconds": 0,
79337948 "DeleteIntervalSeconds": 0.5,
7934- "DocumentPropertiesHash": "76a143310018a965418e9379eb90670ea780456ea33047bd55f0b597443d59ba ",
7949+ "DocumentPropertiesHash": "dff26ffe5bc8a2eb7a84297f591aa46181b17efa8b7c977636db9cf3beeec61c ",
79357950 "ServiceToken": {
79367951 "Ref": "WaitProviderServiceToken",
79377952 },
0 commit comments