AWS Classroom Series – 14/Feb/2020

Exercise 6: Create Ec2 machine in web subnet and display the ip address as output

  • Instance type = t2.micro
  • Image => ubuntu
{
    "AWSTemplateFormatVersion": "2010-09-09",
    "Description": "Exercise-5",
    "Parameters": {
        "vpccidr": {
            "Description": "CIDR Range of VPC",
            "Type": "String",
            "Default": "192.168.0.0/16"
        },
        "websubnetcidr": {
            "Description": "CIDR Range of Web Subnet",
            "Type": "String",
            "Default": "192.168.0.0/24"
        },
        "dbsubnetcidr": {
            "Description": "CIDR Range of db Subnet",
            "Type": "String",
            "Default": "192.168.1.0/24"
        },
        "websubnetaz": {
            "Description": "AZ for web subnet",
            "Type": "AWS::EC2::AvailabilityZone::Name"
        },
        "dbsubnetaz": {
            "Description": "AZ for db subnet",
            "Type": "AWS::EC2::AvailabilityZone::Name"
        },
        "storagebucketname": {
            "Description": "Storage Bucket name",
            "Type": "String",
            "Default": "qts3fromclidemo1"
        },
        "keyvaluepair": {
            "Description": "Select the key value",
            "Type": "AWS::EC2::KeyPair::KeyName"
        },
        "securitygroup": {
            "Description": "Select Security Group",
            "Type": "AWS::EC2::SecurityGroup::GroupName"
        }
    },
    "Resources": {
        "myqtstorage": {
            "Type": "AWS::S3::Bucket",
            "Properties": {
                "AccessControl": "PublicRead",
                "BucketName": {
                    "Ref": "storagebucketname"
                }
            }
        },
        "myvpc": {
            "Type": "AWS::EC2::VPC",
            "Properties": {
                "CidrBlock": {
                    "Ref": "vpccidr"
                },
                "Tags": [
                    {
                        "Key": "Name",
                        "Value": "myvpc"
                    }
                ]
            }
        },
        "websubnet": {
            "Type": "AWS::EC2::Subnet",
            "Properties": {
                "AvailabilityZone": {
                    "Ref": "websubnetaz"
                },
                "VpcId": {
                    "Ref": "myvpc"
                },
                "CidrBlock": {
                    "Ref": "websubnetcidr"
                },
                "Tags": [
                    {
                        "Key": "Name",
                        "Value": "web"
                    }
                ]
            }
        },
        "dbsubnet": {
            "Type": "AWS::EC2::Subnet",
            "Properties": {
                "AvailabilityZone": {
                    "Ref": "dbsubnetaz"
                },
                "VpcId": {
                    "Ref": "myvpc"
                },
                "CidrBlock": {
                    "Ref": "dbsubnetcidr"
                },
                "Tags": [
                    {
                        "Key": "Name",
                        "Value": "db"
                    }
                ]
            }
        },
        "myweb": {
            "Type": "AWS::EC2::Instance",
            "Properties": {
                "KeyName": {
                    "Ref": "keyvaluepair"
                },
                "ImageId": "ami-0d1cd67c26f5fca19",
                "InstanceType": "t2.micro",
                "Tags": [
                    {
                        "Key": "Name",
                        "Value": "myweb"
                    }
                ],
                "NetworkInterfaces": [
                    {
                        "SubnetId": {
                            "Ref": "websubnet"
                        },
                        "DeviceIndex": "0"
                    },
                    {
                        "SubnetId": {
                            "Ref": "websubnet"
                        },
                        "DeviceIndex": "1"
                    }
                ]
            }
        }
        
    }
}

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Customized Social Media Icons from Acurax Digital Marketing Agency
Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube