generated from clowdhaus/terraform-aws-module-template
-
-
Notifications
You must be signed in to change notification settings - Fork 91
feat: Add key_spec to external key and add upgrade to v4 readme
#38
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
Merged
bryantbiggs
merged 3 commits into
terraform-aws-modules:master
from
magreenbaum:feat/support_key_spec_and_add_upgrade_doc
Sep 1, 2025
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,162 @@ | ||
| # Upgrade from v3.x to v4.x | ||
|
|
||
| If you have any questions regarding this upgrade process, please consult the [`examples/`](https://github.com/terraform-aws-modules/terraform-aws-kms/tree/master/examples) projects: | ||
|
|
||
| If you find a bug, please open an issue with supporting configuration to reproduce. | ||
|
|
||
| ## List of backwards incompatible changes | ||
|
|
||
| - Support for Terraform `<1.5.7` has been dropped; `1.5.7` is now the minimum supported version | ||
| - Terraform AWS provider minimum version is now `v6.0.0` in order to support the `region` argument in resources | ||
| - Variable `key_statements.conditions` is now `key_statements.condition` | ||
| - Variable `grants.constraints` has changed to type list | ||
|
|
||
| ## Additional changes | ||
|
|
||
| ### Added | ||
|
|
||
| - `region` to support creating resources in a different region than the provider region | ||
|
|
||
| ### Modified | ||
|
|
||
| - `key_statements.conditions` changed to `key_statements.condition` | ||
| - `grants.constrants` changed to type list | ||
|
|
||
| ### Variable and output changes | ||
|
|
||
| 1. Removed variables: | ||
|
|
||
| - None | ||
|
|
||
| 2. Renamed variables: | ||
|
|
||
| - `key_statements.conditions` -> `key_statements.condition` | ||
|
|
||
| 3. Added variables: | ||
|
|
||
| - `region` | ||
|
|
||
| 4. Removed outputs: | ||
|
|
||
| - None | ||
|
|
||
| 5. Renamed outputs: | ||
|
|
||
| - None | ||
|
|
||
| 6. Added outputs: | ||
|
|
||
| - `key_region` added to support output for setting the `region` variable | ||
|
|
||
| ## Upgrade Migrations | ||
|
|
||
| The following examples demonstrate some of the changes that users can elect to make to avoid any potential disruptions when upgrading. | ||
|
|
||
| ### Before 3.x Example | ||
|
|
||
| ```hcl | ||
| module "kms" { | ||
| source = "terraform-aws-modules/kms/aws" | ||
| version = "~> 3.0" | ||
|
|
||
| # Only the affected attributes are shown | ||
| key_statements = [ | ||
| { | ||
| sid = "CloudWatchLogs" | ||
| actions = [ | ||
| "kms:Encrypt*", | ||
| "kms:Decrypt*", | ||
| "kms:ReEncrypt*", | ||
| "kms:GenerateDataKey*", | ||
| "kms:Describe*" | ||
| ] | ||
| resources = ["*"] | ||
|
|
||
| principals = [ | ||
| { | ||
| type = "Service" | ||
| identifiers = ["logs.${data.aws_region.current.name}.amazonaws.com"] | ||
| } | ||
| ] | ||
|
|
||
| conditions = [ | ||
| { | ||
| test = "ArnLike" | ||
| variable = "kms:EncryptionContext:aws:logs:arn" | ||
| values = [ | ||
| "arn:aws:logs:${local.region}:${data.aws_caller_identity.current.account_id}:log-group:*", | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
|
|
||
| # Grants | ||
| grants = { | ||
| lambda = { | ||
| grantee_principal = aws_iam_role.lambda.arn | ||
| operations = ["Encrypt", "Decrypt", "GenerateDataKey"] | ||
| constraints = { | ||
| encryption_context_equals = { | ||
| Department = "Finance" | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| tags = local.tags | ||
| } | ||
| ``` | ||
|
|
||
| ### After 4.x Example | ||
|
|
||
| ```hcl | ||
| module "kms" { | ||
| source = "terraform-aws-modules/kms/aws" | ||
| version = "~> 4.0" | ||
|
|
||
| key_statements = [ | ||
| { | ||
| sid = "CloudWatchLogs" | ||
| actions = [ | ||
| "kms:Encrypt*", | ||
| "kms:Decrypt*", | ||
| "kms:ReEncrypt*", | ||
| "kms:GenerateDataKey*", | ||
| "kms:Describe*" | ||
| ] | ||
| resources = ["*"] | ||
|
|
||
| principals = [ | ||
| { | ||
| type = "Service" | ||
| identifiers = ["logs.${local.region}.amazonaws.com"] | ||
| } | ||
| ] | ||
|
|
||
| condition = [ | ||
| { | ||
| test = "ArnLike" | ||
| variable = "kms:EncryptionContext:aws:logs:arn" | ||
| values = [ | ||
| "arn:aws:logs:${local.region}:${local.account_id}:log-group:*", | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
|
|
||
| # Grants | ||
| grants = { | ||
| lambda = { | ||
| grantee_principal = aws_iam_role.lambda.arn | ||
| operations = ["Encrypt", "Decrypt", "GenerateDataKey"] | ||
| constraints = [{ | ||
| encryption_context_equals = { | ||
| Department = "Finance" | ||
| } | ||
| }] | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
thank so much you for this 😅