TO-DO : execute the terraform commands to create VPC using vpc.tf and update the command documentation with screenshots
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}
provider "aws" {
region = "us-east-1"
default_tags {
tags = {
terraform = "yes"
project = "terraform-learning"
}
}
}
-
resource "aws_vpc" "appvpc" { cidr_block = "10.0.0.0/16" tags = { Name = "myapp-vpc" } }
-
Terraform AWS Authentication Types
- Static Credentials - You can use this under provider section, but its NOT A RECOMMENDED Option
- Environment variables - Recommended Option (example below)
- IAM credentials stored locally (configuration file $HOME/.aws/credentials)
- use
aws configure
to configure the aws credentials
- use
-
Example : Using Environment variables via PowerShell
terraform init
terraform validate
terraform plan
terraform apply
or
terraform apply -auto-approve
(if you want to avoid the prompt) NOT Recommended for beginners
terraform destroy
or
terraform destroy -auto-approve
(if you want to avoid the prompt) NOT Recommended for beginners
rm -rf .terraform*
rm -rf terraform.tfstate*
Delete the lock file .terraform* and state file terraform.tfstate files from the folder