Skip to content

keystore: add support for aws kms multi-region key replication#53927

Merged
dboslee merged 15 commits intomasterfrom
david/kms-multi-region
May 27, 2025
Merged

keystore: add support for aws kms multi-region key replication#53927
dboslee merged 15 commits intomasterfrom
david/kms-multi-region

Conversation

@dboslee
Copy link
Copy Markdown
Contributor

@dboslee dboslee commented Apr 10, 2025

This adds the logic to handle kms key replication.

Key replication is configured on key creation and during teleport auth initialization. This allows for reconfiguring the primary/replica regions after an auth restart.

Let me know if there are any concerns with updating the stored key arn after a primary region change. This it not required but I thought it would provide a better UX. The keyID is the same however the full key arn changes with the aws region the primary is located in.

Each server only accesses KMS in the region configured by AWSRegion. As a consequence of this only the region where the primary key currently resides is able to perform config changes on startup to replicate the key and update the primary. The other consequence of this is that when KMS is down in a given region auth in that region should be considered unhealthy. I plan to follow this up with a change that would link KMS availability to auth readiness.

One final note, I had to increase the pendingKeyTimeout to 2 minutes. this is to account for the time it takes to successfully call GetPublicKey after updating the primary region. I've observed delays of ~1 minute during key creation when an auth server outside the primary region creates creates the key and needs to update the primary. I am still discussing this issue with AWS support but so far they saying this is expected behavior.

changelog: Added support for AWS KMS multi-region keys with key replication

@dboslee dboslee requested a review from nklaassen April 10, 2025 17:28
@github-actions github-actions Bot requested a review from fheinecke April 10, 2025 17:28
Comment thread lib/auth/keystore/manager.go Outdated
Comment thread lib/auth/keystore/aws_kms.go Outdated
Comment thread lib/auth/init.go Outdated
Comment thread lib/auth/keystore/aws_kms.go Outdated
Comment thread lib/auth/keystore/aws_kms.go Outdated
Comment thread lib/auth/keystore/aws_kms.go Outdated
Comment thread lib/auth/keystore/aws_kms.go
Comment thread lib/service/servicecfg/auth.go Outdated
Comment thread lib/config/fileconf.go Outdated
Comment thread lib/auth/init.go
@dboslee dboslee requested a review from nklaassen May 12, 2025 20:53
Comment on lines +59 to +60
// TODO(dboslee): waiting on AWS support to answer question regarding
// long time for GetPublicKey to succeed after updating key via UpdatePrimaryRegion.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KMS service team will deploy a fix by May 23 to resolve the GetPublicKey operation failures that occur when keys are in the 'updating' state. The service team has confirmed the code update is ready for deployment.

Update from AWS. Going to leave this until I am able to test the fix though. If this PR lands first I will create a follow up to adjust the timeout back down.

eriktate added a commit that referenced this pull request May 20, 2025
eriktate added a commit that referenced this pull request May 20, 2025
Comment thread lib/auth/init.go
Comment thread lib/auth/keystore/aws_kms.go
Comment thread lib/auth/keystore/manager.go
Comment thread lib/config/configuration.go Outdated
@rosstimothy rosstimothy requested a review from eriktate May 21, 2025 14:17
@public-teleport-github-review-bot public-teleport-github-review-bot Bot removed the request for review from fheinecke May 22, 2025 18:56
eriktate added a commit that referenced this pull request May 22, 2025
@dboslee dboslee added this pull request to the merge queue May 27, 2025
Merged via the queue into master with commit bb8700b May 27, 2025
40 checks passed
@dboslee dboslee deleted the david/kms-multi-region branch May 27, 2025 22:32
@backport-bot-workflows
Copy link
Copy Markdown
Contributor

@dboslee See the table below for backport results.

Branch Result
branch/v16 Failed
branch/v17 Failed
branch/v18 Create PR

dboslee added a commit that referenced this pull request May 28, 2025
* keystore: add support for aws kms multi-region key replication

* update func name ApplyConfig -> ApplyMultiRegionConfig

* more descriptive var out -> describeKeyOut

* fix typo

* better var names

* add comment

* renaming vars for readability

* refactor multi-region auth config

* add comment about cert authority lock

* fix typo

* move funcs up

* update comment

* copy whole struct instead of individual values
github-merge-queue Bot pushed a commit that referenced this pull request Jun 10, 2025
…53927) (#55212)

* keystore: add support for aws kms multi-region key replication (#53927)

* keystore: add support for aws kms multi-region key replication

* update func name ApplyConfig -> ApplyMultiRegionConfig

* more descriptive var out -> describeKeyOut

* fix typo

* better var names

* add comment

* renaming vars for readability

* refactor multi-region auth config

* add comment about cert authority lock

* fix typo

* move funcs up

* update comment

* copy whole struct instead of individual values

* keystore: retry describe key when applying multi-region kms config (#55274)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants