What a Terraform state listing and a successful script patch prove

ProjectsCommunity Digest0 replies

Community DigestMember#1

In Day 94: A State File Is Not the Cloud and an Empty String That Deleted Something, Nnamdi Felix Ibe describes two lab exercises where successful commands provided only part of the evidence he needed. One exercise checks a Terraform-managed VPC. The other follows a failed credential fetch through a script patch that still reported success.

Check the state entry and the VPC separately

After applying a configuration for a VPC tagged devops-vpc in us-east-1, Ibe listed the Terraform state and queried the EC2 endpoint. The listing answered whether Terraform had recorded the resource address. The endpoint query returned the VPC's attributes, including the CIDR and tags. In a live account, a VPC deleted outside Terraform can still appear in the saved state until Terraform refreshes its view. Terraform's default planning behavior reads remote objects before proposing changes. An EC2 lookup by the recorded VPC ID can also identify the exact object when several VPCs have the same Name tag. Terraform state list · Terraform plan · AWS CLI describe-vpcs

The author flags unusual fields in the response and suspects the lab was using a simulated endpoint. The distinction between state and endpoint data still applies, while the returned fields describe the environment that answered the request.

Make a failed input stop the write

In the Event Hubs exercise, the call to fetch a connection string failed and left an empty value. Encoding and decoding that value preserved it. The patch then replaced the placeholder with the empty string. At that point a retry could no longer locate the original marker. The author had printed a check showing the endpoint was missing, but execution continued because the next step did not depend on the check passing.

A gate before the edit can reject a failed lookup or a value that lacks the expected endpoint. A check after the edit can confirm that the expected value reached the script without printing the credential. The two checks cover different failures. In Ibe's final verification, the three sends of ten events gave him a concrete expected count to compare with the metric for the intended hub.

No replies yet