diff --git a/Labs/01-Deploy-Infrastructure-with-Terraform/README.md b/Labs/01-Deploy-Infrastructure-with-Terraform/README.md new file mode 100644 index 0000000..da1ba0a --- /dev/null +++ b/Labs/01-Deploy-Infrastructure-with-Terraform/README.md @@ -0,0 +1,121 @@ +
+ +

+ + cloudofthings + +

100 days in Cloud

+

+ Deploy infrastructure on AWS using Terraform +
+ Lab 1 +
+

+

+ +
+

Lab Details

+
    +
  1. Services covered +
  2. Lab description
  3. + +
  4. Lab date
  5. +
  6. Prerequisites
  7. +
  8. Lab steps
  9. +
  10. Lab files
  11. +
  12. Acknowledgements
  13. +
+
+ +--- + +## Services Covered +* ![terraform](https://github.com/CloudedThings/100-Days-in-Cloud/blob/main/images/terraform.png) **Terraform** +* ![ec2](https://github.com/CloudedThings/100-Days-in-Cloud/blob/main/images/AmazonEC2.png) **EC2** + +--- + +## Lab description +*You must modify an existing Terraform configuration to deploy a subnet within the Web VPC and provision an EC2 instance inside the subnet. Only t2.micro instances and volumes up to 10GBs are allowed in this lab challenge.* + +--- + +### Learning Objectives +:bulb: Create Terraform configuration + +--- + +### Lab date +30-12-2021 + +--- + +### Prerequisites +:cloud: AWS account + +:computer: EC2 Instance running or Terraform installed locally + + +--- + +### Lab steps +1. SSH into the **Development** EC2 instance (Shell or EC2 Instance Connect). + +2. Add to the existing `main.tf` file to configure the following: + + - Create a subnet resource in **Web VPC** + + - Create an EC2 instance into the newly created subnet within **Web VPC** + + That's how it looks pre: + + ![lab01_pre_main](img/lab01_pre_main.jpg) + +3. That's want it look afterwards: + +``` +provider "aws" { + version = "2.69" + + region = "us-west-2" # Oregon +} + +data "aws_availability_zones" "available" { + state = "available" +} + +resource "aws_vpc" "web_vpc" { + cidr_block = "192.168.100.0/24" + enable_dns_hostnames = true + + tags = { + Name = "Web VPC" + } +} + +resource "aws_subnet" "subnet1" { + vpc_id = aws_vpc.web_vpc.id + cidr_block = cidrsubnet(aws_vpc.web_vpc.cidr_block, 8, 1) + availability_zone = data.aws_availability_zones.available.names[0] +} + +resource "aws_instance" "web" { + ami = "ami-0528a5175983e7f28" + instance_type = "t2.micro" + subnet_id = aws_subnet.subnet1.id + root_block_device { + volume_size = "10" + } +} +``` + + + +### Lab files +* [main.tf](main.tf) + +--- + +### Acknowledgements +* [cloud academy](https://cloudacademy.com/lab-challenge/terraform-deploy-infrastructure-challenge/) + diff --git a/Labs/01-Deploy-Infrastructure-with-Terraform/img/lab01_diagram.jpg b/Labs/01-Deploy-Infrastructure-with-Terraform/img/lab01_diagram.jpg new file mode 100644 index 0000000..3124fa0 Binary files /dev/null and b/Labs/01-Deploy-Infrastructure-with-Terraform/img/lab01_diagram.jpg differ diff --git a/Labs/01-Deploy-Infrastructure-with-Terraform/img/lab01_pre_main.jpg b/Labs/01-Deploy-Infrastructure-with-Terraform/img/lab01_pre_main.jpg new file mode 100644 index 0000000..ddd750b Binary files /dev/null and b/Labs/01-Deploy-Infrastructure-with-Terraform/img/lab01_pre_main.jpg differ diff --git a/Labs/01-Deploy-Infrastructure-with-Terraform/main.tf b/Labs/01-Deploy-Infrastructure-with-Terraform/main.tf new file mode 100644 index 0000000..ee4dab9 --- /dev/null +++ b/Labs/01-Deploy-Infrastructure-with-Terraform/main.tf @@ -0,0 +1,33 @@ +provider "aws" { + version = "2.69" + + region = "us-west-2" # Oregon +} + +data "aws_availability_zones" "available" { + state = "available" +} + +resource "aws_vpc" "web_vpc" { + cidr_block = "192.168.100.0/24" + enable_dns_hostnames = true + + tags = { + Name = "Web VPC" + } +} + +resource "aws_subnet" "subnet1" { + vpc_id = aws_vpc.web_vpc.id + cidr_block = cidrsubnet(aws_vpc.web_vpc.cidr_block, 8, 1) + availability_zone = data.aws_availability_zones.available.names[0] +} + +resource "aws_instance" "web" { + ami = "ami-0528a5175983e7f28" + instance_type = "t2.micro" + subnet_id = aws_subnet.subnet1.id + root_block_device { + volume_size = "10" + } +} \ No newline at end of file