pulumi-aws
pulumi-aws copied to clipboard
Add notification configuration to SQS Queue Python Example is Incorrect
File: themes/default/content/registry/packages/aws/api-docs/s3/bucketnotification/_index.md
Section: Add notification configuration to SQS Queue
The python example for setting up an S3 notification to an SQS queue does not work. The inline queue policy results in the policy authorizing sqs:SendMessage to a non-existent Queue.
The example should be replaced with:
import pulumi
import pulumi_aws as aws
bucket = aws.s3.BucketV2("bucket")
queue = aws.sqs.Queue("queue")
policy = pulumi.Output.all(queue_arn=queue.arn, source_arn=bucket.arn).apply(lambda args: f"""{{
"Version": "2012-10-17",
"Statement": [{{
"Effect": "Allow",
"Principal": "*",
"Action": "sqs:SendMessage",
"Resource": "{ args['queue_arn'] }",
"Condition": {{
"ArnEquals": {{
"aws:SourceArn": "{ args['source_arn'] }"
}}
}}
}}]
}}
"""
queue_policy = aws.sqs.Queue_Policy("queue_policy", queue_url=queue.id, policy=policy)
bucket_notification = aws.s3.BucketNotification("bucketNotification",
bucket=bucket.id,
queues=[aws.s3.BucketNotificationQueueArgs(
queue_arn=queue.arn,
events=["s3:ObjectCreated:*"],
filter_suffix=".log",
)])
This is derived from this example: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_notification#add-notification-configuration-to-sqs-queue
It works in the original because it hard codes the name of the resource in the policy. We by default apply autonaming, but in this case that breaks the code.
We will need to either:
- Not autoname in this case (not clear how we could decide that though)
- Change the example in our fork to be in the style noted in the suggestion above
Moving as this will likely need to be addressed in the provider (or upstream fork).