In Terraform, how to output values from a list?

I am trying to get the output to show me the names of the IAM users being created. resource "aws_iam_user" "lb" { name = var.elb_names[count.index] count = 3 path = "/system/" } variable "elb_names" { type = list default = ["dev-lb", "qa-lb", "prod-lb"] } output "elb_names" { value = aws_iam_user.lb.name[count.index] } I expect to get… Read More In Terraform, how to output values from a list?

Create parameterized resource policy on terraform

I want to create a resource policy for a Secrets Manager secret. I am following the official example on the docs resource "aws_secretsmanager_secret_policy" "this" { count = var.create_resource_policy ? 1 : 0 secret_arn = aws_secretsmanager_secret.mysecret.arn policy = <<POLICY { "Version": "2012-10-17", "Statement": [ { "Sid": "EnableAnotherAWSAccountToReadTheSecret", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::123456789012:root" }, "Action": "secretsmanager:GetSecretValue",… Read More Create parameterized resource policy on terraform

How to combine aws_subnet.prod_subnet.*.id with aws_subnet.prod2_subnet.*.id into a single list

I am trying to combine all subnets to be able to attach an ACL to them. I have two subnets that exist which different resource names, so it’s forcing me to have two ACL blocks which I don’t want. Right now the ACL subnet_id blocks for both ACL blocks read as: resource "aws_network_acl" "prod_public" {… Read More How to combine aws_subnet.prod_subnet.*.id with aws_subnet.prod2_subnet.*.id into a single list

terraform aws: Incorrect protocol in creating a security group

I have the following aws_security_group I would like to implement with terraform: resource "aws_security_group" "ort_to_db" { name = "MySQL/AURORA" vpc_id = data.aws_vpc.vpc_ort.id ingress { from_port = 3306 to_port = 3306 protocol = "MYSQL/Aurora" cidr_blocks = ["0.0.0.0/0"] } egress { from_port = 0 to_port = 0 protocol = -1 cidr_blocks = ["0.0.0.0/0"] } } However, I’m… Read More terraform aws: Incorrect protocol in creating a security group

Value attribute is expected when creating aws internet gateway with terraform

I want to create an internet gateway with terraform. Following the [terraform documentation][1] I have the following block resource "aws_internet_gateway" "prod-igw" { vpc_id = "${aws_vpc.prod-vpc.id}" tags = {{ Name = "pos-igw" } } After applying I get this error message. Error: Missing attribute value Expected an attribute value, introduced by an equals sign ("="). There’s… Read More Value attribute is expected when creating aws internet gateway with terraform

Inappropriate value for attribute "value": string required in terraform

I’m creating Elastic beanstalk with terraform inside a vpc and I need to have at least two subnets because when I try to apply with only one I get an error that demands at least two. So here I define two subnets. resource "aws_elastic_beanstalk_application" "elasticapp" { name = var.elasticapp } resource "aws_elastic_beanstalk_environment" "beanstalkappenv" { name… Read More Inappropriate value for attribute "value": string required in terraform

What is needed to make Terraform tolist() to work for my code after the replacement of list()

This is a simple question and I am trying to understand what documentation I can use to better understand this but this is what is happening. I’m looking to update my code of Terraform and I am running into an issue when it comes to using tolist(). My snippet of code: subnet_ids = var.zone_awareness_enabled ?… Read More What is needed to make Terraform tolist() to work for my code after the replacement of list()