Skip to content

Commit 964072d

Browse files
authored
feat: allow optionality of SSM params (#109)
1 parent 1982b40 commit 964072d

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ For automated tests of the complete example using [bats](https://github.com/bats
202202
| <a name="input_security_group_description"></a> [security\_group\_description](#input\_security\_group\_description) | The description to assign to the created Security Group.<br/>Warning: Changing the description causes the security group to be replaced. | `string` | `"Managed by Terraform"` | no |
203203
| <a name="input_security_group_name"></a> [security\_group\_name](#input\_security\_group\_name) | The name to assign to the created security group. Must be unique within the VPC.<br/>If not provided, will be derived from the `null-label.context` passed in.<br/>If `create_before_destroy` is true, will be used as a name prefix. | `list(string)` | `[]` | no |
204204
| <a name="input_ssm_parameter_name_format"></a> [ssm\_parameter\_name\_format](#input\_ssm\_parameter\_name\_format) | SSM parameter name format | `string` | `"/%s/%s"` | no |
205+
| <a name="input_ssm_parameters_enabled"></a> [ssm\_parameters\_enabled](#input\_ssm\_parameters\_enabled) | Whether to create SSM parameters for MQ users and passwords | `bool` | `true` | no |
205206
| <a name="input_ssm_path"></a> [ssm\_path](#input\_ssm\_path) | The first parameter to substitute in `ssm_parameter_name_format` | `string` | `"mq"` | no |
206207
| <a name="input_stage"></a> [stage](#input\_stage) | ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no |
207208
| <a name="input_subnet_ids"></a> [subnet\_ids](#input\_subnet\_ids) | List of VPC subnet IDs | `list(string)` | n/a | yes |

main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ resource "random_password" "mq_application_password" {
4545
}
4646

4747
resource "aws_ssm_parameter" "mq_master_username" {
48-
count = local.mq_admin_user_enabled ? 1 : 0
48+
count = local.mq_admin_user_enabled && var.ssm_parameters_enabled ? 1 : 0
4949
name = format(var.ssm_parameter_name_format, var.ssm_path, var.mq_admin_user_ssm_parameter_name)
5050
value = local.mq_admin_user
5151
description = "MQ Username for the admin user"
@@ -54,7 +54,7 @@ resource "aws_ssm_parameter" "mq_master_username" {
5454
}
5555

5656
resource "aws_ssm_parameter" "mq_master_password" {
57-
count = local.mq_admin_user_enabled ? 1 : 0
57+
count = local.mq_admin_user_enabled && var.ssm_parameters_enabled ? 1 : 0
5858
name = format(var.ssm_parameter_name_format, var.ssm_path, var.mq_admin_password_ssm_parameter_name)
5959
value = local.mq_admin_password
6060
description = "MQ Password for the admin user"
@@ -64,7 +64,7 @@ resource "aws_ssm_parameter" "mq_master_password" {
6464
}
6565

6666
resource "aws_ssm_parameter" "mq_application_username" {
67-
count = local.enabled ? 1 : 0
67+
count = local.enabled && var.ssm_parameters_enabled ? 1 : 0
6868
name = format(var.ssm_parameter_name_format, var.ssm_path, var.mq_application_user_ssm_parameter_name)
6969
value = local.mq_application_user
7070
description = "AMQ username for the application user"
@@ -73,7 +73,7 @@ resource "aws_ssm_parameter" "mq_application_username" {
7373
}
7474

7575
resource "aws_ssm_parameter" "mq_application_password" {
76-
count = local.enabled ? 1 : 0
76+
count = local.enabled && var.ssm_parameters_enabled ? 1 : 0
7777
name = format(var.ssm_parameter_name_format, var.ssm_path, var.mq_application_password_ssm_parameter_name)
7878
value = local.mq_application_password
7979
description = "AMQ password for the application user"

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ variable "subnet_ids" {
106106
description = "List of VPC subnet IDs"
107107
}
108108

109+
variable "ssm_parameters_enabled" {
110+
type = bool
111+
description = "Whether to create SSM parameters for MQ users and passwords"
112+
default = true
113+
}
114+
109115
variable "ssm_parameter_name_format" {
110116
type = string
111117
description = "SSM parameter name format"

0 commit comments

Comments
 (0)