0

I am working on setting up a Cloud9 environment using Terraform, I ran into an issue when it comes to my Terraform apply and specifically:

Error: Error applying plan:

1 error(s) occurred:

* aws_instance.cloud9Test: 1 error(s) occurred:

* aws_instance.cloud9Test: 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

Here is my Terraform code that seems to be related and causing the issue.

resource "aws_vpc" "cloud9Test" {
  cidr_block       = "10.0.0.0/16"
  instance_tenancy = "dedicated"

  tags = {
    Name = "cloud9Test"
  }
}

resource "aws_security_group" "cloud9Test" {
    name = "cloud9Test-sg"
    description = "Cloud9 Group"
    vpc_id      = "${aws_vpc.cloud9Test.id}"
}

When I comment out the vpc_id in the security group I don't have the issue anymore but I do want the security group inside my VPC.

How do I fix this?

Note I do not have anything that should overlap causing an issue, this is a fairly new account with only 3 ec2 instances and 1 cloud9 instance all created manually

0

I'll go out on a limb here and assume that the issue is actually in your "aws_instance" block and is likely the result of how you are assigning the security groups in the "aws_instance".

Copied from the first linked article, in the resolution:

change 

security_groups = ["cloud9Test"]

to

vpc_security_group_ids = ["${aws_security_group.cloud9Test.id}"]

Two related articles:

https://github.com/KainosSoftwareLtd/aws-api-gateway-demo/issues/3

https://stackoverflow.com/questions/31569910/terraform-throws-groupname-cannot-be-used-with-the-parameter-subnet-or-vpc-se/34586893#34586893

If this is not on track, please post the "aws_instance" declaration.

For your own sanity I'd also recommend giving the resources names that are more specific to their role, and not identical, for example "cloud9Test_vpc".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.