Draft from Terraform and keep it in step
Draft a model from a Terraform state file, read what the file could and could not say, and check the model against the file when the system changes.
Goal
A threat model drafted from the stack that runs your system, and a check of the model against the stack after it changes.
Before you start
Drawing a model by hand, as course 2 did, takes an afternoon. A cloud system already describes itself in its infrastructure code, so Studio can draft the parts and where they sit, and leave you the threats.
Import the file. Open Threat Models and press Import, at the top right. Choose
invoice-portal.tfstate.json. The dialog reads Import from Terraform and 4 components, 1 data flow, 1 trust zone and 0 threats. Below the Name box it says what it left out: 7 resources support the components rather than being one (IAM, security groups, subnets and the like) and are not drawn. Networks that hold components became trust zones. And where flows come from: Data flows come only from what the file states outright: Lambda event sources, load balancer targets, CloudFront origins and API Gateway integrations. Draw the others yourself.

Name it and import. The name reads Terraform infrastructure. Type
Invoice portal (AWS)and press Import. The model opens.
Read the draft. The VPC is a zone, INVOICE-VPC, holding invoice-alb, a LOAD BALANCER, invoice-web-1, an EC2 INSTANCE, and invoice-db, an RDS DATABASE. invoice-pdfs-prod, an S3 BUCKET, is outside it, because a bucket is not in a VPC. The one flow, HTTPS 443, runs from the load balancer to the instance: the listener and the target group state it. Under the model's name, a line reads Drafted from Terraform: invoice-portal.tfstate.json. Last checked, with the day you imported it, and Check for changes. Each component has the log sources its type should send, so NEXT ACTIONS already asks for the load balancer's access logs and the database's audit log, and for answers to 23 open STRIDE questions.

See what the file cannot say. The draft has no threats: STRIDE is still yours, as in Answer STRIDE. Nor does it have the people. Terraform does not know about the customers or the administrator, or that the instance reads and writes the bucket and the database. Add those by hand as in course 2. What you add is yours, and what Terraform drew stays tied to the resource it came from, so a later check can follow it.
Check it against the same file. Press Check for changes and choose
invoice-portal.tfstate.jsonagain. The dialog compares by the resource each component was drafted from. Components drawn by hand are not compared., and reads Nothing has changed: every resource the model drew is still there, and there is nothing new. Press Close. The button at the top right now reads Save: the day of the check is part of the model, and it is kept when you save.
Know what a check never does. Had the queue been taken out of the stack, the check would read 1 no longer in Terraform, and tell you to remove it from the canvas if it is gone for good, because its threats go with it. Studio never removes a component for you. And when a model has not changed in 90 days, its card on Threat Models reads Review due.
You should now see
Invoice portal (AWS) saved with five components, invoice-email among them, and 27 open STRIDE questions.
Quick check
Go deeper
- Threat models, for what a Terraform, CloudFormation or ServiceNow draft turns into components, zones and flows.
- Save the model, then commit it from the workbench, as with any model: the draft is a pending change until you do.

