When using terraform to apply the change on the datadog monitor and dashboard in one folder. I meet this issue. It blocks the operation. I don’t know how to fix this.
Its command is “TF_LOG=DEBUG infra terraform -e production fe-datadog-monitor”.
One thing that surprised me was that the command worked when I declared the target, even though I declared all targets. This means that my change is exactly the same as the previous one. Here is the corresponding output. And its command is “TF_LOG=DEBUG infra terraform -e production -l module.ott-firetv-fe-monitor -l module.ott-androidtv-fe-monitor -l module.ott-ps4-fe-monitor -l module.ott-chromecast-fe-monitor -l module.ott-comcast-fe-monitor -l module.ott-rogers-fe-monitor -l module.ott-cox-fe-monitor -l module.ott-hisense-fe-monitor -l module.ott-tivo-fe-monitor -l module.ott-samsung-fe-monitor -l module.ott-sony-fe-monitor -l module.ott-vizio-fe-monitor -l module.ott-xboxone-fe-monitor -l module.ott-lgtv-fe-monitor -l module.ott-shaw-fe-monitor -l module.ott-hilton-fe-monitor -l module.ott-telstra-fe-monitor -l module.ott-windows-fe-monitor -l module.web-fe-monitor -l module.elasticache_monitor fe-datadog-monitor”
[STDOUT] Plan: 19 to add, 308 to change, 39 to destroy.
[STDOUT] ╷
[STDOUT] │ Warning: Value for undeclared variable
[STDOUT] │
[STDOUT] │ The root module does not declare a variable named "trusted_ips" but a value
[STDOUT] │ was found in file
[STDOUT] │ "/home/heng/tubi/infrastructure/terraform/environments/production.shared.tfvars".
[STDOUT] │ If you meant to use this value, add a "variable" block to the
[STDOUT] │ configuration.
[STDOUT] │
[STDOUT] │ To silence these warnings, use TF_VAR_... environment variables to provide
[STDOUT] │ certain "global" settings to all configurations in your organization. To
[STDOUT] │ reduce the verbosity of these warnings, use the -compact-warnings option.
[STDOUT] ╵
[STDOUT] ╷
[STDOUT] │ Warning: Value for undeclared variable
[STDOUT] │
[STDOUT] │ The root module does not declare a variable named "region" but a value was
[STDOUT] │ found in file
[STDOUT] │ "/home/heng/tubi/infrastructure/terraform/environments/production.shared.tfvars".
[STDOUT] │ If you meant to use this value, add a "variable" block to the
[STDOUT] │ configuration.
[STDOUT] │
[STDOUT] │ To silence these warnings, use TF_VAR_... environment variables to provide
[STDOUT] │ certain "global" settings to all configurations in your organization. To
[STDOUT] │ reduce the verbosity of these warnings, use the -compact-warnings option.
[STDOUT] ╵
[STDERR] 2023-03-29T06:37:30.341Z [DEBUG] [aws-sdk-go] DEBUG: Response dynamodb/GetItem Details:
[STDERR] ---[ RESPONSE ]--------------------------------------
[STDERR] HTTP/1.1 200 OK
[STDERR] Connection: close
[STDERR] Content-Length: 402
[STDERR] Content-Type: application/x-amz-json-1.0
[STDERR] Date: Wed, 29 Mar 2023 06:37:30 GMT
[STDERR] Server: Server
[STDERR] X-Amz-Crc32: 362938085
[STDERR] X-Amzn-Requestid: QG4RF6GPMJ2F4PVUC7MK3K774RVV4KQNSO5AEMVJF66Q9ASUAAJG
[STDERR]
[STDERR]
[STDERR] -----------------------------------------------------
[STDERR] 2023-03-29T06:37:30.341Z [DEBUG] [aws-sdk-go] {"Item":{"LockID":{"S":"tubi-terraform-state/env:/production/live-site/fe-datadog/terraform.tfstate"},"Info":{"S":"{\"ID\":\"242500b2-e0ce-7d7c-e66d-a0731eb8c330\",\"Operation\":\"OperationTypePlan\",\"Info\":\"\",\"Who\":\"heng@heng-dev\",\"Version\":\"1.4.2\",\"Created\":\"2023-03-29T06:36:09.481492064Z\",\"Path\":\"tubi-terraform-state/env:/production/live-site/fe-datadog/terraform.tfstate\"}"}}}
[STDERR] 2023-03-29T06:37:30.342Z [DEBUG] [aws-sdk-go] DEBUG: Request dynamodb/DeleteItem Details:
[STDERR] ---[ REQUEST POST-SIGN ]-----------------------------
[STDERR] POST / HTTP/1.1
[STDERR] Host: dynamodb.us-east-1.amazonaws.com
[STDERR] User-Agent: APN/1.0 HashiCorp/1.0 Terraform/1.4.2 aws-sdk-go/1.44.122 (go1.19.6; linux; amd64)
[STDERR] Content-Length: 131
[STDERR] Accept-Encoding: identity
[STDERR] Authorization: AWS4-HMAC-SHA256 Credential=ASIAVMJ2EIWVPNHI6HNG/20230329/us-east-1/dynamodb/aws4_request, SignedHeaders=accept-encoding;content-length;content-type;host;x-amz-date;x-amz-security-token;x-amz-target, Signature=480e0ea0f0de1ace2ae351f97e46b8319442616898a6b08b989a6d9f935f6c3e
[STDERR] Content-Type: application/x-amz-json-1.0
[STDERR] X-Amz-Date: 20230329T063730Z
[STDERR] X-Amz-Security-Token: FwoGZXIvYXdzEJD//////////wEaDBilMia1gHhlS6PnliK3AUtQxTygFxDLjQRpX+ay/6m+jFc5PE8OhvoxJ+LClB/BIyIz1SW1v4+V2/0qAc/Dein7XbH4XZTt+pbPkdFeaKiGI2d+4iHUccz53p9SkSRI1lCq8vTa2DB4eHs0hkugH08XIVuYSsr6PkGb362tqQEntcBmM+XbrpFhOzioppCZSpxpAuU0HtnVvMn7OIpVXF76KyXw4vKhrBRVTwDCRioJ8IpFHZaWV4jlksBGB1Sm0EBSRdG1iijYuI+hBjItItEOY+Cuc2Z5/m1KbXs4Y4vXMsauLhzCwGQOYjGJAs6IQ3LvHI7AQE2DSSaA
[STDERR] X-Amz-Target: DynamoDB_20120810.DeleteItem
[STDERR]
[STDERR] {"Key":{"LockID":{"S":"tubi-terraform-state/env:/production/live-site/fe-datadog/terraform.tfstate"}},"TableName":"terraform-lock"}
[STDERR] -----------------------------------------------------
[STDOUT] Releasing state lock. This may take a few moments...
[STDERR] 2023-03-29T06:37:30.606Z [DEBUG] [aws-sdk-go] DEBUG: Response dynamodb/DeleteItem Details:
[STDERR] ---[ RESPONSE ]--------------------------------------
[STDERR] HTTP/1.1 200 OK
[STDERR] Connection: close
[STDERR] Content-Length: 2
[STDERR] Content-Type: application/x-amz-json-1.0
[STDERR] Date: Wed, 29 Mar 2023 06:37:30 GMT
[STDERR] Server: Server
[STDERR] X-Amz-Crc32: 2745614147
[STDERR] X-Amzn-Requestid: QRH7J6ILQQLA9HMOB3B1UJ6AO3VV4KQNSO5AEMVJF66Q9ASUAAJG
[STDERR]
[STDERR]
[STDERR] -----------------------------------------------------
[STDERR] 2023-03-29T06:37:30.607Z [DEBUG] [aws-sdk-go] {}
[STDERR] 2023-03-29T06:37:30.608Z [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
[STDERR] 2023-03-29T06:37:30.613Z [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/datadog/datadog/2.25.0/linux_amd64/terraform-provider-datadog_v2.25.0 pid=268078
[STDERR] 2023-03-29T06:37:30.613Z [DEBUG] provider: plugin exited
[ERROR] Error while trying to get terraform plan
[INFO] Try running manually: cd /home/heng/tubi/infrastructure/terraform/live-site/fe-datadog-monitor && terraform plan -detailed-exitcode -var-file=/home/heng/tubi/infrastructure/terraform/environments/production.shared.tfvars -var-file=/home/heng/tubi/infrastructure/terraform/live-site/fe-datadog-monitor/environments/production.tfvars -out /tmp/567eae66-40db-4397-9f69-542b2700289c
[INFO] Killing vault agent listening on http://127.0.0.1:8200...
Here is our terraform command. “terraform plan -detailed-exitcode -var-file=/home/ubuntu/infra/terraform/environments/production.shared.tfvars -var-file=/home/ubuntu/infra/terraform/live-site/fe-datadog/environments/production.tfvars -out /tmp/e45afbf4-b6c1-48a5-846f-2d901a6ef061”
We will still meet the same error without the wrapper script.