-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate AWS OpenSearch requests signing credential generation to AWS SDK V2 #51149
Conversation
// TODO(gabrielcorado): once all service callers are updated to use | ||
// AWSConfigProvider, make it required and remove session provider and | ||
// credentials getter fallback. | ||
func (s *SigningService) newSigner(ctx context.Context, signCtx *SigningCtx) (*v4.Signer, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I like how this makes it easy to migrate each dependent service in small PRs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took another look at this and it won't match prior behavior because the engine will not assume the role from the db AWS metadata to chain the roles together.
We can fix that by adding e.sessionCtx.Database.GetAWS().AssumeRoleARN
to the SigningCtx
and passing it when we call SignRequest.
Alternatively, we could add it to the SigningServiceConfig, e.g
func (s *SigningService) newSigner(ctx context.Context, signCtx *SigningCtx) (*v4.Signer, error) {
if s.AWSConfigProvider != nil {
awsCfg, err := s.AWSConfigProvider.GetConfig(ctx, signCtx.SigningRegion,
awsconfig.WithAssumeRole(s.AWSRoleArn, s.AWSExternalID),
awsconfig.WithAssumeRole(signCtx.AWSRoleArn, signCtx.AWSExternalID),
…com:gravitational/teleport into gabrielcorado/opensearch-aws-sdk2-migration
Thanks for pointing it out. I've updated the Also, @smallinsky, if you can take a look at this, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM if tested
Does that mean the existing code uses external ID twice for At this point, i would rather make the |
Yes. It should have been chained like this: teleport/lib/srv/db/dynamodb/engine.go Lines 233 to 236 in c6b09ce
I agree that we should reduce the scope of signing service responsibilities. |
@GavinFrazar @greedy52 I've kept this change as simple as possible by adding another parameter to the SigingCtx and having the caller decide how to specify the external IDs. This isn't ideal, but since the signing service will be reworked during the SDK V2 migration, any improvements on the API definition should come from there because we'll know precisely the requirements for V2. We'll also consider the app access usage. |
Related to #14142
This PR updates the AWS signing service to accept using the AWS config provider (which uses AWS SDK V2). OpenSearch uses the service to sign the requests.
Note that the signer part still uses the SDK V1 signer (with the
NewSignerV2
helper function). So, no changes are required to the signing logic for now. This will be updated in future PRs.