AWS error when creating an SNS Topic Subscription when RawMessageDelivery set to false

Viewed 33

I want to create a subscription for a Lambda function endpoint, which does not support Raw Message Delivery, so I send the attribute 'RawDelivery'='false' as illustrated in the below code:

sns_client = boto3.client('sns', region_name='us-east-2')
topic_arn = 'arn:aws:sns:us-east-2:myacct:my-topic'
protocol = 'lambda'
endpoint = 'arn:aws:lambda:us-east-2:myacct:function:my-lambda-function'
attribs = dict()
attribs['RawMessageDelivery'] = 'false'
sns_client.subscribe(TopicArn=topic_arn, Protocol=protocol, Endpoint=endpoint,
                     Attributes=attribs)

However, AWS responds with this error:

Invalid parameter: Attributes Reason: Delivery protocol [lambda] does not support raw message delivery.

According to the AWS Boto3 docs:

When set to true ,[RawMessageDelivery] enables raw message delivery to Amazon SQS or HTTP/S endpoints.

I'm setting it to 'false', not 'true', so why does AWS think I'm trying to enable raw message delivery?

1 Answers
attribs['RawMessageDelivery'] = 'false'

You're setting the attribute to 'false' instead of False. 'false', a string, is a truthy value

% python <<<"print('truthy' if 'false' else 'not truthy')"                                                                   
truthy

Probably you don't need to set the attribute at all. From the text I would guess False is the default.

Related