Menu

One secret in our task definition hid the database change sitting next to it
📰

One secret in our task definition hid the database change sitting next to it

DEV Community: terraform·Sergey Shinder·about 3 hours ago
#EMt98FKB
#devtoterraform#devto#dev#sensitive#service
Reading 0:00
15s threshold

In March our order service spent nine minutes failing every write with cannot execute INSERT in a read-only transaction. A pull request merged that morning had pointed it at the reporting replica. Two of us had approved the Terraform plan for that change.

The service runs on ECS, and its task definition is built in Terraform: a list of container definitions passed through jsonencode, environment variables included. One of those variables was the API key for our address lookup provider, read from a Terraform variable marked sensitive. The pull request was a tidy-up that moved shared settings into locals, and during the move the order service's DATABASE_URL was copied from the reporting worker's block a few lines further down.

Terraform carries sensitivity through expressions. Anything derived from a sensitive value is sensitive too, and jsonencode returns one string, so a single secret anywhere inside it marked the entire string.…

Continue reading — create a free account

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