Skip to content

Commit

Permalink
fix(s3): Extract QueueARN instead of external name
Browse files Browse the repository at this point in the history
* Make QueueARN field optional
* Update put bucket notification configuration error message to give a
hint about missing IAM credentials.

Signed-off-by: Maximilian Blatt <maximilian.blatt-extern@deutschebahn.com>
(external expert on behalf of DB Netz AG)
  • Loading branch information
MisterMX committed Feb 21, 2022
1 parent 75e7227 commit 8d596e9
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
3 changes: 2 additions & 1 deletion apis/s3/v1beta1/notificationConfiguration_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ type QueueConfiguration struct {
//
// QueueArn is a required field
// +crossplane:generate:reference:type=github.com/crossplane/provider-aws/apis/sqs/v1beta1.Queue
QueueArn string `json:"queueArn"`
// +crossplane:generate:reference:extractor=github.com/crossplane/provider-aws/apis/sqs/v1beta1.QueueARN()
QueueArn *string `json:"queueArn,omitempty"`

// QueueArnRef references an Queue to retrieve its ARN
// +optional
Expand Down
5 changes: 5 additions & 0 deletions apis/s3/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions apis/s3/v1beta1/zz_generated.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package/crds/s3.aws.crossplane.io_buckets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,6 @@ spec:
type: object
required:
- events
- queueArn
type: object
type: array
topicConfigurations:
Expand Down
6 changes: 3 additions & 3 deletions pkg/controller/s3/bucket/notificationConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (

const (
notificationGetFailed = "cannot get Bucket notification"
notificationPutFailed = "cannot put Bucket notification"
notificationPutFailed = "cannot put Bucket notification (may be caused by insuffifienct permissions on the target)"
)

// NotificationConfigurationClient is the client for API methods and reconciling the LifecycleConfiguration
Expand Down Expand Up @@ -180,7 +180,7 @@ func GenerateQueueConfigurations(config *v1beta1.NotificationConfiguration) []ty
for _, v := range config.QueueConfigurations {
conf := types.QueueConfiguration{
Id: v.ID,
QueueArn: awsclient.String(v.QueueArn),
QueueArn: v.QueueArn,
}
if v.Events != nil {
conf.Events = copyEvents(v.Events)
Expand Down Expand Up @@ -359,7 +359,7 @@ func LateInitializeQueue(external []types.QueueConfiguration, local []v1beta1.Qu
Events: LateInitializeEvents(local[i].Events, v.Events),
Filter: LateInitializeFilter(local[i].Filter, v.Filter),
ID: awsclient.LateInitializeStringPtr(local[i].ID, v.Id),
QueueArn: awsclient.LateInitializeString(local[i].QueueArn, v.QueueArn),
QueueArn: awsclient.LateInitializeStringPtr(local[i].QueueArn, v.QueueArn),
}
}
return local
Expand Down
6 changes: 3 additions & 3 deletions pkg/controller/s3/bucket/notificationConfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func generateNotificationConfig() *v1beta1.NotificationConfiguration {
Events: generateNotificationEvents(),
Filter: generateNotificationFilter(),
ID: &id,
QueueArn: queueArn,
QueueArn: awsclient.String(queueArn),
}},
TopicConfigurations: []v1beta1.TopicConfiguration{{
Events: generateNotificationEvents(),
Expand Down Expand Up @@ -406,7 +406,7 @@ func TestIsNotificationConfigurationUpToDate(t *testing.T) {
Events: generateNotificationEvents(),
Filter: generateNotificationFilter(),
ID: &id,
QueueArn: queueArn,
QueueArn: awsclient.String(queueArn),
}},
TopicConfigurations: []v1beta1.TopicConfiguration{{
Events: generateNotificationEvents(),
Expand Down Expand Up @@ -453,7 +453,7 @@ func TestIsNotificationConfigurationUpToDate(t *testing.T) {
Events: generateNotificationEvents(),
Filter: generateNotificationFilter(),
ID: awsclient.String("queue-id-1"),
QueueArn: queueArn,
QueueArn: awsclient.String(queueArn),
}},
TopicConfigurations: []v1beta1.TopicConfiguration{{
Events: generateNotificationEvents(),
Expand Down

0 comments on commit 8d596e9

Please sign in to comment.