Hi,
I created a new VPC in AWS (non-default) and used it:
resource "aws_instance" "prov-node" {
ami = "ami-ad8894c1"
key_name = "${var.aws_keypair}"
vpc_security_group_ids = ["vpc-b0720bd9"]
availability_zone = "eu-central-1a"
instance_type = "m3.large"
tags {
Name = "Chef Provisioning Node"
}
provisioner "remote-exec" {
inline = [
"sudo apt-get -y update",
"sudo apt-get -y install nginx",
"sudo service nginx start"
]
}
}
It always fails with:
* aws_instance.prov-node: Error launching instance, possible mismatch of Security Group IDs and Names. See AWS Instance docs here: https://terraform.io/docs/providers/aws/r/instance.html.
AWS Error: Value () for parameter groupId is invalid. The value cannot be empty
Iยดm using Terraform v0.6.12 and the VPC is created in AWS:
chef
vpc-b0720bd9
available
172.16.0.0/20
dopt-e8e40a81
rtb-91155cf8
acl-e1e4a888
Default
No
Am I missing something?
Hi @cjohannsen81
I think this is the causing the problem:
vpc_security_group_ids = ["vpc-b0720bd9"]
the field expects group IDs, not VPC IDs.
Feel free to reopen if you're still having issues.
Also you'll need to specify the subnet_id and use subnet which is part of that VPC, otherwise default VPC is used.
Urgh, my fault! Thanks!
this is not working for me.
resource "aws_instance" "JumpBox" {
ami = "${data.aws_ami.jenkins.id}"
instance_type = "t2.micro"
subnet_id = "${aws_subnet.public_subnet.id}"
vpc_security_group_ids = ["${aws_security_group.public_ssh_sg.id}"]
}
when i run Terraform Plan, The vps_security_group_ids shows not show the sg id i am setting instead displays
Hi, I have come across the exact same issue. My error message after running terraform apply in the above context is:
aws_instance.mongo: Error launching source instance: InvalidGroup.NotFound: The security group 'my_security_group' does not exist in VPC 'vpc-7ef73604'
status code: 400, request id: df1b098a-2474-478f-a44e-9e0792582fa3
I though see on AWS console that my security group is associated with my VPC under the "security group" link.
Will appreciate any help.
Thanks.
Suj
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
Also you'll need to specify the
subnet_idand use subnet which is part of that VPC, otherwise default VPC is used.