hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.79k stars 9.14k forks source link

[Bug]: `apply` deletes `aws_emr_security_configuration` becasue of `ExternalId` #37526

Open apwrk opened 5 months ago

apwrk commented 5 months ago

Terraform Core Version

1.5.0

AWS Provider Version

5.48.0

Affected Resource(s)

Expected Behavior

With no change in aws_emr_security_configuration resource block apply should not delete and create security configuration.

Actual Behavior

Provider deletes and creates the security configuration in AWS account even though there is no change in the resource block.

Here is what the terraform plan shows

  # module.aws_infra.module.access_layer.module.sagemaker[0].module.servicecatalog_emr.aws_emr_security_configuration.sagemaker must be replaced
+/- resource "aws_emr_security_configuration" "sagemaker" {
      ~ configuration = jsonencode(
          ~ {
              ~ AuthorizationConfiguration = {
                  ~ IAMConfiguration           = {
                      ~ ApplicationScopedIAMRoleConfiguration = {
                          - ExternalId              = "XXXXXXXXXXXXXXXXXXXXXX" -- NOT THE REAL ONE
                            # (1 unchanged attribute hidden)
                        }
                        # (1 unchanged attribute hidden)
                    }
                    # (1 unchanged attribute hidden)
                }
                # (1 unchanged attribute hidden)
            } # forces replacement
        )
      ~ creation_date = "2024-05-15T07:50:43Z" -> (known after apply)
      ~ id            = "sagemaker-emr-security-configuration20240515075043015500000001" -> (known after apply)
      ~ name          = "sagemaker-emr-security-configuration20240515075043015500000001" -> (known after apply)
        # (1 unchanged attribute hidden)
    }

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

resource "aws_emr_security_configuration" "sagemaker" {
  name_prefix = "sagemaker-emr-security-configuration"
  configuration = jsonencode(
    {
      "EncryptionConfiguration" : {
        "EnableAtRestEncryption" : true,
        "AtRestEncryptionConfiguration" : {
          "S3EncryptionConfiguration" : {
            "EncryptionMode" : "SSE-KMS",
            "AwsKmsKey" : var.kms_s3_data_lake_key_arn
          },
          "LocalDiskEncryptionConfiguration" : {
            "EncryptionKeyProviderType" : "AwsKms",
            "AwsKmsKey" : var.kms_s3_data_lake_key_arn
          }
        },
        "EnableInTransitEncryption" : true,
        "InTransitEncryptionConfiguration" : {
          "TLSCertificateConfiguration" : {
            "CertificateProviderType" : "PEM",
            "S3Object" : format("s3://%s/%s", aws_s3_object.emr_transit_encryption_certs.bucket, aws_s3_object.emr_transit_encryption_certs.key)
          }
        }
      }
      "AuthorizationConfiguration" : {
        "IAMConfiguration" : {
          "EnableApplicationScopedIAMRole" : true,
          "ApplicationScopedIAMRoleConfiguration" : {
            "PropagateSourceIdentity" : true,
          }
        },
        "LakeFormationConfiguration" : {
          "AuthorizedSessionTagValue" : "Amazon EMR"
        }
      }
    }
  )
}

Steps to Reproduce

create resource aws_emr_security_configuration by doing terraform apply and then do a terraform plan.

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 5 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue