Menu

1 / 2

I got tired of manually digging CloudTrail every time Terraform drifted — so I built tf-why

DEV Community·Raj Patil·7 months ago
#jSFU0LNn
#devops#aws#cloud#terraform#cloudtrail
Reading 0:00
15s threshold

The problem

Every time terraform plan showed drift, I'd see something like this:

~ aws_security_group.web will be updated in-place

~ ingress = [

{

from_port = 22

protocol = "tcp"

to_port = 22 }, ]

Terraform tells you what changed. It tells you nothing about who

changed it, when, or how.

So I'd open the AWS Console, navigate to CloudTrail, set the time range,

filter by resource, scroll through dozens of unrelated events, and

eventually find the culprit — 20 minutes later.

Every. Single. Time.

What I built

tf-why — a CLI that pipes terraform show -json output directly into

AWS CloudTrail and gives you attribution in seconds.

terraform show -json plan.tfplan | tf-why

Enter fullscreen mode

Exit fullscreen mode

Output:

aws_security_group.web (ingress rules changed)

├── Changed by: [email protected]

├── When: 2 days ago (2026-05-02 14:32 UTC)

├── Via: AWS Console

└── Event: AuthorizeSecurityGroupIngress

aws_s3_bucket.assets (versioning changed)

├── Changed by: ci-deploy-role

├──…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.