Facing issue while createing VPC

can someone tell me, what am I doing wrong here.

Did you give the command “terraform apply”?

If the Terraform code is ok (in main.tf) and “terraform apply” command is executed the vpc will be created.

Hi @Alisy404

Please share the course level and task name.

If you look at the screenshot, you will see that the vpc exists when running terraform state list

It seems the validator is expecting a Tag for the VPC. IMHO this is wrong since it’s not a part of the ask and tags are optional. As long as the vpc with the expected name exist in the state, it should pass.

The trick to solving this is to add a tag.

Example
resource “aws_vpc” “main” {
cidr_block = “10.0.0.0/16”

tags = {
Name = “main”
}
}

Level 1 Terraform 1, Q3 Create VPC Using Terraform

Thanks @brkk for sharing the task name.

I’ve checked it and was able to pass the task. I agree with brkk, we need to declare the Name tag correctly so that it matches the name required in the task.

It should pass even without the Name tag. Tag is optional and it wasn’t a part of the question. It should validate based on the existence of the resource in the state file.

Hi @brkk

The task asks us to create a VPC with a name, and AWS uses the ‘Name’ tag key as the default name shown in the console. For example, when you create an EC2 instance and enter a name in the console, that value is actually stored in the ‘Name’ tag.