|
| 1 | +--- |
| 2 | +title: "Calling `chamber write` triggers `Error: InvalidKeyId: ... parameter_store_key is not found.`" |
| 3 | +excerpt: "Chamber expects to find a KMS key with alias `parameter_store_key`" |
| 4 | +--- |
| 5 | + |
| 6 | +# Question |
| 7 | + |
| 8 | +``` |
| 9 | +Error: InvalidKeyId: Alias arn:aws:kms:us-west-2:671362398325:alias/parameter_store_key is not found. (Service: AWSKMS; Status Code: 400; Error Code: NotFoundException; Request ID: bf9b3240-39f5-11e8-921d-e9dc98bd5b1a) |
| 10 | +``` |
| 11 | + |
| 12 | +# Answer |
| 13 | + |
| 14 | +Per the [documentation](https://github.com/segmentio/chamber/blob/master/README.md#setting-up-kms), Chamber expects to find a KMS key with alias `parameter_store_key` in the account that you are writing/reading secrets. |
| 15 | + |
| 16 | +You can follow the [AWS KMS documentation](http://docs.aws.amazon.com/kms/latest/developerguide/create-keys.html) to create your key, and follow this guide to [set up your alias](http://docs.aws.amazon.com/kms/latest/developerguide/programming-aliases.html). |
| 17 | + |
| 18 | +We recommend using Terraform: |
| 19 | +``` |
| 20 | +resource "aws_kms_key" "parameter_store" { |
| 21 | + description = "Parameter store kms master key" |
| 22 | + deletion_window_in_days = 10 |
| 23 | + enable_key_rotation = true |
| 24 | +} |
| 25 | +
|
| 26 | +resource "aws_kms_alias" "parameter_store_alias" { |
| 27 | + name = "alias/parameter_store_key" |
| 28 | + target_key_id = "${aws_kms_key.parameter_store.id}" |
| 29 | +} |
| 30 | +``` |
| 31 | + |
| 32 | +{{% dialog type="info" icon="fa-info-circle" title="Note" %}} |
| 33 | +Define `CHAMBER_KMS_KEY_ALIAS` environment variable to override the default of `alias/parameter_store_key` |
| 34 | +{{% /dialog %}} |
| 35 | + |
| 36 | + |
| 37 | +Also, we now have a Terraform Module to manage KMS keys: <https://github.com/cloudposse/terraform-aws-kms-key> |
| 38 | + |
| 39 | +``` |
| 40 | +module "kms_key" { |
| 41 | + source = "git::https://github.com/cloudposse/terraform-aws-kms-key.git?ref=master" |
| 42 | + namespace = "cp" |
| 43 | + stage = "prod" |
| 44 | + name = "app" |
| 45 | + description = "KMS key for chamber" |
| 46 | + deletion_window_in_days = 10 |
| 47 | + enable_key_rotation = "true" |
| 48 | +} |
| 49 | +``` |
| 50 | + |
| 51 | +Then tell chamber to use this new key: |
| 52 | + |
| 53 | +``` |
| 54 | +export CHAMBER_KMS_KEY_ALIAS="alias/cp-prod-app" |
| 55 | +``` |
0 commit comments