terraform: unable to set vpc name?

Viewed 268

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

1 Answers

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"
  }
}
Related