Live data from Hacker News

Terraform 0.15 General Availability

hashicorp.com

221–230 of 239 posts

Re: Terraform 0.15 General Availability

#221
post #132
post #99

Earlier quoted context omitted.

The jump from what you mentioned in paragraph 2 to 3 is not necessarily Terraform. You can use other tools, like Ansible, that IMO have a much better framework than Terraform. I use Terraform for extremely simple stuff that is easy to destroy/recreate. Projects of bigger scale IMO are better served with Ansible and friends.

Ansible looks fine when you start, but gets painful. You need to write idempotent ansible from the start. No excuses. Then you would implement a retry logic in ansible since your cloud APIs will fail for weird reasons or you really must wait that a resource in AWS is truly ready before you run another task. ( for example vpn gateway in AWS must be ready and then you can attach a vpn connection, or a route53 zone reco…

> You need to write idempotent ansible from the start. No excuses.

Absolutely. And code reviews, etc. just like code.

> Then you would implement a retry logic in ansible since your cloud APIs will fail for weird reasons or you really must wait that a resource in AWS is truly ready before you run another task. ( for example vpn gateway in AWS must be ready and then you can attach a vpn connection, or a route53 zone record has to propagate before you do something with it. But in the meantime your other tasks can continue in parallel. Only the vpn tasks needs to wait)

Yes, Ansible modules have a retry built in or a wait_for statement. You can also control the serialization serialize: (or was it parallel), or run_once or when. You have a couple of tools at your disposal.

> At this point we did not do any code reviews yet and we did not answer the question: “how should the infrastructure look like?”

Why not? We usually start with some diagram in README.md or Confluence or a Design Proposal before the code. Code never gets released without a merge request.

> This especially means: how do you actually delete resources with Ansible? So you Start to introduce a kind of “state” for your resource.

state: absent, you can use in about every module.

> So, if you squint hard enough, idempotent, resilient, parallelizable, thread-safe, fast ansible with a state is what terraform solves. If you look at tools like terratest you even get to do unit/integration testing for your infrastructure code.

I believe terraform hides way too much and is too magic. Troubleshooting when terraform goes wrong is really really hard. You have two states to look on -- the cloud state and the TF state.

And now you need to know two tools too, since you will likely need Ansible anyways to configure and operator the hosts later.

> So as soon as you are more than 1 person handling infrastructure following best practices like code review and testing, without getting insane, use terraform.

Beg to differ, 100s of engineers sharing ansible galaxy roles with semantic versioning and whatnot in a very good way at my org.

> Once you do not work in isolation any more, either in a team or as a consultant who needs to hand over their work (and Teach people how idempotent ansible works), I would favor terraform any time.

Maybe you're right. If I'm doing freelance I will likely use Terraform to interact with Cloud. IMO Ansible, just like coding, requires a bit of a community around it with best practices, reviews and etc.

Re: Terraform 0.15 General Availability

#222
post #182

Earlier quoted context omitted.

> Who cares if there is a dangling dns records somewhere or an extra allocated floating ip What if instead of a dangling dns record, its 15 large EC2 instances? Yes, you can come up with examples of trivial dangling resources, but it's just as easy for me to come up with non-trivial examples of dangling resources.

I came up with trivial examples because no one forgets about non-trivial resources. In my opinion, if you decrease some instance count from 18 to 3, you'd rather waste 1 minute deleting 15 instances than dealing with all the problems a state management brings to the table.

> no one forgets about non-trivial resources

The number of articles I've read about someone who left a non-trivial number of resources running unused in AWS and were later surprised by a large bill would seem to be a counterexample to that point.

Re: Terraform 0.15 General Availability

#223
post #221
post #132

Earlier quoted context omitted.

Ansible looks fine when you start, but gets painful. You need to write idempotent ansible from the start. No excuses. Then you would implement a retry logic in ansible since your cloud APIs will fail for weird reasons or you really must wait that a resource in AWS is truly ready before you run another task. ( for example vpn gateway in AWS must be ready and then you can attach a vpn connection, or a route53 zone reco…

> You need to write idempotent ansible from the start. No excuses. Absolutely. And code reviews, etc. just like code. > Then you would implement a retry logic in ansible since your cloud APIs will fail for weird reasons or you really must wait that a resource in AWS is truly ready before you run another task. ( for example vpn gateway in AWS must be ready and then you can attach a vpn connection, or a route53 zone re…

> Beg to differ, 100s of engineers sharing ansible galaxy roles with semantic versioning and whatnot in a very good way at my org

I understand we both have our experiences when using ansible compared to terraform. Good to know that this scales

Regarding your point:

> state: absent, you can use in about every module.

What I meant is that you probably would create 2 pull request. The first one to actually delete things for your infrastructure and then a second pull request to delete your ansible code. I am still not sure how changing things work in this manner, where you destroy and recreate things in a single logical Pull request/commit for example. I guess tracking multiple pull requests in a single ticket might work.

> And now you need to know two tools too, since you will likely need Ansible anyways to configure and operator the hosts later.

I agree. Well, I would use ansible beforehand with Packer to build immutable images/AMIs which are launched by an auto scaling group and a final configuration via cloudinit. Therefore I would not have a chance to apply ansible during autoscaling.

Thanks for your input and valuable discussion. Stay safe

Re: Terraform 0.15 General Availability

#224

Earlier quoted context omitted.

+1 to Pulumi. xyzzy123 already described the differences between Pulumi and terraform, but I want to add one key way in which they are similar: Pulumi uses terraform under the hood. We get all of the reliability of terraform, but with a much more powerful runtime engine.

I guess it depends on what you mean by "under the hood". As far as I know it doesn't use Terraform during runtime but it uses the Terraform resources for generating language definitions. It has a lot of interoperability tools as well such as a "terraform bridge" and a tool that converts Terraform projects.

Thank you for clarifying -- I didn't know that!

Re: Terraform 0.15 General Availability

#225
post #153

So much hate ITT for such a great tool. Terraform is definitely not perfect but it's still one of my favorite tools, solely because of the amount of efficiency gained from learning it. Yes HCL is not perfect, but it is definitely adequate for a lot of applications. IMO, Hashicorp makes some of the most well thought out tools and I am grateful of their attitude towards open source.

I’ve preferred cloud formation for many years. the amount of time I spend debugging problems related to TF is infuriating. at least with aws.

The amount of tooling that has sprung out around managing large CloudFormation deployments is exactly the reason TF exists. CloudFormation is an untenable mess.

Re: Terraform 0.15 General Availability

#226

Earlier quoted context omitted.

Roll back is one reason I choose AWS Cloudformation over Terraform. And also I do not see the reason for Terraform in my use case as we run only on AWS. No point in not using AWS native tools.

I don't use CF, but how does it handle rolling back a delete (thus recreating a resource) and resource ARNs? Is it using some functionality not available to other tools? I always found tf's lack of rollback ability, basically admitting there is no way to really rollback to the exact state, ARNs and all, so it isn't going to try.

>Is it using some functionality not available to other tools?

No, CloudFormation just postpones resource deletions towards the end of stack operations to allow successful operation rollbacks. Even the default replacement strategy is creating the new resource before deleting the old resource whenever possible for this reason:

https://github.com/aws-cloudformation/aws-cloudformation-res...

Re: Terraform 0.15 General Availability

#227

Earlier quoted context omitted.

I don’t get why people like scripting it, declarative is fantastically simple. I don’t want to trace through loops, if statements, functions It does from these files declare my infra to these scripts when parser thru define my infer I get Logic in yaml/json is less ergonomic but templing makes us for it

I suspect you haven't tried Pulumi. It is declarative. Sometimes I just want to generate the declarations rather than type them out by hand.

I was more replying to those saying these products now offer a typescript feature

Re: Terraform 0.15 General Availability

#228
post #216

Earlier quoted context omitted.

You wouldn't see much _practical_ difference between CDK and Pulumi (or Terraform!) for that use-case. The workflow would feel almost identical. Under the hood different things are happening. Your CDK program would run with all the resources you declared. That would generate CloudFormation script(s) that get submitted to the CloudFormation service for evaluation. The CloudFormation service (running inside AWS) is the…

Nice. Does Pulumi support stuff like Cloudflare Workers, FaunaDB, or Auth0?

Workers yes, Auth0 yes, FaunaDB not built-in but you can add it (there is an experimental provider someone made).

Re: Terraform 0.15 General Availability

#229

Earlier quoted context omitted.

I’ve preferred cloud formation for many years. the amount of time I spend debugging problems related to TF is infuriating. at least with aws.

The amount of tooling that has sprung out around managing large CloudFormation deployments is exactly the reason TF exists. CloudFormation is an untenable mess.

No, it’s just that it’s not fun to learn.

Re: Terraform 0.15 General Availability

#230
post #220

Earlier quoted context omitted.

I'm no tooling expert but that seems like the opposite of what you should use Terraform for. Imperative frameworks like Ansible are basically fancy ways to organize and execute custom scripts, you still have to implement your own custom state management logic in Ansible commands/scripts. With larger & more complex infrastructure, you want to do this as little as possible because it's hard to consistently get it right…

Ansible has a bunch of declarative modules. Writing imperative Ansible should basically never happen. My team maintains 50-80 galaxy_roles and it's super rare that we have to build any shared galaxy role on top of imperative logic.

True, and interesting to see that it has worked out so well for your team. I suspect the difference I see in practice is that Ansible playbooks make it much easier to hack in imperative shell scripts in an Ansible task, so it's more likely to happen. I agree that a disciplined & experienced team can do the right thing with either tool and perhaps Ansible's API is nicer if you use it right. This makes me see Ansible in a slightly different light, perhaps I've been unfairly influenced by some Ansible playbooks I've seen in real life.
Post reply on HN