GithubHelp home page GithubHelp logo

Comments (5)

antonbabenko avatar antonbabenko commented on May 24, 2024 1

Thanks! Looks scary :) I normally (for 99.9% of cases) use auto-scaling groups and set EC2 tags from instance itself if necessary.

from terraform-aws-ec2-instance.

antonbabenko avatar antonbabenko commented on May 24, 2024

Yes, you need to modify this module, because you need to access count.index which is available only inside resource block.

from terraform-aws-ec2-instance.

TinajaLabs avatar TinajaLabs commented on May 24, 2024

Thank you, Anton.

FYI, my modification looks like this, in case you or anyone else might have a thought about how to generalize this.

  # modifications 
  # tags = "${merge(var.tags, map("Name", format("%s-%d", var.name, count.index+1)))}"  # original tag code

  tags = "${merge(var.tags, 
    map("Name", "${var.number_of_instances > 1 ? "${var.host_name}${format("%02d", count.index + 1)}.${var.instance_name}" : "${var.instance_name}" }"),
    map("Desc", "Instance for: ${var.number_of_instances > 1 ? "${var.host_name}${format("%02d", count.index + 1)}.${var.instance_name}" : "${var.instance_name}" }")
    )}"
  volume_tags = "${merge(var.volume_tags, 
    map("Name", "${var.number_of_instances > 1 ? "${var.host_name}${format("%02d", count.index + 1)}.${var.instance_name}" : "${var.instance_name}" }"),
    map("Desc", "Volume for: ${var.number_of_instances > 1 ? "${var.host_name}${format("%02d", count.index + 1)}.${var.instance_name}" : "${var.instance_name}" }")
    )}"

from terraform-aws-ec2-instance.

TinajaLabs avatar TinajaLabs commented on May 24, 2024

Haha. Sorry. I'm a nubie so perhaps it's overkill. I get tired of looking at so many things in AWS and trying to figure our which system they're associated. So I'm a bit obsessive trying to apply, for example, the actual fqdn of the instance in the Name field.

I am also using the iterative count mechanism to build multiple variants of the same instances. So not every instance is using it's own unique resource definition.

While I'm developing for AWS now, I'm also trying to keep from going too deep into AWS, because we'll also need t support the same infrastructure on private cloud openstack. If I can't create it in AWS and Openstack, I need to be careful what I use in AWS so I don't paint us into a corner.

Thanks so much for your help and advice.

from terraform-aws-ec2-instance.

github-actions avatar github-actions commented on May 24, 2024

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

from terraform-aws-ec2-instance.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.