Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Alfredo Cambera
    @alfredocambera
    Is it possible to create various resources using a for/for_each loop? I'd like to create a module that would receive a list of parameters to create DNS records
    Andrew Bobulsky
    @RulerOf
    You can create many of the same resource with for_each, but not different resources. I'm about 99% sure the same is true of for
    ...I still haven't quite figured out the purpose of for.
    Alfredo Cambera
    @alfredocambera
    I was looking to do something like this:
    for_each = [ for host in hosts: {
    resource "aws_route53_record" "${host}" {
      zone_id = "${aws_route53_zone.private.zone_id}"
          name    = "${var.s.name}"
          type    = "A"
          ttl     = "30"
    
          records = [
            "${var.s.ip}"
          ]
        }
    }
      ]
    cloudsoldier
    @cloudsoldier
    Dear people ...my job is in danger and need help...has anyone encrypted azurevm disks using terraform ? please please help
    any code example will be helpful
    Andrew Bobulsky
    @RulerOf
    @alfredocambera you cannot interpolate resource names.
    That said, there's a way to do what you're asking. It just looks a little different
    one moment.
    Alfredo Cambera
    @alfredocambera
    great, thanks @RulerOf
    cloudsoldier
    @cloudsoldier
    all gone quite....
    sorry guys
    Alfredo Cambera
    @alfredocambera
    @cloudsoldier did you manage to find the solution?
    cloudsoldier
    @cloudsoldier
    @alfredocambera ..no sir struggling for last two weeks and no one knows
    Alfredo Cambera
    @alfredocambera
    Sorry, I have no experience with terraform and azure.
    Andrew Bobulsky
    @RulerOf
    Same problem here @cloudsoldier , I don't know much of anything about Azure, including how its disk encryption scheme works.
    cloudsoldier
    @cloudsoldier
    so this forum is for Terraform or something ele
    else
    where shall I ask for help
    Andrew Bobulsky
    @RulerOf
    It's for terraform, but your question is more specific to Azure than it is to terraform.
    Alfredo Cambera
    @alfredocambera
    @cloudsoldier why don't you ask on the terraform channel on IRC? Just a guess
    Create a question on stackoverflow
    Andrew Bobulsky
    @RulerOf
    I think you already know the resource you need to configure—something to do with azurevm_extension and a bit of embedded JSON.
    cloudsoldier
    @cloudsoldier
    no sir....I used Terraform to create azure vm ...only I need assistance to encrypt
    Alfredo Cambera
    @alfredocambera
    Create a question on quora or reddit
    cloudsoldier
    @cloudsoldier
    terraform channel /Irc what are they
    quora /reddit no idea sie
    sir
    Alfredo Cambera
    @alfredocambera
    Quora, Reddit a couple of websites? Google it and they will show first on search results
    https://webchat.freenode.net/ this is a web interface for IRC. Look for the #terraform channel there
    cloudsoldier
    @cloudsoldier
    thanks guys
    Alfredo Cambera
    @alfredocambera
    Andrew Bobulsky
    @RulerOf
    @alfredocambera is var.hosts a list of maps?
    Alfredo Cambera
    @alfredocambera
    @RulerOf yeap
    Andrew Bobulsky
    @RulerOf
    So something like this:
    variable "hosts" {
      default = [
        {
          name = "host1"
          ip   = "1.1.1.1"
        },
        {
          name = "host2"
          ip   = "2.2.2.2"
        }
      ]
    }
    Alfredo Cambera
    @alfredocambera
      hosts = [
        {
          ip   = "127.0.0.1"
          name = "first"
        },
        {
          ip   = "127.0.0.2"
          name = "second"
        },
        {
          ip   = "127.0.0.3"
          name = "third"
        },
      ]
    Andrew Bobulsky
    @RulerOf
    Close enough :D
    Alfredo Cambera
    @alfredocambera
    yeap
    Andrew Bobulsky
    @RulerOf
    Something like this ought to do it:
    resource "aws_route53_record" "host" {
      for_each = var.hosts
    
      zone_id = aws_route53_zone.private.zone_id
      name    = each.name
      type    = "A"
      ttl     = 30
    
      records = [
        each.ip
      ]
    }
    Alfredo Cambera
    @alfredocambera
    nice!, thanks a lot for taking the time to create an example @RulerOf
    Andrew Bobulsky
    @RulerOf
    Sure thing! :)
    metsuke0
    @metsuke0
    Does there still exist the behavior that if I use "count" to create 100 instances, and I destroy the first [0] instance, then terraform will shift the array and recreate however many shifted on next apply?
    Andrew Bobulsky
    @RulerOf
    That's what for_each was specifically developed to resolve
    metsuke0
    @metsuke0
    I'm curious as to why that behavior isn't built in then? Is the behavior I mentioned desired by default?
    but I shall redo my instance creation with for_each then
    Andrew Bobulsky
    @RulerOf
    The array shifting is just a side effect of the way the count concept works.
    It's not really desired or undesired. It just... is.
    ketzacoatl
    @ketzacoatl
    @metsuke0 it is now "built in" in that sense, wasn't possible in HCL before
    Kevin Crook
    @MidnightCellist_twitter
    Is there a recommended size limit on terraform stacks?
    Andrew Bobulsky
    @RulerOf
    Never heard of such a recommendation, but that doesn't mean it doesnt exist.