diff --git a/README.md b/README.md index 61f7771..d7f06a4 100644 --- a/README.md +++ b/README.md @@ -176,7 +176,7 @@ Available targets: | [namespace](#input\_namespace) | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | `string` | `null` | no | | [regex\_replace\_chars](#input\_regex\_replace\_chars) | Regex to replace chars with empty string in `namespace`, `environment`, `stage` and `name`.
If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no | | [ses\_group\_enabled](#input\_ses\_group\_enabled) | Creates a group with permission to send emails from SES domain | `bool` | `true` | no | -| [ses\_group\_name](#input\_ses\_group\_name) | The name of the group to create | `string` | `"SESSenders"` | no | +| [ses\_group\_name](#input\_ses\_group\_name) | The name of the IAM group to create. If empty the module will calculate name from a context (recommended). | `string` | `""` | no | | [ses\_group\_path](#input\_ses\_group\_path) | The IAM Path of the group to create | `string` | `"/"` | no | | [ses\_user\_enabled](#input\_ses\_user\_enabled) | Creates user with permission to send emails from SES domain | `bool` | `true` | no | | [stage](#input\_stage) | Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no | diff --git a/docs/terraform.md b/docs/terraform.md index 968694f..abe5cd7 100644 --- a/docs/terraform.md +++ b/docs/terraform.md @@ -53,7 +53,7 @@ | [namespace](#input\_namespace) | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | `string` | `null` | no | | [regex\_replace\_chars](#input\_regex\_replace\_chars) | Regex to replace chars with empty string in `namespace`, `environment`, `stage` and `name`.
If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no | | [ses\_group\_enabled](#input\_ses\_group\_enabled) | Creates a group with permission to send emails from SES domain | `bool` | `true` | no | -| [ses\_group\_name](#input\_ses\_group\_name) | The name of the group to create | `string` | `"SESSenders"` | no | +| [ses\_group\_name](#input\_ses\_group\_name) | The name of the IAM group to create. If empty the module will calculate name from a context (recommended). | `string` | `""` | no | | [ses\_group\_path](#input\_ses\_group\_path) | The IAM Path of the group to create | `string` | `"/"` | no | | [ses\_user\_enabled](#input\_ses\_user\_enabled) | Creates user with permission to send emails from SES domain | `bool` | `true` | no | | [stage](#input\_stage) | Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no | diff --git a/main.tf b/main.tf index 0948b42..c34649b 100644 --- a/main.tf +++ b/main.tf @@ -41,6 +41,8 @@ resource "aws_route53_record" "amazonses_dkim_record" { locals { create_group_enabled = module.this.enabled && var.ses_group_enabled create_user_enabled = module.this.enabled && var.ses_user_enabled + + ses_group_name = coalesce(var.ses_group_name, module.this.id) } data "aws_iam_policy_document" "ses_policy" { @@ -55,7 +57,7 @@ data "aws_iam_policy_document" "ses_policy" { resource "aws_iam_group" "ses_users" { count = local.create_group_enabled ? 1 : 0 - name = var.ses_group_name + name = local.ses_group_name path = var.ses_group_path } diff --git a/variables.tf b/variables.tf index c52cbc7..8df31c1 100644 --- a/variables.tf +++ b/variables.tf @@ -35,8 +35,8 @@ variable "ses_group_enabled" { variable "ses_group_name" { type = string - description = "The name of the group to create" - default = "SESSenders" + description = "The name of the IAM group to create. If empty the module will calculate name from a context (recommended)." + default = "" } variable "ses_group_path" {