0.9.4
Please list the resources as a list, for example:
resource "aws_security_group" "allow_all" {
name = "allow_all"
description = "Allow all inbound traffic"
ingress {
from_port = 0
to_port = 0
protocol = "-1"
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
}
}
resource "aws_lambda_function" "lambda" {
function_name = "${var.name}"
vpc_config {
subnet_ids = ["xxxx", "xxxx", "xxxx"]
# doesnt work with
security_group_ids = ["${aws_security_group.allow_all.id}"]
# works with security_group_ids = ["sg-123456"]
# works with security_group_ids = ["sg-123456", "sg-123456"]
# works with security_group_ids = ${list("sg-123456")}
# works with security_group_ids = ${list("sg-123456", "sg-123456")}
}
}
aws_lambda_function.lambda: vpc_config.0.security_group_ids: should be a list
none
aws_lambda_function.lambda: vpc_config.0.security_group_ids: "sg-112311"
aws_lambda_function.lambda: vpc_config.0.security_group_ids: should be a list
Please list the steps required to reproduce the issue, for example:
terraform planHi @rraymondseek, thanks for the issue!
Just to confirm, the issue works with the following interpolation:
security_group_ids = "${list("${aws_security_group.allow_all.id}")}"
But doesn't work when manually creating the list?
hi @grubernaut,
it doesn't work with the security group you created in another resource
resource "aws_security_group" "allow_all" {
# put content here
}
security_group_ids = "${list("${aws_security_group.allow_all.id}")}"
but, it works with the list you created manually:
security_group_ids = "${list("sg-123456", "sg-654321")}"
Can you please confirm that you're running v0.9.4?
I'm getting a successful lamda function creation with the following Terraform code:
resource "aws_security_group" "foo" {
name = "foo-jake-testing"
vpc_id = "${aws_vpc.foo.id}"
ingress {
from_port = 0
to_port = 0
protocol = "-1"
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
}
}
resource "aws_lambda_function" "foo" {
function_name = "jake-testing-function"
filename = "lambdatest.zip"
role = "${aws_iam_role.foo.arn}"
runtime = "nodejs4.3"
handler = "exports.test"
vpc_config {
subnet_ids = ["${aws_subnet.foo.id}", "${aws_subnet.bar.id}"]
security_group_ids = ["${aws_security_group.foo.id}"]
}
}
With Terraform v0.9.4
aws_lambda_function.foo: Creating...
arn: "" => "<computed>"
filename: "" => "lambdatest.zip"
function_name: "" => "jake-testing-function"
handler: "" => "exports.test"
invoke_arn: "" => "<computed>"
last_modified: "" => "<computed>"
memory_size: "" => "128"
publish: "" => "false"
qualified_arn: "" => "<computed>"
role: "" => "arn:aws:iam::<>:role/iam_for_lambda_jake"
runtime: "" => "nodejs4.3"
source_code_hash: "" => "<computed>"
timeout: "" => "3"
version: "" => "<computed>"
vpc_config.#: "" => "1"
vpc_config.0.security_group_ids.#: "" => "1"
vpc_config.0.security_group_ids.3557995954: "" => "sg-3181164a"
vpc_config.0.subnet_ids.#: "" => "2"
vpc_config.0.subnet_ids.1481730518: "" => "subnet-e23b58ab"
vpc_config.0.subnet_ids.879600011: "" => "subnet-43014924"
vpc_config.0.vpc_id: "" => "<computed>"
aws_lambda_function.foo: Creation complete (ID: jake-testing-function)
Apply complete! Resources: 7 added, 0 changed, 0 destroyed.
Also, which OS/ARCH are you running TF on? Thanks!
hi @grubernaut,
it works, thanks a lot!
I have just realized that the lambda is in its own module
variable "sg_ids" {
default = []
type = "list"
}
resource "aws_lambda_function" "lambda" {
function_name = "${var.name}"
vpc_config {
subnet_ids = ["xxxx", "xxxx", "xxxx"]
security_group_ids = "${var.sg_ids}"
## changed this to security_group_ids = ["${var.sg_ids}"] and it works
}
}
and
resource "aws_security_group" "allow_all" {
name = "allow_all"
description = "Allow all inbound traffic"
ingress {
from_port = 0
to_port = 0
protocol = "-1"
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
}
}
module "lambda" {
source = "lambda"
sg_ids = ["${aws_security_group.allow_all.id}"]
}
}
thank you so much, we can close this now!
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.
Most helpful comment
hi @grubernaut,
it works, thanks a lot!
I have just realized that the lambda is in its own module
and