yen
yen

Reputation: 2292

terraform: unable to set vpc name?

I am starting to learn terraform. I created a vpc thusly:

resource "aws_vpc" "my-vpc" {
  cidr_block = "10.0.0.0/16"

  tags = {
    terraform = "true"
  }
}

I thought it would be named my-vpc in the management console but it wasn't. The name is blank. And on the documentation page there is no "name" attribute: when I tried setting a name I got an error during the apply (An argument named "name" is not expected here.)

I can't believe you can't set a name?! What am I missing?

enter image description here

Upvotes: 7

Views: 2900

Answers (1)

Marcin
Marcin

Reputation: 238081

Name of a VPC is just a tag called Name:

resource "aws_vpc" "my-vpc" {
  cidr_block = "10.0.0.0/16"

  tags = {
    terraform = "true"
    Name = "myvpc"
  }
}

Upvotes: 16

Related Questions