Re:Terraform best practices for reliability at any scale
by harha_ on Saturday August 05, 2023 @05:09AM
(#37010321)
I've never used terraform, but I have used CloudFormation and AWS CDK. It's been a while though, is there a clear indication on the major cloud provider docs which resources are stateful? Or is it always obvious?
[ Parent
| on HN ]
Re:Terraform best practices for reliability at any scale
by tyingq on Saturday August 05, 2023 @06:26AM
(#37010683)
Difficult question, as people mean different things when they say state. One example might be a relatively simple AWS Lambda. Most people would say that's easily stateless.
But, what if that Lambda depends on a VPC with some specific networking config to allow it to connect to some partner company private network? And, it's difficult to recreate that VPC without service disruption for a variety of reasons that are out of your control. Well, now you have state because you need to track which existing VPC the Lambda needs if you tear the Lambda down and recreate it.
Re:Terraform best practices for reliability at any scale
by giaour on Saturday August 05, 2023 @07:57AM
(#37011146)
Usually people use "state" to mean that the resource accumulates data. E.g., a VPC is stateless, but the s3 bucket containing flow logs for the VPC is not.
Tearing down and recreating a VPC can be disruptive, but that doesn't make it a stateful resource.
Re:Terraform best practices for reliability at any scale
by tyingq on Saturday August 05, 2023 @08:20AM
(#37011296)
In my example, the "state" part is someone storing the specific VPC reference to re-apply to a newly re-created lambda. Rather than recreating both the VPC and the Lambda. Many people would refer to that as a bad practice because it's carrying state. e.g., the kind of stuff that terraform puts in .tfstate files.
There's definitely a purist camp that advocates completely stateless infra. Though there's also what you're describing, where some people consider state to only refer to things like databases.