Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First Demo #1

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*.tfstate.backup
#.terraform.lock.hcl
#*.tfvars
secrets.tfvars

# Ignore .pem files
#*.pem

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ terraform {
# Provider Block
provider "aws" {
profile = "default" # AWS Credentials Profile configured on your local desktop terminal $HOME/.aws/credentials
region = "us-east-1"
region = "eu-west-1"
}

# Resource Block
resource "aws_instance" "ec2demo" {
ami = "ami-0be2609ba883822ec" # Amazon Linux in us-east-1, update as per your region
ami = "ami-0d1bf5b68307103c2" # Amazon Linux in us-east-1, update as per your region
instance_type = "t2.micro"
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
# Terraform Block
terraform {
required_version = "~> 0.14.3"
required_version = "~> 1.0.0"
required_providers {
aws = {
source = "hashicorp/aws"
source = "hashicorp/aws"
version = "~> 3.0"
}
}

random = {
source = "hashicorp/random"
version = "3.0.1"
}
source = "hashicorp/random"
version = "~> 3.0"
}
}
}

provider "aws" {
region = "eu-west-1"
profile = "default"
}

/*
Play with Terraform Version
required_version = "~> 0.14.3"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# Terraform Block
terraform {
required_version = "~> 0.14.6"
required_version = "~> 1.0.0"

required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
}
}
}
}

# Provider Block
provider "aws" {
region = "us-east-1"
region = "eu-west-1"
profile = "default"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
# Resource-1: Create VPC
resource "aws_vpc" "myvpc" {
cidr_block = "10.0.0.0/16"

tags = {
"Name" = "myvpc"
"Created_by" = "Terraform"
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Terraform Block
terraform {
required_version = "~> 0.14.6"
required_version = "~> 1.0.0"
required_providers {
aws = {
source = "hashicorp/aws"
Expand All @@ -11,15 +11,15 @@ terraform {

# Provider-1 for us-east-1 (Default Provider)
provider "aws" {
region = "us-east-1"
region = "eu-west-1"
profile = "default"
}

# Provider-2 for us-west-1
provider "aws" {
region = "us-west-1"
region = "eu-west-2"
profile = "default"
alias = "aws-west-1"
alias = "aws-eu-west-2"
}


Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Resource Block to Create VPC in us-east-1 which uses default provider
resource "aws_vpc" "vpc-us-east-1" {
resource "aws_vpc" "vpc-eu-west-1" {
cidr_block = "10.1.0.0/16"

tags = {
"Name" = "vpc-us-east-1"
"Name" = "vpc-eu-west-1"
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Resource Block to Create VPC in us-west-1
resource "aws_vpc" "vpc-us-west-1" {
resource "aws_vpc" "vpc-eu-west-2" {
cidr_block = "10.1.0.0/16"
provider = aws.aws-west-1
provider = aws.aws-eu-west-2
tags = {
"Name" = "vpc-us-west-1"
"Name" = "vpc-eu-west-2"
}
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Terraform Settings Block
terraform {
# Terraform Version
required_version = "~> 0.14.6"
required_version = "~> 1.0.0"
required_providers {
# AWS Provider
aws = {
source = "hashicorp/aws"
version = ">= 2.0.0"
version = ">= 2.1.0"
}
# Random Provider
random = {
Expand All @@ -18,6 +18,6 @@ terraform {

# Provider Block
provider "aws" {
region = "us-east-1"
region = "eu-west-1"
profile = "default" # Defining it for default profile is Optional
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ resource "random_pet" "petname" {
resource "aws_s3_bucket" "sample" {
bucket = random_pet.petname.id
acl = "public-read"
region = "us-east-1" # Comment this if we are going to use AWS Provider v3.x version
#region = "eu-west-1" # Comment this if we are going to use AWS Provider v3.x version
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Terraform Block
terraform {
required_version = "~> 0.14"
required_version = "~> 1.0.0"
required_providers {
aws = {
source = "hashicorp/aws"
Expand All @@ -11,5 +11,5 @@ terraform {

# Provider Block
provider "aws" {
region = "us-east-1"
region = "eu-west-1"
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Create EC2 Instance
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance

resource "aws_instance" "my-ec2-vm" {
ami = "ami-047a51fa27710816e"
resource "aws_instance" "my_resource_1" {
ami = "ami-0d1bf5b68307103c2"
instance_type = "t2.micro"
availability_zone = "us-east-1a"
#availability_zone = "us-east-1b"
availability_zone = "eu-west-1a"

tags = {
"Name" = "web"
#"tag1" = "Update-test-1"
Name = "HelloWorld"
From = "Terraform Training"
}
}

}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading