Live data from Hacker News

Terraform 0.12

hashicorp.com

31–40 of 167 posts

Re: Terraform 0.12

#31
Good stuff. It looks like they've addressed a few of the ergonomic issues in their language with this release. The old way of doing iteration and having to use string interpolations just to reference variables were annoying.

Re: Terraform 0.12

#32

I moved away from Terraform a long time ago. Ansible was way more powerful, handled errors and issues with state changes. Terraform was super picky about how you had to operate, slow and HCL was a terrible markup language. I wasn't really a huge fan of Ansible either though and more recently have been doing things in regular shell/Bash scripts. Now with Kubernetes and service brokers, there is no need for Terraform.

What about setting up and tearing down EKS clusters? I haven't used terraform but I learned about it through looking at this: https://learn.hashicorp.com/terraform/aws/eks-intro So, I'd say Kubernetes itself does more heavy lifting but not all of it?

I use Terraform to create EKS, works pretty well. I have it setup to use Spot instances with a standard compute node as well as GPU nodes when needed.

https://github.com/JasonCarter80/contoso_aws_k8s/tree/master...

Re: Terraform 0.12

#34
post #14
post #9

Earlier quoted context omitted.

The biggest issue we have with Terraform (and other Hashicorp tools in general, really) is their different configuration formats, but mostly it is HCL limitations. I haven't found a solution for it, but I have lots of resources that are almost identical, except for a few arguments, but right now it seems like my options are to either write my own Ruby script to output .hcl files, or live with two resources that are a…

You can't write a local module for the resource that takes the differences as inputs?

Maybe I can, but I am failing to grasp how templates or the modules work, we have these resources where only the ami is different (and sometimes the count):

    resource "aws_instance" "nomadclients_tick" {
      ami = "${data.aws_ami.nomadclient_tick.image_id}"
      instance_type = "t2.micro"

      count = 3

      iam_instance_profile   = "${aws_iam_instance_profile.consul-join.name}"
      subnet_id              = "${element(aws_subnet.consul.*.id, count.index)}"

      vpc_security_group_ids = [
        "${aws_security_group.rule01.id}",
        "${aws_security_group.rule02.id}",
        "${aws_security_group.rule03.id}",
        "${aws_security_group.rule04.id}",
      ]
    }

    resource "aws_instance" "nomadclients_tock" {
      ami = "${data.aws_ami.nomadclient_tock.image_id}"
      instance_type = "t2.micro"

      count = 3

      iam_instance_profile   = "${aws_iam_instance_profile.consul-join.name}"
      subnet_id              = "${element(aws_subnet.consul.*.id, count.index)}"

      vpc_security_group_ids = [
        "${aws_security_group.rule01.id}",
        "${aws_security_group.rule02.id}",
        "${aws_security_group.rule03.id}",
        "${aws_security_group.rule04.id}",
      ]
    }
The examples I have found feels very difficult.

Re: Terraform 0.12

#35

Earlier quoted context omitted.

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, repeatabl…

>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?

For 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.

Re: Terraform 0.12

#36
post #8
post #4

Earlier quoted context omitted.

IMO they should have dumped HCL once they caught a whiff of what Pulumi is up to, much rather go with actual languages that when you learn them, you pick up some valued knowledge. You can also do a whole lot more with Typescript than you can with HCL 2.

Agreed, the data model of Terraform simply doesn’t match the problem domain. You need an algorithm to codify the pattern and then data to fill in the params. Terraform doesn’t allow you to create the patterns you need in a way that’s debugable and doesn’t allow for code reuse. For simple setups it’s not apparent there’s a problem but when they get more complex it’s nearly impossible to use. Additionally you have to r…

The Terraform language extension in VSCode is very good.

Re: Terraform 0.12

#37
post #15

I honestly love Terraform as a product. It was one of probably three tools I've used in my entire career that made me feel immediately more productive. After using it for a very short period of time I was shocked developers continued to struggle through CF templates and the fragility the whole process entailed.

Well, I feel the same about terraform. I much prefer cloudformation.

Re: Terraform 0.12

#38

I’m a little unclear on terraform in practice. As you supposed to download this, use it’s language and syntax which is all it’s own thing, to define you services and then export that to a YAML setup that AWS CloudFormation (for example) is expecting? I assume there are reasons I wouldn’t just define it myself in YAML directly?

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, repeatabl…

Where 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.

Re: Terraform 0.12

#39
post #34
post #14

Earlier quoted context omitted.

You can't write a local module for the resource that takes the differences as inputs?

Maybe I can, but I am failing to grasp how templates or the modules work, we have these resources where only the ami is different (and sometimes the count): resource "aws_instance" "nomadclients_tick" { ami = "${data.aws_ami.nomadclient_tick.image_id}" instance_type = "t2.micro" count = 3 iam_instance_profile = "${aws_iam_instance_profile.consul-join.name}" subnet_id = "${element(aws_subnet.consul.*.id, count.index)}…

One way I can think of that will solve this problem is to do something like:

    resource "aws_instance" "nomadclients" {
      ami = "${count.index > 2 ? data.aws_ami.nomadclient_tick.image_id : data.aws_ami.nomadclient_tock.image_id}"
      instance_type = "t2.micro"

      count = 6

      iam_instance_profile   = "${aws_iam_instance_profile.consul-join.name}"
      subnet_id              = "${element(aws_subnet.consul.*.id, count.index)}"

      vpc_security_group_ids = [
        "${aws_security_group.rule01.id}",
        "${aws_security_group.rule02.id}",
        "${aws_security_group.rule03.id}",
        "${aws_security_group.rule04.id}",
      ]
    }
The downside to this approach (in TF Because of these headaches, we decided to abandon hcl for these use cases and ended up writing our own preprocessor that takes a JSON configuration and generates individual JSON-based HCL (ie. .json.tf) that terraform can then use. We can leverage proper templating to generate many variants of a single resource in a higher level language, while still using terraform to manage the infrastructure and it only adds one additional step to the plan + apply process.

Re: Terraform 0.12

#40
post #15

I honestly love Terraform as a product. It was one of probably three tools I've used in my entire career that made me feel immediately more productive. After using it for a very short period of time I was shocked developers continued to struggle through CF templates and the fragility the whole process entailed.

Agreed about CF. AWS puts a huge emphasis on CloudFormation when they know it is sub-par. Ansible is pretty cool too because you can easily convert between YAML/JSON for CF, and add a lot of flexibility based on variables and other things such as error handling that you can't do with Terraform.

Definitely not subpar. Cloudformation is an incredible service. I’ve used it to deploy thousands of stacks. It just works.
Post reply on HN