hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.82k stars 9.16k forks source link

KMS arguments unintuitive #30120

Open steve-hb opened 1 year ago

steve-hb commented 1 year ago

Description

I've been adding KMS to all my resources and wondered why Terraform couldn't find the KMS key for the cloudwatch log group. Checked the code multiple times, tried adding a "depends_on" (maybe the dependency resolution broke?), tried changing policies and finally decided to read the docs again:

kms_key_id - (Optional) The ARN of the KMS Key to use when encrypting log data.

This resulted in the following code (with some small changes):

resource "aws_cloudwatch_log_group" "my_log_group" {
  name              = "my-wonderful-log-group"
  retention_in_days = 14
  kms_key_id        = aws_kms_key.encryption_key.arn
}

Could we please rename the kms_key_id argument to kms_key_arn in order to have consistent arguments? Maybe adding an alias and deprecating the old one is feasible in this case? This issue doesn't only affect CW, but some other resources - some of them supposedly support both formats.

If I miss something specific about the terminology of KMS, please let me know :)

PS: Sorry if I chose the wrong template, couldn't decide between bug, enhancement and docs (which are correct tho, just a little bit confusing).

References

https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_log_group#argument-reference

Would you like to implement a fix?

None

github-actions[bot] commented 1 year ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

mbbush commented 9 months ago

The choice of name is definitely confusing, and it's in a lot of resources across the provider. In many cases, you can use the kms key id (or the ARN), but only when the resource is in the same aws account as the key, so using the ARN is generally preferred.

The hard part is figuring out how to implement this in a way that doesn't break existing code.