diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index 8a1927a39ca..5dccf1a2d36 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -3,3 +3,5 @@ ### SDK Enhancements ### SDK Bugs +* `s3control`: Fixes bug in SDK that caused GetAccessPointPolicy, DeleteAccessPointPolicy, and PutAccessPointPolicy operations to not route properly for S3 on Outposts. ([#3599](https://github.com/aws/aws-sdk-go/pull/3599)) + * Fixes [#3598](https://github.com/aws/aws-sdk-go/issues/3598). diff --git a/private/model/api/customization_passes.go b/private/model/api/customization_passes.go index 2ea7bf6c0e8..8f7c3308845 100644 --- a/private/model/api/customization_passes.go +++ b/private/model/api/customization_passes.go @@ -224,11 +224,11 @@ func s3ControlCustomizations(a *API) error { // List of input shapes that use accesspoint names as arnable fields accessPointNameArnables := map[string]struct{}{ - "GetAccessPointInput": {}, - "DeleteAccessPointInput": {}, - "PutAccessPointPolicy": {}, - "GetAccessPointPolicy": {}, - "DeleteAccessPointPolicy": {}, + "GetAccessPointInput": {}, + "DeleteAccessPointInput": {}, + "PutAccessPointPolicyInput": {}, + "GetAccessPointPolicyInput": {}, + "DeleteAccessPointPolicyInput": {}, } var endpointARNShape *ShapeRef diff --git a/service/s3control/api.go b/service/s3control/api.go index f2c525aa0f0..dce38f30e3e 100644 --- a/service/s3control/api.go +++ b/service/s3control/api.go @@ -491,6 +491,9 @@ func (c *S3Control) DeleteAccessPointPolicyRequest(input *DeleteAccessPointPolic output = &DeleteAccessPointPolicyOutput{} req = c.newRequest(op, input, output) + // update account id or check if provided input for account id member matches + // the account id present in ARN + req.Handlers.Validate.PushFrontNamed(updateAccountIDWithARNHandler) req.Handlers.Unmarshal.Swap(restxml.UnmarshalHandler.Name, protocol.UnmarshalDiscardBodyHandler) req.Handlers.Build.PushBackNamed(protocol.NewHostPrefixHandler("{AccountId}.", input.hostLabels)) req.Handlers.Build.PushBackNamed(protocol.ValidateEndpointHostHandler) @@ -1397,6 +1400,9 @@ func (c *S3Control) GetAccessPointPolicyRequest(input *GetAccessPointPolicyInput output = &GetAccessPointPolicyOutput{} req = c.newRequest(op, input, output) + // update account id or check if provided input for account id member matches + // the account id present in ARN + req.Handlers.Validate.PushFrontNamed(updateAccountIDWithARNHandler) req.Handlers.Build.PushBackNamed(protocol.NewHostPrefixHandler("{AccountId}.", input.hostLabels)) req.Handlers.Build.PushBackNamed(protocol.ValidateEndpointHostHandler) return @@ -2628,6 +2634,9 @@ func (c *S3Control) PutAccessPointPolicyRequest(input *PutAccessPointPolicyInput output = &PutAccessPointPolicyOutput{} req = c.newRequest(op, input, output) + // update account id or check if provided input for account id member matches + // the account id present in ARN + req.Handlers.Validate.PushFrontNamed(updateAccountIDWithARNHandler) req.Handlers.Unmarshal.Swap(restxml.UnmarshalHandler.Name, protocol.UnmarshalDiscardBodyHandler) req.Handlers.Build.PushBackNamed(protocol.NewHostPrefixHandler("{AccountId}.", input.hostLabels)) req.Handlers.Build.PushBackNamed(protocol.ValidateEndpointHostHandler) @@ -4385,6 +4394,47 @@ func (s *DeleteAccessPointPolicyInput) hostLabels() map[string]string { } } +func (s *DeleteAccessPointPolicyInput) getEndpointARN() (arn.Resource, error) { + if s.Name == nil { + return nil, fmt.Errorf("member Name is nil") + } + return parseEndpointARN(*s.Name) +} + +func (s *DeleteAccessPointPolicyInput) hasEndpointARN() bool { + if s.Name == nil { + return false + } + return arn.IsARN(*s.Name) +} + +// updateArnableField updates the value of the input field that +// takes an ARN as an input. This method is useful to backfill +// the parsed resource name from ARN into the input member. +// It returns a pointer to a modified copy of input and an error. +// Note that original input is not modified. +func (s DeleteAccessPointPolicyInput) updateArnableField(v string) (interface{}, error) { + if s.Name == nil { + return nil, fmt.Errorf("member Name is nil") + } + s.Name = aws.String(v) + return &s, nil +} + +// updateAccountID returns a pointer to a modified copy of input, +// if account id is not provided, we update the account id in modified input +// if account id is provided, but doesn't match with the one in ARN, we throw an error +// if account id is not updated, we return nil. Note that original input is not modified. +func (s DeleteAccessPointPolicyInput) updateAccountID(accountId string) (interface{}, error) { + if s.AccountId == nil { + s.AccountId = aws.String(accountId) + return &s, nil + } else if *s.AccountId != accountId { + return &s, fmt.Errorf("Account ID mismatch, the Account ID cannot be specified in an ARN and in the accountId field") + } + return nil, nil +} + type DeleteAccessPointPolicyOutput struct { _ struct{} `type:"structure"` } @@ -5390,6 +5440,47 @@ func (s *GetAccessPointPolicyInput) hostLabels() map[string]string { } } +func (s *GetAccessPointPolicyInput) getEndpointARN() (arn.Resource, error) { + if s.Name == nil { + return nil, fmt.Errorf("member Name is nil") + } + return parseEndpointARN(*s.Name) +} + +func (s *GetAccessPointPolicyInput) hasEndpointARN() bool { + if s.Name == nil { + return false + } + return arn.IsARN(*s.Name) +} + +// updateArnableField updates the value of the input field that +// takes an ARN as an input. This method is useful to backfill +// the parsed resource name from ARN into the input member. +// It returns a pointer to a modified copy of input and an error. +// Note that original input is not modified. +func (s GetAccessPointPolicyInput) updateArnableField(v string) (interface{}, error) { + if s.Name == nil { + return nil, fmt.Errorf("member Name is nil") + } + s.Name = aws.String(v) + return &s, nil +} + +// updateAccountID returns a pointer to a modified copy of input, +// if account id is not provided, we update the account id in modified input +// if account id is provided, but doesn't match with the one in ARN, we throw an error +// if account id is not updated, we return nil. Note that original input is not modified. +func (s GetAccessPointPolicyInput) updateAccountID(accountId string) (interface{}, error) { + if s.AccountId == nil { + s.AccountId = aws.String(accountId) + return &s, nil + } else if *s.AccountId != accountId { + return &s, fmt.Errorf("Account ID mismatch, the Account ID cannot be specified in an ARN and in the accountId field") + } + return nil, nil +} + type GetAccessPointPolicyOutput struct { _ struct{} `type:"structure"` @@ -8011,6 +8102,47 @@ func (s *PutAccessPointPolicyInput) hostLabels() map[string]string { } } +func (s *PutAccessPointPolicyInput) getEndpointARN() (arn.Resource, error) { + if s.Name == nil { + return nil, fmt.Errorf("member Name is nil") + } + return parseEndpointARN(*s.Name) +} + +func (s *PutAccessPointPolicyInput) hasEndpointARN() bool { + if s.Name == nil { + return false + } + return arn.IsARN(*s.Name) +} + +// updateArnableField updates the value of the input field that +// takes an ARN as an input. This method is useful to backfill +// the parsed resource name from ARN into the input member. +// It returns a pointer to a modified copy of input and an error. +// Note that original input is not modified. +func (s PutAccessPointPolicyInput) updateArnableField(v string) (interface{}, error) { + if s.Name == nil { + return nil, fmt.Errorf("member Name is nil") + } + s.Name = aws.String(v) + return &s, nil +} + +// updateAccountID returns a pointer to a modified copy of input, +// if account id is not provided, we update the account id in modified input +// if account id is provided, but doesn't match with the one in ARN, we throw an error +// if account id is not updated, we return nil. Note that original input is not modified. +func (s PutAccessPointPolicyInput) updateAccountID(accountId string) (interface{}, error) { + if s.AccountId == nil { + s.AccountId = aws.String(accountId) + return &s, nil + } else if *s.AccountId != accountId { + return &s, fmt.Errorf("Account ID mismatch, the Account ID cannot be specified in an ARN and in the accountId field") + } + return nil, nil +} + type PutAccessPointPolicyOutput struct { _ struct{} `type:"structure"` }