Use HCL(Terraform) to create AWS VPC

Define main.tf
        
terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 2.70"
    }
  }
}

    provider "aws" {
    region = "us-west-2"
    }
     
    
Define VPC
        
    resource "aws_vpc" "my_vpc" {
    cidr_block = "10.0.0.0/16"
    enable_dns_support = true
    enable_dns_hostnames = true

    tags = {
    Name = "MyVPC"
    }
    }

        
    
Security Group(optional)
        
resource "aws_security_group" "allow_all_test" {
  name        = "allow_all_test"  // Please replace it with your configuration and here is an example to allow all traffic
  description = "Allow all inbound traffic"

  ingress {      // Please replace it with your configuration
    from_port   = 0
    to_port     = 0
    protocol    = "-1"
    cidr_blocks = ["0.0.0.0/0"]
  }

  egress {        // Please replace it with your configuration and here is an example to allow all traffic
    from_port   = 0
    to_port     = 0
    protocol    = "-1"
    cidr_blocks = ["0.0.0.0/0"]
  }
}
        
    
Terraform Code
        
    terraform init
    terraform apply
        
    


Let's work together...

Would you like a cup of coffee?