You've already forked devops-exercises
Add different solutions to AWS exercises
Not only console solutions, but also Terraform and Pulumi. In addition, this change fixes issues #279 and #280
This commit is contained in:
@@ -2,7 +2,8 @@
|
||||
|
||||
### Requirements
|
||||
|
||||
Single newly created VPC
|
||||
1. Single newly created VPC
|
||||
2. Region with more than two availability zones
|
||||
|
||||
### Objectives
|
||||
|
||||
|
||||
27
topics/aws/exercises/subnets/pulumi/__main__.py
Normal file
27
topics/aws/exercises/subnets/pulumi/__main__.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import pulumi
|
||||
import pulumi_aws as aws
|
||||
|
||||
availableZones = pulumi_aws.get_availability_zones(state="available")
|
||||
|
||||
aws.ec2.Subnet("NewSubnet1",
|
||||
vpc_id=aws_vpc["main"]["id"],
|
||||
cidr_block="10.0.0.0/24",
|
||||
availability_zone=availableZones.names[0],
|
||||
tags={"Name": "NewSubnet1"}
|
||||
)
|
||||
|
||||
aws.ec2.Subnet("NewSubnet2",
|
||||
vpc_id=aws_vpc["main"]["id"],
|
||||
cidr_block="10.0.1.0/24",
|
||||
availability_zone=availableZones.names[1]
|
||||
tags={"Name": "NewSubnet2"}
|
||||
)
|
||||
|
||||
aws.ec2.Subnet("NewSubnet3",
|
||||
vpc_id=aws_vpc["main"]["id"],
|
||||
cidr_block="10.0.2.0/24",
|
||||
availability_zone=availableZones.names[2]
|
||||
tags={"Name": "NewSubnet3"}
|
||||
)
|
||||
|
||||
# Run "pulumi up"
|
||||
@@ -1,26 +1,27 @@
|
||||
## AWS VPC - Subnets
|
||||
# AWS VPC - Subnets
|
||||
|
||||
### Requirements
|
||||
## Requirements
|
||||
|
||||
Single newly created VPC
|
||||
1. Single newly created VPC
|
||||
2. Region with more than two availability zones
|
||||
|
||||
### Objectives
|
||||
## Objectives
|
||||
|
||||
1. Create a subnet in your newly created VPC
|
||||
1. CIDR: 10.0.0.0/24
|
||||
2. Name: NewSubnet1
|
||||
1. CIDR: 10.0.0.0/24
|
||||
1. Name: NewSubnet1
|
||||
2. Create additional subnet
|
||||
1. CIDR: 10.0.1.0/24
|
||||
2. Name: NewSubnet2
|
||||
3. Different AZ compared to previous subnet
|
||||
1. CIDR: 10.0.1.0/24
|
||||
2. Name: NewSubnet2
|
||||
3. Different AZ compared to previous subnet
|
||||
3. Create additional subnet
|
||||
1. CIDR: 10.0.2.0/24
|
||||
2. Name: NewSubnet3
|
||||
3. Different AZ compared to previous subnets
|
||||
4. CIDR: 10.0.2.0/24
|
||||
5. Name: NewSubnet3
|
||||
6. Different AZ compared to previous subnets
|
||||
|
||||
### Solution
|
||||
## Solution
|
||||
|
||||
#### Console
|
||||
### Console
|
||||
|
||||
1. Click on "Subnets" under "Virtual Private Cloud"
|
||||
2. Make sure you filter by your newly created VPC (to not see the subnets in all other VPCs). You can do this in the left side menu
|
||||
@@ -37,3 +38,11 @@ Single newly created VPC
|
||||
13. Set the subnet name to "NewSubnet3"
|
||||
14. Choose a different AZ
|
||||
15. Set CIDR to 10.0.2.0/24
|
||||
|
||||
### Terraform
|
||||
|
||||
Click [here](terraform/main.tf) to view the solution
|
||||
|
||||
### Pulumi - Python
|
||||
|
||||
Click [here](pulumi/__main__.py) to view the solution
|
||||
49
topics/aws/exercises/subnets/terraform/main.tf
Normal file
49
topics/aws/exercises/subnets/terraform/main.tf
Normal file
@@ -0,0 +1,49 @@
|
||||
# Variables
|
||||
|
||||
variable "vpc_id" {
|
||||
type = string
|
||||
}
|
||||
|
||||
# AWS Subnets
|
||||
|
||||
resource "aws_subnet" "NewSubnet1" {
|
||||
cidr_block = "10.0.0.0/24"
|
||||
vpc_id = var.vpc_id
|
||||
availability_zone = data.aws_availability_zones.all.names[0]
|
||||
tags = {
|
||||
Purpose: exercise
|
||||
Name: "NewSubnet1"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_subnet" "NewSubnet2" {
|
||||
cidr_block = "10.0.1.0/24"
|
||||
vpc_id = var.vpc_id
|
||||
availability_zone = data.aws_availability_zones.all.names[1]
|
||||
tags = {
|
||||
Purpose: exercise
|
||||
Name: "NewSubnet2"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_subnet" "NewSubnet3" {
|
||||
cidr_block = "10.0.2.0/24"
|
||||
vpc_id = var.vpc_id
|
||||
availability_zone = data.aws_availability_zones.all.names[2]
|
||||
tags = {
|
||||
Purpose: exercise
|
||||
Name: "NewSubnet3"
|
||||
}
|
||||
}
|
||||
|
||||
# Outputs
|
||||
|
||||
output "NewSubnet1-id" {
|
||||
value = aws_subnet.NewSubnet1.id
|
||||
}
|
||||
output "NewSubnet2-id" {
|
||||
value = aws_subnet.NewSubnet2.id
|
||||
}
|
||||
output "NewSubnet3-id" {
|
||||
value = aws_subnet.NewSubnet3.id
|
||||
}
|
||||
Reference in New Issue
Block a user