Skip to content

Commit 42216df

Browse files
authored
Update ssm-parameter-store modules (#45)
1 parent 2ef60fb commit 42216df

File tree

11 files changed

+61
-115
lines changed

11 files changed

+61
-115
lines changed

modules/ssm-parameter-store-parameter-set/README.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,32 @@ This module creates following resources.
99

1010
| Name | Version |
1111
|------|---------|
12-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5 |
13-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.22 |
12+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.6 |
13+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.43 |
1414

1515
## Providers
1616

17-
| Name | Version |
18-
|------|---------|
19-
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.19.0 |
17+
No providers.
2018

2119
## Modules
2220

2321
| Name | Source | Version |
2422
|------|--------|---------|
2523
| <a name="module_resource_group"></a> [resource\_group](#module\_resource\_group) | tedilabs/misc/aws//modules/resource-group | ~> 0.10.0 |
24+
| <a name="module_this"></a> [this](#module\_this) | ../ssm-parameter-store-parameter | n/a |
2625

2726
## Resources
2827

29-
| Name | Type |
30-
|------|------|
31-
| [aws_ssm_parameter.self](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssm_parameter) | resource |
32-
| [aws_ssm_parameter.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssm_parameter) | resource |
28+
No resources.
3329

3430
## Inputs
3531

3632
| Name | Description | Type | Default | Required |
3733
|------|-------------|------|---------|:--------:|
38-
| <a name="input_parameters"></a> [parameters](#input\_parameters) | (Required) A list of parameters to manage in the parameter set. Each value of `parameters` block as defined below.<br> (Required) `name` - The name of the parameter. This is concatenated with the `path` of the parameter set for the id. The name should begin with slash (/) and end without trailing slash.<br> (Optional) `description` - The description of the parameter.<br> (Optional) `tier` - The parameter tier to assign to the parameter. Valid values are `STANDARD`, `ADVANCED` or `INTELLIGENT_TIERING`.<br> (Optional) `type` - The intended type of the parameter. Valid values are `STRING`, `STRING_LIST`. Not support `SECURE_STRING`.<br> (Optional) `data_type` - The data type of the parameter. Only required when `type` is `STRING`. Valid values are `text`, `aws:ec2:image` for AMI format.<br> (Optional) `allowed_pattern` - A regular expression used to validate the parameter value.<br> (Required) `value` - The value of the parameter. | `list(map(string))` | n/a | yes |
34+
| <a name="input_parameters"></a> [parameters](#input\_parameters) | (Required) A list of parameters to manage in the parameter set. Each value of `parameters` block as defined below.<br> (Required) `name` - The name of the parameter. This is concatenated with the `path` of the parameter set for the id. The name should begin with slash (/) and end without trailing slash.<br> (Optional) `description` - The description of the parameter.<br> (Optional) `tier` - The parameter tier to assign to the parameter. Valid values are `STANDARD`, `ADVANCED` or `INTELLIGENT_TIERING`.<br> (Optional) `type` - The intended type of the parameter. Valid values are `STRING`, `STRING_LIST`. Not support `SECURE_STRING`.<br> (Optional) `data_type` - The data type of the parameter. Only required when `type` is `STRING`. Valid values are `text`, `aws:ssm:integration`, `aws:ec2:image` for AMI format.<br> (Optional) `allowed_pattern` - A regular expression used to validate the parameter value.<br> (Required) `value` - The value of the parameter. | <pre>list(object({<br> name = string<br> description = optional(string)<br> tier = optional(string)<br> type = optional(string)<br> data_type = optional(string)<br> allowed_pattern = optional(string)<br> value = string<br> }))</pre> | n/a | yes |
3935
| <a name="input_path"></a> [path](#input\_path) | (Required) A path used for the prefix of each parameter name created by this parameter set. The path should begin with slash (/) and end without trailing slash. | `string` | n/a | yes |
4036
| <a name="input_allowed_pattern"></a> [allowed\_pattern](#input\_allowed\_pattern) | (Optional) The default regular expression used to validate each parameter value in the parameter set. This is only used when a specific pattern for the parameter is not provided. For example, for `STRING` types with values restricted to numbers, you can specify `^d+$`. | `string` | `""` | no |
41-
| <a name="input_data_type"></a> [data\_type](#input\_data\_type) | (Optional) The default data type of parameters in the parameter set. Only required when `type` is `STRING`. This is only used when a specific data type of the parameter is not provided. Valid values are `text`, `aws:ec2:image` for AMI format. Defaults to `text`. | `string` | `"text"` | no |
37+
| <a name="input_data_type"></a> [data\_type](#input\_data\_type) | (Optional) The default data type of parameters in the parameter set. Only required when `type` is `STRING`. This is only used when a specific data type of the parameter is not provided. Valid values are `text`, `aws:ssm:integration`, `aws:ec2:image` for AMI format. Defaults to `text`. `aws:ssm:integration` data\_type parameters must be of the type `SECURE_STRING` and the name must start with the prefix `/d9d01087-4a3f-49e0-b0b4-d568d7826553/ssm/integrations/webhook/`. | `string` | `"text"` | no |
4238
| <a name="input_description"></a> [description](#input\_description) | (Optional) The default description of parameters in the parameter set. This is only used when a specific description of the parameter is not provided. | `string` | `"Managed by Terraform."` | no |
4339
| <a name="input_ignore_value_changes"></a> [ignore\_value\_changes](#input\_ignore\_value\_changes) | (Optional) Whether to manage the parameter value with Terraform. Ignore changes of `value` or `secret_value` if true. Defaults to `false`. | `bool` | `false` | no |
4440
| <a name="input_module_tags_enabled"></a> [module\_tags\_enabled](#input\_module\_tags\_enabled) | (Optional) Whether to create AWS Resource Tags for the module informations. | `bool` | `true` | no |

modules/ssm-parameter-store-parameter-set/main.tf

Lines changed: 11 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -14,72 +14,32 @@ locals {
1414
} : {}
1515
}
1616

17-
locals {
18-
types = {
19-
"STRING" = "String"
20-
"STRING_LIST" = "StringList"
21-
"SECURE_STRING" = "SecureString"
22-
}
23-
tiers = {
24-
"STANDARD" = "Standard"
25-
"ADVANCED" = "Advanced"
26-
"INTELLIGENT_TIERING" = "Intelligent-Tiering"
27-
}
28-
}
29-
3017

3118
###################################################
3219
# Parameter on Systems Manager Parameter Store
3320
###################################################
3421

35-
resource "aws_ssm_parameter" "this" {
22+
module "this" {
3623
for_each = {
3724
for parameter in var.parameters :
3825
parameter.name => parameter
39-
if !var.ignore_value_changes
4026
}
4127

42-
name = join("", [var.path, each.key])
43-
description = try(each.value.description, var.description)
44-
tier = local.tiers[try(each.value.tier, var.tier)]
45-
46-
type = local.types[try(each.value.type, var.type)]
47-
data_type = try(each.value.data_type, var.data_type)
48-
allowed_pattern = try(each.value.allowed_pattern, var.allowed_pattern)
49-
50-
insecure_value = each.value.value
51-
52-
# BUG: https://github.com/hashicorp/terraform-provider-aws/issues/25335
53-
overwrite = true
54-
55-
tags = merge(
56-
{
57-
"Name" = join("", [var.path, each.key])
58-
},
59-
local.module_tags,
60-
var.tags,
61-
)
62-
}
63-
64-
resource "aws_ssm_parameter" "self" {
65-
for_each = {
66-
for parameter in var.parameters :
67-
parameter.name => parameter
68-
if var.ignore_value_changes
69-
}
28+
source = "../ssm-parameter-store-parameter"
7029

7130
name = join("", [var.path, each.key])
72-
description = try(each.value.description, var.description)
73-
tier = local.tiers[try(each.value.tier, var.tier)]
31+
description = coalesce(each.value.description, var.description)
32+
tier = coalesce(each.value.tier, var.tier)
7433

75-
type = local.types[try(each.value.type, var.type)]
76-
data_type = try(each.value.data_type, var.data_type)
77-
allowed_pattern = try(each.value.allowed_pattern, var.allowed_pattern)
34+
type = coalesce(each.value.type, var.type)
35+
data_type = coalesce(each.value.data_type, var.data_type)
36+
allowed_pattern = coalesce(each.value.allowed_pattern, var.allowed_pattern)
7837

79-
insecure_value = each.value.value
38+
ignore_value_changes = var.ignore_value_changes
39+
value = each.value.value
8040

81-
# BUG: https://github.com/hashicorp/terraform-provider-aws/issues/25335
82-
overwrite = true
41+
resource_group_enabled = false
42+
module_tags_enabled = false
8343

8444
tags = merge(
8545
{
@@ -88,11 +48,4 @@ resource "aws_ssm_parameter" "self" {
8848
local.module_tags,
8949
var.tags,
9050
)
91-
92-
lifecycle {
93-
ignore_changes = [
94-
value,
95-
insecure_value,
96-
]
97-
}
9851
}

modules/ssm-parameter-store-parameter-set/outputs.tf

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
locals {
2-
parameter_set = var.ignore_value_changes ? aws_ssm_parameter.self : aws_ssm_parameter.this
3-
}
4-
51
output "path" {
62
description = "The path used for the prefix of each parameter names managed by this parameter set."
73
value = var.path
@@ -10,7 +6,7 @@ output "path" {
106
output "parameters" {
117
description = "The list of parameters in the parameter set."
128
value = {
13-
for name, parameter in local.parameter_set :
9+
for name, parameter in module.this :
1410
name => {
1511
id = parameter.id
1612
arn = parameter.arn

modules/ssm-parameter-store-parameter-set/variables.tf

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
variable "path" {
22
description = "(Required) A path used for the prefix of each parameter name created by this parameter set. The path should begin with slash (/) and end without trailing slash."
33
type = string
4+
nullable = false
45

56
validation {
67
condition = alltrue([
@@ -43,14 +44,14 @@ variable "type" {
4344
}
4445

4546
variable "data_type" {
46-
description = "(Optional) The default data type of parameters in the parameter set. Only required when `type` is `STRING`. This is only used when a specific data type of the parameter is not provided. Valid values are `text`, `aws:ec2:image` for AMI format. Defaults to `text`."
47+
description = "(Optional) The default data type of parameters in the parameter set. Only required when `type` is `STRING`. This is only used when a specific data type of the parameter is not provided. Valid values are `text`, `aws:ssm:integration`, `aws:ec2:image` for AMI format. Defaults to `text`. `aws:ssm:integration` data_type parameters must be of the type `SECURE_STRING` and the name must start with the prefix `/d9d01087-4a3f-49e0-b0b4-d568d7826553/ssm/integrations/webhook/`."
4748
type = string
4849
default = "text"
4950
nullable = false
5051

5152
validation {
52-
condition = contains(["text", "aws:ec2:image"], var.data_type)
53-
error_message = "Valid values are `text`, `aws:ec2:image`."
53+
condition = contains(["text", "aws:ssm:integration", "aws:ec2:image"], var.data_type)
54+
error_message = "Valid values are `text`, `aws:ssm:integration`, `aws:ec2:image`."
5455
}
5556
}
5657

@@ -68,12 +69,20 @@ variable "parameters" {
6869
(Optional) `description` - The description of the parameter.
6970
(Optional) `tier` - The parameter tier to assign to the parameter. Valid values are `STANDARD`, `ADVANCED` or `INTELLIGENT_TIERING`.
7071
(Optional) `type` - The intended type of the parameter. Valid values are `STRING`, `STRING_LIST`. Not support `SECURE_STRING`.
71-
(Optional) `data_type` - The data type of the parameter. Only required when `type` is `STRING`. Valid values are `text`, `aws:ec2:image` for AMI format.
72+
(Optional) `data_type` - The data type of the parameter. Only required when `type` is `STRING`. Valid values are `text`, `aws:ssm:integration`, `aws:ec2:image` for AMI format.
7273
(Optional) `allowed_pattern` - A regular expression used to validate the parameter value.
7374
(Required) `value` - The value of the parameter.
7475
EOF
75-
type = list(map(string))
76-
nullable = false
76+
type = list(object({
77+
name = string
78+
description = optional(string)
79+
tier = optional(string)
80+
type = optional(string)
81+
data_type = optional(string)
82+
allowed_pattern = optional(string)
83+
value = string
84+
}))
85+
nullable = false
7786

7887
validation {
7988
condition = alltrue([
@@ -90,7 +99,7 @@ variable "parameters" {
9099
condition = alltrue([
91100
for parameter in var.parameters :
92101
contains(["STANDARD", "ADVANCED", "INTELLIGENT_TIERING"], parameter.tier)
93-
if try(parameter.tier, null) != null
102+
if parameter.tier != null
94103
])
95104
error_message = "Valid values are `STANDARD`, `ADVANCED` or `INTELLIGENT_TIERING`."
96105
}
@@ -99,26 +108,18 @@ variable "parameters" {
99108
condition = alltrue([
100109
for parameter in var.parameters :
101110
contains(["STRING", "STRING_LIST"], parameter.type)
102-
if try(parameter.type, null) != null
111+
if parameter.type != null
103112
])
104113
error_message = "Valid values are `STRING`, `STRING_LIST`. Not support `SECURE_STRING`."
105114
}
106115

107116
validation {
108117
condition = alltrue([
109118
for parameter in var.parameters :
110-
contains(["text", "aws:ec2:image"], parameter.data_type)
111-
if try(parameter.data_type, null) != null
112-
])
113-
error_message = "Valid values are `text`, `aws:ec2:image`."
114-
}
115-
116-
validation {
117-
condition = alltrue([
118-
for parameter in var.parameters :
119-
can(parameter.value)
119+
contains(["text", "aws:ssm:integration", "aws:ec2:image"], parameter.data_type)
120+
if parameter.data_type != null
120121
])
121-
error_message = "The value for `value` is required."
122+
error_message = "Valid values are `text`, `aws:ssm:integration`, `aws:ec2:image`."
122123
}
123124
}
124125

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
terraform {
2-
required_version = ">= 1.5"
2+
required_version = ">= 1.6"
33

44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = ">= 4.22"
7+
version = ">= 5.43"
88
}
99
}
1010
}

modules/ssm-parameter-store-parameter/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ This module creates following resources.
99

1010
| Name | Version |
1111
|------|---------|
12-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5 |
13-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.22 |
12+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.6 |
13+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.43 |
1414

1515
## Providers
1616

1717
| Name | Version |
1818
|------|---------|
19-
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.19.0 |
19+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.50.0 |
2020

2121
## Modules
2222

@@ -37,7 +37,7 @@ This module creates following resources.
3737
|------|-------------|------|---------|:--------:|
3838
| <a name="input_name"></a> [name](#input\_name) | (Required) Friendly name of the new parameter. If the name contains a path (e.g., any forward slashes (/)), it must be fully qualified with a leading forward slash (/). | `string` | n/a | yes |
3939
| <a name="input_allowed_pattern"></a> [allowed\_pattern](#input\_allowed\_pattern) | (Optional) A regular expression used to validate the parameter value. For example, for `STRING` types with values restricted to numbers, you can specify `^d+$`. | `string` | `""` | no |
40-
| <a name="input_data_type"></a> [data\_type](#input\_data\_type) | (Optional) The data type of the parameter. Only required when `type` is `STRING`. Valid values are `text`, `aws:ec2:image` for AMI format. Defaults to `text`. | `string` | `"text"` | no |
40+
| <a name="input_data_type"></a> [data\_type](#input\_data\_type) | (Optional) The data type of the parameter. Only required when `type` is `STRING`. Valid values are `text`, `aws:ssm:integration`, `aws:ec2:image` for AMI format. Defaults to `text`. `aws:ssm:integration` data\_type parameters must be of the type `SECURE_STRING` and the name must start with the prefix `/d9d01087-4a3f-49e0-b0b4-d568d7826553/ssm/integrations/webhook/`. | `string` | `"text"` | no |
4141
| <a name="input_description"></a> [description](#input\_description) | (Optional) The description of the parameter. | `string` | `"Managed by Terraform."` | no |
4242
| <a name="input_ignore_value_changes"></a> [ignore\_value\_changes](#input\_ignore\_value\_changes) | (Optional) Whether to manage the parameter value with Terraform. Ignore changes of `value` or `secret_value` if true. Defaults to `false`. | `bool` | `false` | no |
4343
| <a name="input_kms_key"></a> [kms\_key](#input\_kms\_key) | (Optional) The ARN or ID of the AWS KMS key to be used to encrypt the parameter value with `SECURE_STRING` type. If you don't specify this value, then Parameter Store defaults to using the AWS account's default KMS key named `aws/ssm`. If the default KMS key with that name doesn't yet exist, then AWS Parameter Store creates it for you automatically the first time. | `string` | `null` | no |

modules/ssm-parameter-store-parameter/main.tf

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ locals {
3232
# Parameter on Systems Manager Parameter Store
3333
###################################################
3434

35+
# INFO: Deprecated attributes
36+
# - `overwrite`
3537
resource "aws_ssm_parameter" "this" {
3638
count = var.ignore_value_changes ? 0 : 1
3739

@@ -46,9 +48,6 @@ resource "aws_ssm_parameter" "this" {
4648
insecure_value = var.type == "SECURE_STRING" ? null : var.value
4749
value = var.type == "SECURE_STRING" ? var.secret_value : null
4850

49-
# BUG: https://github.com/hashicorp/terraform-provider-aws/issues/25335
50-
overwrite = true
51-
5251

5352
## Encryption
5453
key_id = var.type == "SECURE_STRING" ? var.kms_key : null
@@ -62,6 +61,8 @@ resource "aws_ssm_parameter" "this" {
6261
)
6362
}
6463

64+
# INFO: Deprecated attributes
65+
# - `overwrite`
6566
resource "aws_ssm_parameter" "self" {
6667
count = var.ignore_value_changes ? 1 : 0
6768

@@ -76,9 +77,6 @@ resource "aws_ssm_parameter" "self" {
7677
insecure_value = var.type == "SECURE_STRING" ? null : var.value
7778
value = var.type == "SECURE_STRING" ? var.secret_value : null
7879

79-
# BUG: https://github.com/hashicorp/terraform-provider-aws/issues/25335
80-
overwrite = true
81-
8280

8381
## Encryption
8482
key_id = var.type == "SECURE_STRING" ? var.kms_key : null

modules/ssm-parameter-store-parameter/variables.tf

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
variable "name" {
22
description = "(Required) Friendly name of the new parameter. If the name contains a path (e.g., any forward slashes (/)), it must be fully qualified with a leading forward slash (/)."
33
type = string
4+
nullable = false
45
}
56

67
variable "description" {
@@ -14,6 +15,7 @@ variable "tier" {
1415
description = "(Optional) The parameter tier to assign to the parameter. If not specified, will use the default parameter tier for the region. Valid values are `STANDARD`, `ADVANCED` or `INTELLIGENT_TIERING`."
1516
type = string
1617
default = null
18+
nullable = true
1719

1820
validation {
1921
condition = (var.tier != null
@@ -37,14 +39,14 @@ variable "type" {
3739
}
3840

3941
variable "data_type" {
40-
description = "(Optional) The data type of the parameter. Only required when `type` is `STRING`. Valid values are `text`, `aws:ec2:image` for AMI format. Defaults to `text`."
42+
description = "(Optional) The data type of the parameter. Only required when `type` is `STRING`. Valid values are `text`, `aws:ssm:integration`, `aws:ec2:image` for AMI format. Defaults to `text`. `aws:ssm:integration` data_type parameters must be of the type `SECURE_STRING` and the name must start with the prefix `/d9d01087-4a3f-49e0-b0b4-d568d7826553/ssm/integrations/webhook/`."
4143
type = string
4244
default = "text"
4345
nullable = false
4446

4547
validation {
46-
condition = contains(["text", "aws:ec2:image"], var.data_type)
47-
error_message = "Valid values are `text`, `aws:ec2:image`."
48+
condition = contains(["text", "aws:ssm:integration", "aws:ec2:image"], var.data_type)
49+
error_message = "Valid values are `text`, `aws:ssm:integration`, `aws:ec2:image`."
4850
}
4951
}
5052

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
terraform {
2-
required_version = ">= 1.5"
2+
required_version = ">= 1.6"
33

44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = ">= 4.22"
7+
version = ">= 5.43"
88
}
99
}
1010
}

0 commit comments

Comments
 (0)