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
}
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...
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
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
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
@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
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