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

module 5 changes #46

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions 04-vpcs/exec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

PROFILE="fidelis"
STACK_NAME="fidelisEc2"
TEMPLATE="vpc-4-1-4.yaml"
PARAMETER="file://params.json"
KEY_NAME="fidelis"
REGION="us-east-1"

# deploy stack
# aws cloudformation deploy --template-file $TEMPLATE \
# --stack-name $STACK_NAME --profile $PROFILE \
# --parameter-overrides $PARAMETER \
# --region $REGION

# clean up
aws cloudformation delete-stack \
--stack-name $STACK_NAME \
--profile $PROFILE \
--region $REGION

# create ec2 keypair
# aws ec2 create-key-pair --key-name $KEY_NAME \
# --query 'KeyMaterial' \
# --region $REGION --profile $PROFILE \
# --output text > fidelis.pem
10 changes: 10 additions & 0 deletions 04-vpcs/params.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"Parameters": {
"VpcCIDR": "10.0.0.0/16",
"PublicSubnetCIDR": "10.0.0.0/24",
"PrivateSubnetCIDR": "10.0.1.0/24",
"AmiID": "ami-0cff7528ff583bf9a",
"InstanceType": "t2.micro",
"KeypairName": "fidelis"
}
}
56 changes: 56 additions & 0 deletions 04-vpcs/vpc-4-1-1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
AWSTemplateFormatVersion: "2010-09-09"

Description: CFN template to create VPC

# Metadata:

Parameters:
VpcCIDR:
Type: String
Description: The VPC CIDR block

Ec2SubnetCIDR:
Type: String
Description: The Ec2 subnet CIDR block

Resources:
VPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: !Ref VpcCIDR
EnableDnsSupport: true
EnableDnsHostnames: true
Tags:
- Key: Name
Value: !Join ['', [!Ref "AWS::StackName", "-VPC" ]]
- Key: User
Value: fidelis.ogunsanmi.labs
- Key: stelligent-u-lesson
Value: '4'
- Key: stelligent-u-lab
Value: 4-1-1

Ec2Subnet:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref VPC
CidrBlock: !Ref Ec2SubnetCIDR
AvailabilityZone: !Select [ 0, !GetAZs ]
Tags:
- Key: Name
Value: !Join ['', [!Ref "AWS::StackName", "-Ec2Subnet" ]]
- Key: User
Value: fidelis.ogunsanmi.labs
- Key: stelligent-u-lesson
Value: '4'
- Key: stelligent-u-lab
Value: 4-1-1

Outputs:
VpcID:
Description: The VPC ID
Value: !Ref VPC

Ec2SubnetID:
Description: The Ec2Subnet ID
Value: !Ref Ec2Subnet
103 changes: 103 additions & 0 deletions 04-vpcs/vpc-4-1-2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
AWSTemplateFormatVersion: "2010-09-09"

Description: CFN template to create VPC

# Metadata:

Parameters:
VpcCIDR:
Type: String
Description: The VPC CIDR block

PublicSubnetCIDR:
Type: String
Description: The Ec2 subnet CIDR block

Resources:
# Create VPC
VPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: !Ref VpcCIDR
EnableDnsSupport: true
EnableDnsHostnames: true
Tags:
- Key: Name
Value: !Join ['', [!Ref "AWS::StackName", "-VPC" ]]
- Key: User
Value: fidelis.ogunsanmi.labs
- Key: stelligent-u-lesson
Value: '4'
- Key: stelligent-u-lab
Value: 4-1-1

# Create Internet Gateway
InternetGateway:
Type: AWS::EC2::InternetGateway
Properties:
Tags:
- Key: Name
Value: Test IGW

# Attach Internet Gateway to VPC
InternetGatewayAttachment:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
InternetGatewayId: !Ref InternetGateway
VpcId: !Ref VPC

# Create Public Subnet
PublicSubnet:
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: !Select [ 0, !GetAZs ]
CidrBlock: !Ref PublicSubnetCIDR
MapPublicIpOnLaunch: true
VpcId: !Ref VPC
Tags:
- Key: Name
Value: !Join ['', [!Ref "AWS::StackName", "-PublicSubnet" ]]
- Key: User
Value: fidelis.ogunsanmi.labs
- Key: stelligent-u-lesson
Value: '4'
- Key: stelligent-u-lab
Value: 4-1-1

# Create Route Table
PublicRouteTable:
Type: AWS::EC2::RouteTable
Properties:
Tags:
- Key: Name
Value: !Join ['', [!Ref "AWS::StackName", "-PublicRouteTable" ]]
VpcId: !Ref VPC

# Add a Public Route to the Route Table
PublicRoute:
Type: AWS::EC2::Route
Properties:
DestinationCidrBlock: 0.0.0.0/0
GatewayId: !Ref InternetGateway
RouteTableId: !Ref PublicRouteTable

# Associate Public Subnet1 with Public Route Table
PublicSubnetRouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
RouteTableId: !Ref PublicRouteTable
SubnetId: !Ref PublicSubnet

Outputs:
VpcID:
Description: The VPC ID
Value: !Ref VPC
Export:
Name: !Join ['', [!Ref "AWS::StackName", "-VPC" ]]

PublicSubnetID:
Description: The Ec2Subnet ID
Value: !Ref PublicSubnet
Export:
Name: !Join ['', [!Ref "AWS::StackName", "-PublicSubnet" ]]

Loading