Hello,
I am using Terraform to provision and manage resources for AWS Cloud and Datadog integration for my environment. I use the same Terraform configuration for 3 different AWS regions, and the Terraform plan and apply is executed via a pipeline.
Recently, I tried creating a “datadog_logs_archive” resource documented at Terraform Registry to create and manage Datadog logs archives. My requirement is to create this resource only in the us-east-1 region of AWS. So, I have defined this resource and the related s3 bucket resource using the “count” attribute (count = local.region == "us-east-1" ? 1 : 0
) to ensure that this resource is only created for us-east-1. the resource definition is as follows:
resource "datadog_logs_archive" "some_logs_archive" {
count = local.region == "us-east-1" ? 1 : 0
depends_on = [aws_s3_bucket.some_log_archival]
name = "Application Datadog S3 log archives"
query = ""
s3_archive {
bucket = aws_s3_bucket.some_log_archival[0].id
account_id = "<my_aws_account_id>"
role_name = aws_iam_role.datadog_integration_role.name
}
}
I started coming across the error:
Error: object contains unparsed element: map[bucket:some-log-archival-pro-us-east-1 integration:map[] path:/some_path type:s3]
during the “terraform plan” command execution. This error points to resource “datadog_logs_archive” definition. After some troubleshooting efforts, I have removed all of the resource definitions related for Datadog logs archival as well as the related s3 bucket resource and the IAM resources. But I still continue to get the “Error: object contains unparsed element” error for the same resource during “terraform plan” (even though the resource definition has been removed from the config).
I have tried “terraform refresh” to address the possible issues related to the state file. But I still continue to get this error.
What might be the cause of the error and how can it be solved.
Regards,
Yogesh