Skip to content

A resource with the same resourceName but a different internalId already exists #138

@victor-keltio

Description

@victor-keltio

Hey there. First, I would like to thank you for your work. :)

Describe the bug

Using v6.0.0 and Terraform v1.4.4.

Applying the module works successfully, but it ignores the tags defined by the AWS provider.
When applying again, Terraform wants to add them, and then the bug occurs:

$ terraform apply
aws_route53_record.txt_dmarc[0]: Refreshing state... [id=<ID>__dmarc.<domain>_TXT]
data.aws_region.current: Reading...
aws_sesv2_email_identity.main: Refreshing state... [id=<domain>]
data.aws_region.current: Read complete after 0s [id=<region>]
aws_route53_record.dkim[1]: Refreshing state... [id=<id>._domainkey_CNAME]
aws_sesv2_email_identity_mail_from_attributes.main: Refreshing state... [id=<domain>]
aws_route53_record.dkim[0]: Refreshing state... [id=<id>._domainkey_CNAME]
aws_route53_record.dkim[2]: Refreshing state... [id=<id>._domainkey_CNAME]
aws_route53_record.mx_send_mail_from: Refreshing state... [id=<id>_mail.<domain>_MX]
aws_route53_record.spf_mail_from[0]: Refreshing state... [id=<id>_mail.<domain>_TXT]

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # aws_sesv2_email_identity.main will be updated in-place
  ~ resource "aws_sesv2_email_identity" "main" {
        id                          = "<domain>"
        tags                        = {}
      ~ tags_all                    = {
          + "ENVIRONMENT" = "env"
          + "CREATOR"   = "terraform"
        }
        # (4 unchanged attributes hidden)

        # (1 unchanged block hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

aws_sesv2_email_identity.main: Modifying... [id=<domain>]
╷
│ Error: updating Amazon SESv2 (Simple Email V2) Email Identity (<domain>): tagging resource (arn:aws:ses:<region>:<account>:identity/<domain>): operation error SESv2: TagResource, https response error StatusCode: 400, RequestID: <id>, BadRequestException: A resource with the same resourceName but a different internalId already exists: <id>
│
│   with aws_sesv2_email_identity.main,
│   on main.tf line 14, in resource "aws_sesv2_email_identity" "main":
│   14: resource "aws_sesv2_email_identity" "main" {
│

To Reproduce

Steps to reproduce the behavior:

  1. Add default_tags to the AWS provider in the Terraform file
  2. Apply the configuration
  3. The tags are not present
  4. Apply again
  5. Terraform detects the missing tags
  6. Error occurs

Expected behavior
By default, the tags should be present during the first apply, and in a second time, Terraform shouldn't consider that the resource isn't the one it created.

Additional context
I'm using this module with Terragrunt, a Terraform wrapper.

I tried destroying everything and applying again, it works perfectly but the tags are missing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions