Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Jayson Henkel
    @Deep-Six
    milcom:matrix.org: yes , so I need a 3 line entry foo=bah\nfoo2=<variable>\nfoo3=baz
    1 reply
    Jayson Henkel
    @Deep-Six
    yes, but only one of them is a variable, it's a kubernetes secret
    so I am storing the contents of a config file in a kubernetes secret
    and I need a few dynamic items in it
    but I only have 1 secret reference from the helm chart I am using, so I am using \n's to render the final output I need... inside the container...
    which is working
    but, I'd rather not have a static password defined inside my tf file
    so if I could instead interpolate the password that is in the middle of that string that would be perfect
    2 replies
    Jayson Henkel
    @Deep-Six
    milcom:matrix.org: I'm also getting another difficult issue Could not retrieve the list of available versions for provider
    hashicorp/postgresql: provider registry registry.terraform.io does not have a
    it's mentioning something about upgrading from 12 via 13 to 14, but I've only started using TF at 14
    Jayson Henkel
    @Deep-Six
    fixed it, had to define the provider...
    Henrik Holst
    @hholst80

    Stupid syntax question, re array notatoin.

    The ssh_keys key assumes a list of id's or strings not a composite object with multiple fields. So I need to do the equivalent of the python statement {"ssh_keys": [key.id for key in digitalocean_keys.keys]}

    I have the following code:

    data "digitalocean_ssh_keys" "keys" {
      sort {
        key       = "name"
        direction = "asc"
      }
    }

    and now I want to use that thing inside a instance:

    resource "digitalocean_droplet" "test" {
       ...
      ssh_keys = data.digitalocean_ssh_keys.keys
    }
    5 replies
    Pawel
    @pjd:matrix.org
    [m]
    I have a general question to terraform practicioners. At my company we are entering this space, and trying to design it well from the scratch. How do you navigate the space between terraforming entire fleet and provisioning/CM of individual VMs? My current idea is to have a single repository with entirety of project (GCP)/subscription (Azure) with tags, and then individual Github repositories with "apps" (say SolR for search, or Oracle, or Tableau for business analytics). THose individual repos would be ansible code executed against tags set on the large "fleet" repo. Does this pattern make sense? Are there some "best practices" for this problem ?
    1 reply
    Klaus Frank
    @agowa338
    Hi, is there a possibility to invoke the resource importer for everything in a specific inventory? Or at least for multiple resources at once?
    Viv
    @milcom:matrix.org
    [m]
    Yeah, that's what I think it is. Been a while since I've had to write terraform code from scratch.
    Klaus Frank
    @agowa338

    Hi, is there a possibility to invoke the resource importer for everything in a specific inventory? Or at least for multiple resources at once?

    My main issue is with rate limits on the api, in one response I get the data for a bunch of resources at once, but without the ability to import them all at once I'm just unnecessarily querying the api again. Which leads to the import taking half a day instead of a few minutes...

    MichaelSweikata
    @MichaelSweikata

    Hey everyone, I have a (hopefully) quick question about data blocks with returning data order. So, if I do:

    data "aws_subnet" "my_subnets" {
      count = length(var.subnet_zone_ids)
      [...]
    }

    If var.subnets is going to be a list of 3, is the order in which those data entries to be returned going to be constant? Like, [0] being "id-12345" would always be "id-12345", [1] would be "id-54321" and not change to where 1 is returned in position 0

    1 reply
    Ismael Piñeiro Ramos
    @ispirals

    Hi everyone, I'm facing an issue after upgrade terraform cli on terraform cloud. We have a custom module that install the aws cli to run some commands that are not yet implemented in the aws provider. The problem is that it has stop working and I don't know why. Module is very simple

    resource "null_resource" "install" {
      provisioner "local-exec" {
        command = <<EOH
    set -e
    WORKDIR=$(pwd)
    mkdir -p "$WORKDIR/aws"
    cd "$WORKDIR"
    curl -f "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
    unzip awscli-bundle.zip
    ./awscli-bundle/install -i "$WORKDIR"/aws
    "$WORKDIR"/aws/bin/aws --version
    echo "$WORKDIR"/aws/bin/aws > out.txt
    EOH
      }
      triggers = {
        random_number = timestamp()
      }
    }
    
    data "local_file" "foo" {
      depends_on = [null_resource.install]
      filename   = "out.txt"
    }
    
    output "cli_path" {
      value       = chomp(data.local_file.foo.content)
      description = "The path where the AWS cli executable is installed"
    }

    And since the upgrade I'm getting the error during the plan "Error: open out.txt: no such file or directory" it's like the null_resource isn't triggered

    9 replies
    griffta
    @griffta
    Hi there, I'm new to this chat so I might not know the correct protocol, apologies in advance. Would anyone be able to advise me on the correct way to deploy a Azure SQL VM to achieve the same as described here https://docs.microsoft.com/en-us/azure/azure-sql/virtual-machines/windows/sql-server-on-azure-vm-iaas-what-is-overview
    James Belchamber
    @jamesbelchamber:matrix.org
    [m]
    You're unlikely to get full-on consultancy in this channel
    griffta
    @griffta
    ahh, thanks. Wasn't quite sure what to expect!
    James Belchamber
    @jamesbelchamber:matrix.org
    [m]
    I would go and try implementing it yourself, using the Microsoft and Hashicorp docs, and then ask specific questions where you get stuck (why is this not doing what I expect, etc)
    Huh, they've moved the docs 👀
    griffta
    @griffta
    I have implemented a VM using azurerm_windows_virtual_machine based upon a sql2019-ws2019 image. I've then referenced this VM within a azurerm_mssql_virtual_machine resource. Being fairly new to terraform, I could do with someone confirming that this is the right approach. It deploys without issue...
    James Belchamber
    @jamesbelchamber:matrix.org
    [m]
    My understanding is that the documentation you linked is creating an Azure SQL instance, not an Azure VM instance
    I would suspect the resource you'd be creating is azurerm_sql_database
    griffta
    @griffta
    right, I'll do a bit more reading of the resource docs
    Thibault Cohen
    @titilambert_gitlab
    Hello, I'm trying to use terraform cloud. I want to use it with local execution. At the first plan execution, the workspace is created with "remote" execution and it crashed then I have to go to the UI to change the setting.
    So my question is: can we force the execution mode to local when is created at the first plan run ?
    Rogier Dikkes
    @a-nldisr_gitlab
    Hi, Im using a dynamic block, here i use the for_each. Is it possible to get the index count for the for_each?
    Rogier Dikkes
    @a-nldisr_gitlab
    Something like this:
    dynamic "subnet_mapping" {
        for_each = module.subnets.public_subnet_ids
    
        content {
          subnet_id                         = each.key
          allocation_id                     = aws_eip.something.id[${index.count}] // or something, i have no idea here.
        }
      }
    Nolan Woods
    @innovate-invent
    @a-nldisr_gitlab
    dynamic "subnet_mapping" {
        for_each = range(length(module.subnets.public_subnet_ids))
        content {
          subnet_id                         = keys(module.subnets.public_subnet_ids)[each.key]
          allocation_id                     = aws_eip.something.id[each.key] // or something, i have no idea here.
        }
      }
    BBSDCA
    @BBSDCA
    I can't be the only one with Error: Unsupported argument errors on azure?
    An argument named "virtual_machine_name" is not expected here, but it is. and take it out, it says it's missing.
    anyone? TIA
    provider "azurerm" {
      tenant_id       = "..."
      subscription_id = "..."
      features {}
    }
    # <https://registry.terraform.io/modules/innovationnorway/vm-run-command/azurerm/latest>
    module "run_command" {
      source               = "innovationnorway/vm-run-command/azurerm"
      resource_group_name  = "dc-rg"
      virtual_machine_name = "VM1"
      os_type              = "windows"
    
      script = <<EOF
    Install-Module -Name PSWindowsUpdate -Force -AllowClobber
    Get-WUInstall -WindowsUpdate -AcceptAll -UpdateType Software -IgnoreReboot
    Get-WUInstall -MicrosoftUpdate -AcceptAll -IgnoreUserInput -IgnoreReboot
    EOF
    }

    Error: Missing required argument

    on .terraform\modules\run_command\main.tf line 23, in resource "azurerm_virtual_machine_extension" "linux":
    23: resource "azurerm_virtual_machine_extension" "linux" {

    The argument "virtual_machine_id" is required, but no definition was found.

    whole bunch of those

    TIA

    5 replies
    Chris Schmidt
    @chrisisbeef
    Hi folks - I've been frustrated for a while that there doesn't seem to be any "simple" way to keep track of when modules/providers are updated so that we can be notified and schedule time to evaluate the updates and keep our things up to date. Up until recently we've had our main engineer responsible for maintaining terraform attempting to just watch repos and when he gets notificed of a new release he creates a ticket, but this is unmaintainable as our things scale and grow. Is anyone aware of something that could be run as part of terraform itself that checks to see if you're on the latest version of your modules, and maybe prints something out to the console so we could automate this process in our CI/CD?
    2 replies
    Nolan Woods
    @innovate-invent
    @chrisisbeef have your CI run a nightly job that queries the registry api https://www.terraform.io/docs/registry/api.html
    compare that to the output of terraform --version
    Rogier Dikkes
    @a-nldisr_gitlab

    @a-nldisr_gitlab

    dynamic "subnet_mapping" {
        for_each = range(length(module.subnets.public_subnet_ids))
        content {
          subnet_id                         = keys(module.subnets.public_subnet_ids)[each.key]
          allocation_id                     = aws_eip.something.id[each.key] // or something, i have no idea here.
        }
      }

    Yes, but when i do that i get the error:

    Because aws_eip.something has "count" set, its attributes must be accessed on
    specific instances.
    
    For example, to correlate with indices of a referring resource, use:
        aws_eip.something[count.index]

    And using the count.index on the dynamic block doesnt work, because there is no count set in the block

    Is this a bug?
    Rogier Dikkes
    @a-nldisr_gitlab
    Why should an eip be used on instances?
    You can use it on instances, but also on loadbalancers these days. I dont understand why the error tells me to use a specific instance
    Rogier Dikkes
    @a-nldisr_gitlab

    To give a bit more context this is the whole snippit (cannot adjust the previous message)

    resource "aws_lb" "public-lb" {
      name                              = public-tf
      internal                          = false
      load_balancer_type                = "network"
      subnets                           = module.subnets.public_subnet_ids
    
      dynamic "subnet_mapping" {
        for_each = module.subnets.public_subnet_ids
    
        content {
          subnet_id                         = subnet_mapping.value
          allocation_id                     = aws_eip.public-nlb.id[subnet_mapping.key].allocation_id
        }
      }
    }
    
    resource "aws_eip" "public-nlb" {
      count = 3
      vpc   = true
    }

    The module returns 3, 2 or 1 subnet. I want to dynamically create EIP's based on this. When i however use the above example it returns the error above

    2 replies
    po-wehi
    @po-wehi
    Hi all
    does anyone have a list of most common issues during terraform 0.12 upgrade ?
    derekm1215
    @derekm1215
    :wave:
    Klaus Frank
    @agowa338
    Is there a known issue with the importer, or did I screw something up? The import runs ok, but a terraform plan afterwards shows some strange - timeouts {} which I don't see within the schema. Where could that come from?
    sysrazor
    @sysrazor
    if anyone is still online; can someone tell me if I am way off course or a better way of doing this. I am trying to set some environment variables in locals from the output of modules and merging variables from tfvars and locals into a single local to be used on another module. It was working but as I just tried to add another module I am getting the ever so fun "given value is not suitable for child module" error