Skip to content

aws_guardduty_member says it needs to be recreated if done via organization #13906

@cblkwell

Description

@cblkwell

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

0.12.26

Affected Resource(s)

  • aws_guardduty_member

Terraform Configuration Files

# In an organization infrastructure account, which we designated as the GuardDuty admin account:
resource "aws_guardduty_detector" "main" {
  enable = true
}

resource "aws_guardduty_organization_configuration" "main" {
  auto_enable = true
  detector_id = aws_guardduty_detector.main.id
}

resource "aws_guardduty_member" "trussworks_sandbox" {
   account_id                 = local.trussworks_sandbox_id
   detector_id                = aws_guardduty_detector.main.id
   email                      = local.trussworks_sandbox_email
   invite                     = false
   disable_email_notification = true
}

In this case, trussworks_sandbox is an account we created before we enabled GuardDuty, so it was not automatically added a member automatically via the auto_enable in aws_guardduty_organization_configuration.

No GuardDuty resources are configured in the trussworks_sandbox account because GuardDuty appears to create the detector automatically when it is added as a member.

Expected Behavior

Running Terraform with this code should create the member, and then subsequent runs should say no changes are necessary because the membership is already created.

Actual Behavior

Running Terraform once with this code successfully created the membership, as expected. However, on subsequent terraform apply executions, it attempts to recreate the resource:

  # aws_guardduty_member.trussworks_sandbox must be replaced
-/+ resource "aws_guardduty_member" "trussworks_sandbox" {
        account_id                 = "REDACTED"
        detector_id                = "REDACTED"
        disable_email_notification = true
      + email                      = "[email protected]" # forces replacement
      ~ id                         = "REDACTED" -> (known after apply)
      ~ invite                     = true -> false
      ~ relationship_status        = "Enabled" -> (known after apply)
    }

Steps to Reproduce

  1. Create an AWS organization with three accounts -- a "master" account, the GuardDuty admin account, and another account.
  2. Make the GuardDuty admin account the GuardDuty admin account (...obviously), and configure as above.
  3. Add the third account as a GuardDuty member with the code above.
  4. Run terraform apply, and then run terraform apply again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    service/guarddutyIssues and PRs that pertain to the guardduty service.upstreamAddresses functionality related to the cloud provider.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions