cloudposse / terraform-aws-kms-key

Terraform module to provision a KMS key with alias
https://cloudposse.com/accelerate
Apache License 2.0
72 stars 87 forks source link

Running with Complete Example results in Error #36

Closed balq60 closed 2 years ago

balq60 commented 2 years ago

Found a bug? Maybe our Slack Community can help.

Slack Community

Describe the Bug

I started with this - https://github.com/cloudposse/terraform-aws-kms-key/tree/0.12.1/examples/complete

Expected Behavior

I expected the KMS Key to be generated

Steps to Reproduce

Steps to reproduce the behavior:

  1. Download - https://github.com/cloudposse/terraform-aws-kms-key/tree/0.12.1/examples/complete
  2. Terraform init
  3. Terraform plan
  4. See error

Admin:~/environment/ModuleTemplate/LearnModules/modules/kms-key (aws-s3-bucket2) $ terraform plan var.region Enter a value: us-east-1

╷ │ Error: "name" must begin with 'alias/' and be comprised of only [a-zA-Z0-9/_-] │ │ with module.kms_key.aws_kms_alias.default[0], │ on .terraform/modules/kms_key/main.tf line 15, in resource "aws_kms_alias" "default": │ 15: name = coalesce(var.alias, format("alias/%v", module.this.id)) │

When I hard coded the value on line 15 to be alias/123 it Worked!

Also running the simplified example works as well....

Screenshots

If applicable, add screenshots or logs to help explain your problem.

Environment (please complete the following information):

Anything that will help us triage the bug will help. Here are some ideas:

Additional Context

Add any other context about the problem here.

Nuru commented 2 years ago

@balq60 Sorry the documentation is not clear enough about this.

examples/complete is intended to be Terraformed with -var-file fixtures.us-east-2.tfvars. One of

needs to be set in order for the key to have a valid alias name. Cloud Posse modules in general expect one of the context/null-label labels to be set. It is such a universal requirement that we do not always point it out that clearly.