7 ms·
As others have said, no exporting is involved. You write roughly-json-esque code which you then apply to a cloud provider. The state of the infrastructure is s
by pensatoio 7y ago
As others have said, no exporting is involved. You write roughly-json-esque code which you then apply to a cloud provider.
The state of the infrastructure is stored, ideally, in the cloud. You apply your code during which terraform identifies which changes need to be made by comparing the current state with your local changes and executes those changes as you watch.
The end result is well-defined, testable, repeatable cloud infrastructure provisioning.
Infrastructure as code. Store it in git. Profit.
- SlowRobotAhead 7y ago>Infrastructure as code. Store it in git. Profit. Ok. But so is CloudFormation YAML files, mostly. So is the advantage of Teraform that it works beyond AWS?
- dvcrn 7y agoFor me yes. I can do things like: Spinup a kubernetes cluster, add a deployment with the latest image from my docker registry, add a loadbalancer with an external IP and create a cloudflare A record for my domain with that IP - all within the same tool.
- SlowRobotAhead 7y agoOk, but if you are (as in my case) staying entirely in AWS dynamo, lambda, E3, and IoT Core... it seems less important. I never leave the AWS ecosystem at all. I’m not challenging what you do, just trying to figure out what makes sense for me.
- mirceal 7y agohuge difference between storing the infrastructure definition vs storing the infrastructure state. cloudformation manages the state for you and will not fuck it up / allow you to fuck it up
- 420codebro 7y agoMy opinion? Because CloudFormation is full of shit regarding "always being able to rollback". After dealing with a 100+ failed CF rollbacks, I stopped caring about that phantom feature. That's around the same time I started using Terraform. At this point I only use CF for things I can not put in TF directly - namely ASGs. Regarding IaC "rollback" capabilities - I don't think it really exists in a way that makes it reasonable for people to depend on. The path forward is to stand up new infrastructure, canary test, etc - then steer via load-balancers the traffic to your new nodes, and then finally destroy the old ones. I loathe trying to maintain a fleet of nodes that can drift into various states of dis-repair. I love the idea of blowing everything away and having a 100% clean and predictable environment again. It makes me happy. </end rant> Hope that helps - I really have fallen in love with Terraform after having to cobble down N number of CLI tools for various cloud providers, hypervisor providers, etc. Terraform at least gives an easy to use language and abstracts me above recursive API call logic that I would otherwise need to write for basic things.
- SlowRobotAhead 7y agoThat does help. I’ve never heard about CF not working as expected. Hmm, I’ll have to look into it some more. I really like the idea of layering my application into dynamo set up, lambdas, polices, etc. and being able to update a specific layer, pull it down and put the new one up. Last thing I want is more headache.
- nineteen999 7y agoWhere do you store your state files? The only project I've worked on that used Terraform stored state in a git repo, which seemed like a nightmare with multiple people doing deploys to the same environment. Others have suggested it would be better stored on a network accessible share.
- 0xEFF 7y agoStore them in a bucket as soon as possible.
- bbatha 7y agoUsually your favorite S3 like service. Do most of your development in modules then have “roots” that cover a well defined subsets of your infrastructure (say db, app servers, load balancer and firewall rules for a single app) then use workspaces to manage different environments. The docs for terraform are actually quiet.
- haney 7y agoI use a versioned S3 bucket to store state in my project, terraform also supports "locks" to avoid race conditions/parallel execution. I've set up buildkite to run `terraform plan` and then if the output looks I can approve the next step to run `terraform apply`. Atlantis (https://github.com/runatlantis/atlantis https://github.com/runatlantis/atlantis) is also a really cool project for managing teams working on terraform projects.
- pensatoio 7y agoPersonally, my team uses S3 to store state paired with DynamoDB to manage state locks. Translation, when someone applies a layer a remote lock is created for the duration of their interaction. It’s a fantastic system. I imagine using git to store state would be mightily inconvenient.