Skip to content

Commit

Permalink
deprecate aws_kms_key attribute 'policy' in favor of aws_kms_key_poli…
Browse files Browse the repository at this point in the history
…cy_attachment resource
  • Loading branch information
albsilv-aws committed Mar 11, 2023
1 parent e49e771 commit 0a13a11
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions internal/service/kms/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ func ResourceKey() *schema.Resource {
Type: schema.TypeString,
Optional: true,
Computed: true,
Deprecated: "Use the aws_kms_key_policy_attachment resource instead",
DiffSuppressFunc: verify.SuppressEquivalentPolicyDiffs,
DiffSuppressOnRefresh: true,
ValidateFunc: validation.StringIsJSON,
Expand Down
6 changes: 5 additions & 1 deletion website/docs/r/kms_key.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ description: |-
Manages a single-Region or multi-Region primary KMS key.
---

~> **NOTE on KMS Key Policy:** KMS Key Policy can be configured in either the standalone resource [`aws_kms_key_policy_attachment`](kms_key_policy_attachment.html)
or with the deprecated parameter `policy` in the resource `aws_kms_key`.
Configuring with both will cause inconsistencies and may overwrite configuration.

# Resource: aws_kms_key

Manages a single-Region or multi-Region primary KMS key.
Expand All @@ -29,7 +33,7 @@ Defaults to `ENCRYPT_DECRYPT`.
* `custom_key_store_id` - (Optional) ID of the KMS [Custom Key Store](https://docs.aws.amazon.com/kms/latest/developerguide/create-cmk-keystore.html) where the key will be stored instead of KMS (eg CloudHSM).
* `customer_master_key_spec` - (Optional) Specifies whether the key contains a symmetric key or an asymmetric key pair and the encryption algorithms or signing algorithms that the key supports.
Valid values: `SYMMETRIC_DEFAULT`, `RSA_2048`, `RSA_3072`, `RSA_4096`, `HMAC_256`, `ECC_NIST_P256`, `ECC_NIST_P384`, `ECC_NIST_P521`, or `ECC_SECG_P256K1`. Defaults to `SYMMETRIC_DEFAULT`. For help with choosing a key spec, see the [AWS KMS Developer Guide](https://docs.aws.amazon.com/kms/latest/developerguide/symm-asymm-choose.html).
* `policy` - (Optional) A valid policy JSON document. Although this is a key policy, not an IAM policy, an [`aws_iam_policy_document`](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document), in the form that designates a principal, can be used. For more information about building policy documents with Terraform, see the [AWS IAM Policy Document Guide](https://learn.hashicorp.com/terraform/aws/iam-policy).
* `policy` - (Optional, **Deprecated** use `aws_kms_key_policy_attachment` instead) A valid policy JSON document. Although this is a key policy, not an IAM policy, an [`aws_iam_policy_document`](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document), in the form that designates a principal, can be used. For more information about building policy documents with Terraform, see the [AWS IAM Policy Document Guide](https://learn.hashicorp.com/terraform/aws/iam-policy).

~> **NOTE:** Note: All KMS keys must have a key policy. If a key policy is not specified, AWS gives the KMS key a [default key policy](https://docs.aws.amazon.com/kms/latest/developerguide/key-policies.html#key-policy-default) that gives all principals in the owning account unlimited access to all KMS operations for the key. This default key policy effectively delegates all access control to IAM policies and KMS grants.

Expand Down

0 comments on commit 0a13a11

Please sign in to comment.