From 6da65a903185d34e2219058a96535cf7aa31bce5 Mon Sep 17 00:00:00 2001 From: Matt Bush Date: Mon, 18 Mar 2024 01:04:14 -0700 Subject: [PATCH 1/2] Update examples for s3 bucket notifications and sqs queue policies Signed-off-by: Matt Bush --- .../s3/v1beta1/bucketnotification-sqs.yaml | 84 +++++++++++++++++++ examples/s3/v1beta1/bucketnotification.yaml | 65 +++++++++++++- examples/sqs/v1beta1/queuepolicy.yaml | 42 +++++----- 3 files changed, 167 insertions(+), 24 deletions(-) create mode 100644 examples/s3/v1beta1/bucketnotification-sqs.yaml diff --git a/examples/s3/v1beta1/bucketnotification-sqs.yaml b/examples/s3/v1beta1/bucketnotification-sqs.yaml new file mode 100644 index 0000000000..3416a6501a --- /dev/null +++ b/examples/s3/v1beta1/bucketnotification-sqs.yaml @@ -0,0 +1,84 @@ +# SPDX-FileCopyrightText: 2024 The Crossplane Authors +# +# SPDX-License-Identifier: CC0-1.0 + +apiVersion: s3.aws.upbound.io/v1beta1 +kind: BucketNotification +metadata: + name: example + annotations: + meta.upbound.io/example-id: s3/v1beta1/bucketnotification + labels: + testing.upbound.io/example-name: bucket-notification +spec: + forProvider: + region: us-west-1 + bucketSelector: + matchLabels: + testing.upbound.io/example-name: bucket-notification + queue: + - events: + - "s3:ObjectCreated:*" + filterSuffix: ".log" + queueArnSelector: + matchLabels: + testing.upbound.io/example-name: bucket-notification + +--- +apiVersion: s3.aws.upbound.io/v1beta1 +kind: Bucket +metadata: + name: bucket-notification + annotations: + meta.upbound.io/example-id: s3/v1beta1/bucketnotification + crossplane.io/external-name: ${Rand.RFC1123Subdomain} + labels: + testing.upbound.io/example-name: bucket-notification +spec: + forProvider: + region: us-west-1 + +--- +apiVersion: sqs.aws.upbound.io/v1beta1 +kind: Queue +metadata: + name: bucket-notification + annotations: + meta.upbound.io/example-id: s3/v1beta1/bucketnotification + labels: + testing.upbound.io/example-name: bucket-notification +spec: + forProvider: + region: us-west-1 + name: bucket-notification + +--- +apiVersion: sqs.aws.upbound.io/v1beta1 +kind: QueuePolicy +metadata: + name: bucket-notification + annotations: + meta.upbound.io/example-id: s3/v1beta1/bucketnotification + labels: + testing.upbound.io/example-name: bucket-notification +spec: + forProvider: + region: us-west-1 + queueUrlSelector: + matchLabels: + testing.upbound.io/example-name: bucket-notification + policy: | + { + "Version": "2012-10-17", + "Statement": [ + { + "Sid": "example", + "Effect": "Allow", + "Principal": { + "Service": "s3.amazonaws.com" + }, + "Action": "sqs:SendMessage", + "Resource": "arn:aws:sqs:us-west-1:*:bucket-notification" + } + ] + } diff --git a/examples/s3/v1beta1/bucketnotification.yaml b/examples/s3/v1beta1/bucketnotification.yaml index c56777e708..fa70e3c6c5 100644 --- a/examples/s3/v1beta1/bucketnotification.yaml +++ b/examples/s3/v1beta1/bucketnotification.yaml @@ -7,17 +7,76 @@ kind: BucketNotification metadata: name: example annotations: - upjet.upbound.io/manual-intervention: "Requires a TopicPolicy for the referenced Topic and TopicPolicy is not covered yet." + meta.upbound.io/example-id: s3/v1beta1/bucketnotification + labels: + testing.upbound.io/example-name: bucket-notification spec: forProvider: region: us-west-1 bucketSelector: matchLabels: - testing.upbound.io/example-name: s3 + testing.upbound.io/example-name: bucket-notification topic: - events: - "s3:ObjectCreated:*" filterSuffix: ".log" topicArnSelector: matchLabels: - testing.upbound.io/example-name: s3 + testing.upbound.io/example-name: bucket-notification + +--- +apiVersion: s3.aws.upbound.io/v1beta1 +kind: Bucket +metadata: + name: bucket-notification + annotations: + meta.upbound.io/example-id: s3/v1beta1/bucketnotification + crossplane.io/external-name: ${Rand.RFC1123Subdomain} + labels: + testing.upbound.io/example-name: bucket-notification +spec: + forProvider: + region: us-west-1 +--- +apiVersion: sns.aws.upbound.io/v1beta1 +kind: Topic +metadata: + name: bucket-notification + annotations: + meta.upbound.io/example-id: s3/v1beta1/bucketnotification + labels: + testing.upbound.io/example-name: bucket-notification +spec: + forProvider: + region: us-west-1 + +--- +apiVersion: sns.aws.upbound.io/v1beta1 +kind: TopicPolicy +metadata: + name: bucket-notification + annotations: + meta.upbound.io/example-id: s3/v1beta1/bucketnotification + labels: + testing.upbound.io/example-name: bucket-notification +spec: + forProvider: + region: us-west-1 + arnSelector: + matchLabels: + testing.upbound.io/example-name: bucket-notification + policy: | + { + "Version": "2012-10-17", + "Statement": [ + { + "Sid": "example", + "Effect": "Allow", + "Principal": { + "Service": "s3.amazonaws.com" + }, + "Action": "sns:Publish", + "Resource": "arn:aws:sns:us-west-1:*:bucket-notification" + } + ] + } diff --git a/examples/sqs/v1beta1/queuepolicy.yaml b/examples/sqs/v1beta1/queuepolicy.yaml index 4fe6524c31..0c50d9a8d5 100644 --- a/examples/sqs/v1beta1/queuepolicy.yaml +++ b/examples/sqs/v1beta1/queuepolicy.yaml @@ -5,43 +5,43 @@ apiVersion: sqs.aws.upbound.io/v1beta1 kind: QueuePolicy metadata: - labels: - testing.upbound.io/example-name: test - name: test + name: queue-policy annotations: - upjet.upbound.io/manual-intervention: "This resource requires manual intervention for adding resource and source ARNs." + meta.upbound.io/example-id: sqs/v1beta1/queue-policy + labels: + testing.upbound.io/example-name: queue-policy spec: forProvider: + region: us-west-1 + queueUrlSelector: + matchLabels: + testing.upbound.io/example-name: queue-policy policy: | { "Version": "2012-10-17", - "Id": "sqspolicy", "Statement": [ { - "Sid": "First", + "Sid": "example", "Effect": "Allow", - "Principal": "*", + "Principal": { + "Service": "s3.amazonaws.com" + }, "Action": "sqs:SendMessage", - "Resource": "${resource_arn}", - "Condition": { - "ArnEquals": { - "aws:SourceArn": "${source_arn}}" - } - } + "Resource": "arn:aws:sqs:us-west-1:*:queue-policy" } ] } - queueUrlSelector: - matchLabels: - testing.upbound.io/example-name: example - region: us-west-1 --- - -apiVersion: sns.aws.upbound.io/v1beta1 -kind: Topic +apiVersion: sqs.aws.upbound.io/v1beta1 +kind: Queue metadata: - name: user-updates-topic + name: queue-policy + annotations: + meta.upbound.io/example-id: sqs/v1beta1/queuepolicy + labels: + testing.upbound.io/example-name: queue-policy spec: forProvider: region: us-west-1 + name: queue-policy From df2d01b20541b70acf64a42076cbb63096d60c33 Mon Sep 17 00:00:00 2001 From: Matt Bush Date: Mon, 18 Mar 2024 11:14:08 -0700 Subject: [PATCH 2/2] Merge both bucket notification examples Signed-off-by: Matt Bush --- .../s3/v1beta1/bucketnotification-sqs.yaml | 84 ------------------- examples/s3/v1beta1/bucketnotification.yaml | 56 ++++++++++++- 2 files changed, 54 insertions(+), 86 deletions(-) delete mode 100644 examples/s3/v1beta1/bucketnotification-sqs.yaml diff --git a/examples/s3/v1beta1/bucketnotification-sqs.yaml b/examples/s3/v1beta1/bucketnotification-sqs.yaml deleted file mode 100644 index 3416a6501a..0000000000 --- a/examples/s3/v1beta1/bucketnotification-sqs.yaml +++ /dev/null @@ -1,84 +0,0 @@ -# SPDX-FileCopyrightText: 2024 The Crossplane Authors -# -# SPDX-License-Identifier: CC0-1.0 - -apiVersion: s3.aws.upbound.io/v1beta1 -kind: BucketNotification -metadata: - name: example - annotations: - meta.upbound.io/example-id: s3/v1beta1/bucketnotification - labels: - testing.upbound.io/example-name: bucket-notification -spec: - forProvider: - region: us-west-1 - bucketSelector: - matchLabels: - testing.upbound.io/example-name: bucket-notification - queue: - - events: - - "s3:ObjectCreated:*" - filterSuffix: ".log" - queueArnSelector: - matchLabels: - testing.upbound.io/example-name: bucket-notification - ---- -apiVersion: s3.aws.upbound.io/v1beta1 -kind: Bucket -metadata: - name: bucket-notification - annotations: - meta.upbound.io/example-id: s3/v1beta1/bucketnotification - crossplane.io/external-name: ${Rand.RFC1123Subdomain} - labels: - testing.upbound.io/example-name: bucket-notification -spec: - forProvider: - region: us-west-1 - ---- -apiVersion: sqs.aws.upbound.io/v1beta1 -kind: Queue -metadata: - name: bucket-notification - annotations: - meta.upbound.io/example-id: s3/v1beta1/bucketnotification - labels: - testing.upbound.io/example-name: bucket-notification -spec: - forProvider: - region: us-west-1 - name: bucket-notification - ---- -apiVersion: sqs.aws.upbound.io/v1beta1 -kind: QueuePolicy -metadata: - name: bucket-notification - annotations: - meta.upbound.io/example-id: s3/v1beta1/bucketnotification - labels: - testing.upbound.io/example-name: bucket-notification -spec: - forProvider: - region: us-west-1 - queueUrlSelector: - matchLabels: - testing.upbound.io/example-name: bucket-notification - policy: | - { - "Version": "2012-10-17", - "Statement": [ - { - "Sid": "example", - "Effect": "Allow", - "Principal": { - "Service": "s3.amazonaws.com" - }, - "Action": "sqs:SendMessage", - "Resource": "arn:aws:sqs:us-west-1:*:bucket-notification" - } - ] - } diff --git a/examples/s3/v1beta1/bucketnotification.yaml b/examples/s3/v1beta1/bucketnotification.yaml index fa70e3c6c5..eb4075fd70 100644 --- a/examples/s3/v1beta1/bucketnotification.yaml +++ b/examples/s3/v1beta1/bucketnotification.yaml @@ -12,13 +12,20 @@ metadata: testing.upbound.io/example-name: bucket-notification spec: forProvider: - region: us-west-1 bucketSelector: matchLabels: testing.upbound.io/example-name: bucket-notification + queue: + - events: + - "s3:ObjectCreated:*" + filterSuffix: ".log" + queueArnSelector: + matchLabels: + testing.upbound.io/example-name: bucket-notification + region: us-west-1 topic: - events: - - "s3:ObjectCreated:*" + - "s3:ObjectRemoved:*" filterSuffix: ".log" topicArnSelector: matchLabels: @@ -80,3 +87,48 @@ spec: } ] } + +--- +apiVersion: sqs.aws.upbound.io/v1beta1 +kind: Queue +metadata: + name: bucket-notification + annotations: + meta.upbound.io/example-id: s3/v1beta1/bucketnotification + labels: + testing.upbound.io/example-name: bucket-notification +spec: + forProvider: + region: us-west-1 + name: bucket-notification + +--- +apiVersion: sqs.aws.upbound.io/v1beta1 +kind: QueuePolicy +metadata: + name: bucket-notification + annotations: + meta.upbound.io/example-id: s3/v1beta1/bucketnotification + labels: + testing.upbound.io/example-name: bucket-notification +spec: + forProvider: + region: us-west-1 + queueUrlSelector: + matchLabels: + testing.upbound.io/example-name: bucket-notification + policy: | + { + "Version": "2012-10-17", + "Statement": [ + { + "Sid": "example", + "Effect": "Allow", + "Principal": { + "Service": "s3.amazonaws.com" + }, + "Action": "sqs:SendMessage", + "Resource": "arn:aws:sqs:us-west-1:*:bucket-notification" + } + ] + }