From 950b894dac010ba5d0b23ed8512881b73168b5ca Mon Sep 17 00:00:00 2001 From: Timur Saikaliev Date: Wed, 22 Mar 2023 17:53:03 +0300 Subject: [PATCH 1/2] remove unnecessary resource, add resource dependencies, remove unused variable --- examples/simple/main.tf | 1 - examples/simple/variables.tf | 5 ----- main.tf | 16 ++++++---------- variables.tf | 6 ------ 4 files changed, 6 insertions(+), 22 deletions(-) diff --git a/examples/simple/main.tf b/examples/simple/main.tf index c36b072..d94970c 100644 --- a/examples/simple/main.tf +++ b/examples/simple/main.tf @@ -154,7 +154,6 @@ module "ses_domain" { receive_s3_prefix = local.ses_bucket_prefix enable_verification = var.enable_verification enable_spf_record = var.enable_spf_record - extra_ses_records = var.extra_ses_records ses_rule_set = var.rule_set } diff --git a/examples/simple/variables.tf b/examples/simple/variables.tf index 6d3ff81..1937cfa 100644 --- a/examples/simple/variables.tf +++ b/examples/simple/variables.tf @@ -14,11 +14,6 @@ variable "enable_spf_record" { type = bool } -variable "extra_ses_records" { - type = list(string) - default = [] -} - variable "rule_set" { description = "Name of the SES rule set to associate rules with." type = string diff --git a/main.tf b/main.tf index 09cdc29..13dbeb4 100644 --- a/main.tf +++ b/main.tf @@ -19,22 +19,16 @@ resource "aws_sesv2_email_identity" "main" { # SES DKIM Verification # -resource "aws_ses_domain_dkim" "main" { - domain = aws_sesv2_email_identity.main.email_identity -} - resource "aws_route53_record" "dkim" { count = 3 zone_id = var.route53_zone_id - name = format( - "%s._domainkey.%s", - element(aws_ses_domain_dkim.main.dkim_tokens, count.index), - var.domain_name, - ) + name = "${aws_sesv2_email_identity.main.dkim_signing_attributes[0].tokens[count.index]}._domainkey" type = "CNAME" ttl = "600" - records = ["${element(aws_ses_domain_dkim.main.dkim_tokens, count.index)}.dkim.amazonses.com"] + records = ["${aws_sesv2_email_identity.main.dkim_signing_attributes[0].tokens[count.index]}.dkim.amazonses.com"] + + depends_on = [aws_sesv2_email_identity.main] } # @@ -44,6 +38,8 @@ resource "aws_route53_record" "dkim" { resource "aws_sesv2_email_identity_mail_from_attributes" "main" { email_identity = aws_sesv2_email_identity.main.email_identity mail_from_domain = local.stripped_mail_from_domain + + depends_on = [aws_sesv2_email_identity.main] } # SPF validation record diff --git a/variables.tf b/variables.tf index 1f251ec..d6c3149 100644 --- a/variables.tf +++ b/variables.tf @@ -70,9 +70,3 @@ variable "enable_spf_record" { type = bool default = true } - -variable "extra_ses_records" { - description = "Extra records to add to the _amazonses TXT record." - type = list(string) - default = [] -} From 882d9ad657d86d75c0887a0872a76375b399753f Mon Sep 17 00:00:00 2001 From: Timur Saikaliev Date: Wed, 22 Mar 2023 18:02:36 +0300 Subject: [PATCH 2/2] pre-commit --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 9bfffec..17c2a70 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,6 @@ No modules. | [aws_route53_record.mx_send_mail_from](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_record) | resource | | [aws_route53_record.spf_mail_from](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_record) | resource | | [aws_route53_record.txt_dmarc](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_record) | resource | -| [aws_ses_domain_dkim.main](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ses_domain_dkim) | resource | | [aws_ses_receipt_rule.main](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ses_receipt_rule) | resource | | [aws_sesv2_email_identity.main](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sesv2_email_identity) | resource | | [aws_sesv2_email_identity_mail_from_attributes.main](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sesv2_email_identity_mail_from_attributes) | resource | @@ -102,7 +101,6 @@ No modules. | enable\_dmarc | Control whether to create DMARC TXT record. | `bool` | `true` | no | | enable\_incoming\_email | Control whether or not to handle incoming emails. | `bool` | `true` | no | | enable\_spf\_record | Control whether or not to set SPF records. | `bool` | `true` | no | -| extra\_ses\_records | Extra records to add to the \_amazonses TXT record. | `list(string)` | `[]` | no | | from\_addresses | List of email addresses to catch bounces and rejections. | `list(string)` | `null` | no | | mail\_from\_domain | Subdomain (of the route53 zone) which is to be used as MAIL FROM address | `string` | n/a | yes | | receive\_s3\_bucket | Name of the S3 bucket to store received emails (required if enable\_incoming\_email is true). | `string` | `""` | no |