diff --git a/examples/s3/v1beta1/bucketnotification.yaml b/examples/s3/v1beta1/bucketnotification.yaml index c56777e708..eb4075fd70 100644 --- a/examples/s3/v1beta1/bucketnotification.yaml +++ b/examples/s3/v1beta1/bucketnotification.yaml @@ -7,17 +7,128 @@ 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 + 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: - 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" + } + ] + } + +--- +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/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 diff --git a/internal/clients/aws.go b/internal/clients/aws.go index e7fdbe9da6..13fa90b9ab 100644 --- a/internal/clients/aws.go +++ b/internal/clients/aws.go @@ -25,6 +25,7 @@ import ( const ( keyAccountID = "account_id" + keyRegion = "region" ) type SetupConfig struct { @@ -64,6 +65,10 @@ func SelectTerraformSetup(config *SetupConfig) terraform.SetupFn { // nolint:goc ps.ClientMetadata = map[string]string{ keyAccountID: account, } + // several external name configs depend on the setup.Configuration for templating region + ps.Configuration = map[string]any{ + keyRegion: awsCfg.Region, + } if config.TerraformProvider == nil { return terraform.Setup{}, errors.New("terraform provider cannot be nil") }