|
| 1 | + |
| 2 | +## Variables |
| 3 | + |
| 4 | +| Name | Description | Required | |
| 5 | +|---------------------|-----------------------------------------------------------------------------------------------------------------------------------------|-----------| |
| 6 | +| parameter_root_name | The prefix or root parameter that you want to allow access to | No | |
| 7 | +| kms_key | The arn of the KMS key that you want to allow access to. If empty it uses a wildcard resource. `*` | No | |
| 8 | +| region | The region of the parameter store value that you want to allow access to. If none supplied, it uses the current region of the provider. | No | |
| 9 | +| account_id | The account id of the parameter store you want to allow access to. If none supplied, it uses the current account id of the provider. | No | |
| 10 | + |
| 11 | +## Outputs |
| 12 | + |
| 13 | +| Name | Description | |
| 14 | +|---------------------------------|---------------------------------------------------------------------------------------------------| |
| 15 | +| read_parameter_store_policy | A JSON policy document that only allows read access to the parameter store | |
| 16 | +| write_parameter_store_policy | A JSON policy document that only allows write access to the parameter store | |
| 17 | +| manage_kms_store_policy | A JSON policy document that allows decryption access to a KMS key | |
| 18 | +| manage_parameter_store_policy | A JSON policy document that allows full access to the parameter store | |
| 19 | +| put_xray_trace_policy | A JSON policy document that allows putting data into x-ray for tracing parameter store requests | |
| 20 | + |
| 21 | +## Examples |
| 22 | + |
| 23 | +### Create a policy that allows access to read all parameters |
| 24 | + |
| 25 | +```hcl |
| 26 | +module "ps_policy" { |
| 27 | + source = "git::https://github.com/cloudposse/terraform-aws-parameter-store-policy.git?ref=master" |
| 28 | +} |
| 29 | +
|
| 30 | +resource "aws_iam_policy" "ps_read" { |
| 31 | + name_prefix = "read_any_parameter_store_value" |
| 32 | + path = "/" |
| 33 | + policy = "${module.ps_policy.read_parameter_store_policy}" |
| 34 | +} |
| 35 | +``` |
| 36 | + |
| 37 | +### Create a policy that allows access to write all parameters |
| 38 | + |
| 39 | +```hcl |
| 40 | +module "ps_policy" { |
| 41 | + source = "git::https://github.com/cloudposse/terraform-aws-parameter-store-policy.git?ref=master" |
| 42 | +} |
| 43 | +
|
| 44 | +resource "aws_iam_policy" "ps_write" { |
| 45 | + name_prefix = "write_any_parameter_store_value" |
| 46 | + path = "/" |
| 47 | + policy = "${module.ps_policy.write_parameter_store_policy}" |
| 48 | +} |
| 49 | +``` |
| 50 | + |
| 51 | +### Create a policy that allows managing all policies |
| 52 | +```hcl |
| 53 | +module "ps_policy" { |
| 54 | + source = "git::https://github.com/cloudposse/terraform-aws-parameter-store-policy.git?ref=master" |
| 55 | +} |
| 56 | +
|
| 57 | +resource "aws_iam_policy" "ps_manage" { |
| 58 | + name_prefix = "manage_any_parameter_store_value" |
| 59 | + path = "/" |
| 60 | + policy = "${module.ps_policy.manage_parameter_store_policy}" |
| 61 | +} |
| 62 | +``` |
| 63 | + |
| 64 | +### Create a policy that allows reading all parameters that start with a certain prefix |
| 65 | +```hcl |
| 66 | +module "ps_policy" { |
| 67 | + source = "git::https://github.com/cloudposse/terraform-aws-parameter-store-policy.git?ref=master" |
| 68 | + parameter_root_name = "/cp/dev/app" |
| 69 | +
|
| 70 | +} |
| 71 | +
|
| 72 | +resource "aws_iam_policy" "ps_manage" { |
| 73 | + name_prefix = "write_specific_parameter_store_value" |
| 74 | + path = "/" |
| 75 | + policy = "${module.ps_policy.manage_parameter_store_policy}" |
| 76 | +} |
| 77 | +``` |
| 78 | + |
| 79 | +### Create a kms policy to allow decrypting of the parameter store values |
| 80 | +```hcl |
| 81 | +module "kms_key" { |
| 82 | + source = "git::https://github.com/cloudposse/terraform-aws-kms-key.git?ref=master" |
| 83 | + namespace = "cp" |
| 84 | + stage = "prod" |
| 85 | + name = "app" |
| 86 | + description = "KMS key" |
| 87 | + deletion_window_in_days = 10 |
| 88 | + enable_key_rotation = "true" |
| 89 | + alias = "alias/parameter_store_key" |
| 90 | +} |
| 91 | +
|
| 92 | +module "ps_policy" { |
| 93 | + source = "git::https://github.com/cloudposse/terraform-aws-parameter-store-policy.git?ref=master" |
| 94 | + parameter_root_name = "/cp/dev/app" |
| 95 | + kms_key = "${module.kms_key.key_arn}" |
| 96 | +
|
| 97 | +} |
| 98 | +
|
| 99 | +resource "aws_iam_policy" "ps_kms" { |
| 100 | + name_prefix = "decrypt_parameter_store_value" |
| 101 | + path = "/" |
| 102 | + policy = "${module.ps_policy.manage_kms_store_policy}" |
| 103 | +} |
| 104 | +``` |
| 105 | + |
| 106 | +### Create a policy for another account, or region |
| 107 | +```hcl |
| 108 | +module "ps_policy" { |
| 109 | + source = "git::https://github.com/cloudposse/terraform-aws-parameter-store-policy.git?ref=master" |
| 110 | + parameter_root_name = "/cp/dev/app" |
| 111 | + account_id = "783649272629220" |
| 112 | + region = "ap-southeast-2" |
| 113 | +
|
| 114 | +} |
| 115 | +
|
| 116 | +resource "aws_iam_policy" "ps_manage" { |
| 117 | + name_prefix = "manage_any_parameter_store_value" |
| 118 | + path = "/" |
| 119 | + policy = "${module.ps_policy.manage_parameter_store_policy}" |
| 120 | +} |
| 121 | +``` |
0 commit comments