Test/Cloud

AWS CloudFormation template

kiostory 2019. 5. 30. 15:23



template1-designer.png






* JSON


{
    "AWSTemplateFormatVersion": "2010-09-09",
    "Description": "Lab template",
    "Resources": {
        "VPC": {
            "Type": "AWS::EC2::VPC",
            "Properties": {
                "CidrBlock": "10.0.0.0/20",
                "EnableDnsSupport": true,
                "EnableDnsHostnames": true,
                "Tags": [
                    {
                        "Key": "Name",
                        "Value": "Lab VPC"
                    }
                ]
            },
            "Metadata": {
                "AWS::CloudFormation::Designer": {
                    "id": "157db3f5-4073-401e-8966-3fd1e9e71305"
                }
            }
        },
        "IGW": {
            "Type": "AWS::EC2::InternetGateway",
            "Properties": {
                "Tags": [
                    {
                        "Key": "Name",
                        "Value": "Lab IG"
                    }
                ]
            },
            "Metadata": {
                "AWS::CloudFormation::Designer": {
                    "id": "06fe38c1-3999-48ff-bf87-144303a2ee76"
                }
            }
        },
        "VPCtoIGWConnection": {
            "Type": "AWS::EC2::VPCGatewayAttachment",
            "DependsOn": [
                "IGW",
                "VPC"
            ],
            "Properties": {
                "InternetGatewayId": {
                    "Ref": "IGW"
                },
                "VpcId": {
                    "Ref": "VPC"
                }
            },
            "Metadata": {
                "AWS::CloudFormation::Designer": {
                    "id": "38f66d8e-a8cb-4d60-936f-e21e3fd7a45c"
                }
            }
        },
        "PublicRouteTable": {
            "Type": "AWS::EC2::RouteTable",
            "DependsOn": "VPC",
            "Properties": {
                "VpcId": {
                    "Ref": "VPC"
                },
                "Tags": [
                    {
                        "Key": "Name",
                        "Value": "Public Route Table"
                    }
                ]
            },
            "Metadata": {
                "AWS::CloudFormation::Designer": {
                    "id": "1c3e3640-6fd2-450a-8ea8-e4226df1af13"
                }
            }
        },
        "PublicRoute": {
            "Type": "AWS::EC2::Route",
            "DependsOn": [
                "PublicRouteTable",
                "VPCtoIGWConnection"
            ],
            "Properties": {
                "DestinationCidrBlock": "0.0.0.0/0",
                "GatewayId": {
                    "Ref": "IGW"
                },
                "RouteTableId": {
                    "Ref": "PublicRouteTable"
                }
            },
            "Metadata": {
                "AWS::CloudFormation::Designer": {
                    "id": "9bd11e9b-bb52-4b0f-8fee-2d9651b1b1d9"
                }
            }
        },
        "PrivateRouteTable": {
            "Type": "AWS::EC2::RouteTable",
            "DependsOn": "VPC",
            "Properties": {
                "VpcId": {
                    "Ref": "VPC"
                },
                "Tags": [
                    {
                        "Key": "Name",
                        "Value": "Private Route Table 1"
                    }
                ]
            },
            "Metadata": {
                "AWS::CloudFormation::Designer": {
                    "id": "2d1cce8b-dd91-456c-ba10-69d56f57573d"
                }
            }
        },
        "PublicSubnet1": {
            "Type": "AWS::EC2::Subnet",
            "DependsOn": "VPC",
            "Properties": {
                "VpcId": {
                    "Ref": "VPC"
                },
                "MapPublicIpOnLaunch": true,
                "CidrBlock": "10.0.0.0/24",
                "AvailabilityZone": {
                    "Fn::Select": [
                        0,
                        {
                            "Fn::GetAZs": {
                                "Ref": "AWS::Region"
                            }
                        }
                    ]
                },
                "Tags": [
                    {
                        "Key": "Name",
                        "Value": "Public Subnet 1"
                    }
                ]
            },
            "Metadata": {
                "AWS::CloudFormation::Designer": {
                    "id": "0e359b90-3cec-43bd-b8f4-494db89babb7"
                }
            }
        },
        "PublicSubnet2": {
            "Type": "AWS::EC2::Subnet",
            "DependsOn": "VPC",
            "Properties": {
                "VpcId": {
                    "Ref": "VPC"
                },
                "MapPublicIpOnLaunch": true,
                "CidrBlock": "10.0.1.0/24",
                "AvailabilityZone": {
                    "Fn::Select": [
                        1,
                        {
                            "Fn::GetAZs": {
                                "Ref": "AWS::Region"
                            }
                        }
                    ]
                },
                "Tags": [
                    {
                        "Key": "Name",
                        "Value": "Public Subnet 2"
                    }
                ]
            },
            "Metadata": {
                "AWS::CloudFormation::Designer": {
                    "id": "b53d7efb-08c8-41d4-8ceb-0de7da3ab8ca"
                }
            }
        },
        "PublicRouteTableAssociation1": {
            "Type": "AWS::EC2::SubnetRouteTableAssociation",
            "DependsOn": [
                "PublicRouteTable",
                "PublicSubnet1"
            ],
            "Properties": {
                "RouteTableId": {
                    "Ref": "PublicRouteTable"
                },
                "SubnetId": {
                    "Ref": "PublicSubnet1"
                }
            },
            "Metadata": {
                "AWS::CloudFormation::Designer": {
                    "id": "3ca6c48e-fea3-4e90-89f1-307fab42ee31"
                }
            }
        },
        "PublicRouteTableAssociation2": {
            "Type": "AWS::EC2::SubnetRouteTableAssociation",
            "DependsOn": [
                "PublicRouteTable",
                "PublicSubnet2"
            ],
            "Properties": {
                "RouteTableId": {
                    "Ref": "PublicRouteTable"
                },
                "SubnetId": {
                    "Ref": "PublicSubnet2"
                }
            },
            "Metadata": {
                "AWS::CloudFormation::Designer": {
                    "id": "8cfc0dee-6e23-460d-8aa8-a1370ee74b87"
                }
            }
        },
        "PrivateSubnet1": {
            "Type": "AWS::EC2::Subnet",
            "DependsOn": "VPC",
            "Properties": {
                "VpcId": {
                    "Ref": "VPC"
                },
                "CidrBlock": "10.0.2.0/23",
                "AvailabilityZone": {
                    "Fn::Select": [
                        0,
                        {
                            "Fn::GetAZs": {
                                "Ref": "AWS::Region"
                            }
                        }
                    ]
                },
                "Tags": [
                    {
                        "Key": "Name",
                        "Value": "Private Subnet 1"
                    }
                ]
            },
            "Metadata": {
                "AWS::CloudFormation::Designer": {
                    "id": "d123a642-4a21-4158-96d3-f409f63a091e"
                }
            }
        },
        "PrivateSubnet2": {
            "Type": "AWS::EC2::Subnet",
            "DependsOn": "VPC",
            "Properties": {
                "VpcId": {
                    "Ref": "VPC"
                },
                "CidrBlock": "10.0.4.0/23",
                "AvailabilityZone": {
                    "Fn::Select": [
                        1,
                        {
                            "Fn::GetAZs": {
                                "Ref": "AWS::Region"
                            }
                        }
                    ]
                },
                "Tags": [
                    {
                        "Key": "Name",
                        "Value": "Private Subnet 2"
                    }
                ]
            },
            "Metadata": {
                "AWS::CloudFormation::Designer": {
                    "id": "321926b4-235b-4fa6-8f84-00199d7e8078"
                }
            }
        },
        "PrivateRouteTableAssociation1": {
            "Type": "AWS::EC2::SubnetRouteTableAssociation",
            "DependsOn": [
                "PrivateRouteTable",
                "PrivateSubnet1"
            ],
            "Properties": {
                "RouteTableId": {
                    "Ref": "PrivateRouteTable"
                },
                "SubnetId": {
                    "Ref": "PrivateSubnet1"
                }
            },
            "Metadata": {
                "AWS::CloudFormation::Designer": {
                    "id": "0ce27531-eb00-4e6c-a6a9-170a7654c97b"
                }
            }
        },
        "PrivateRouteTableAssociation2": {
            "Type": "AWS::EC2::SubnetRouteTableAssociation",
            "DependsOn": [
                "PrivateRouteTable",
                "PrivateSubnet2"
            ],
            "Properties": {
                "RouteTableId": {
                    "Ref": "PrivateRouteTable"
                },
                "SubnetId": {
                    "Ref": "PrivateSubnet2"
                }
            },
            "Metadata": {
                "AWS::CloudFormation::Designer": {
                    "id": "bafb60c3-585d-4de6-ba5a-4c1953682dc2"
                }
            }
        },
        "NATGateway": {
            "DependsOn": "PrivateSubnet1",
            "Type": "AWS::EC2::NatGateway",
            "Properties": {
                "SubnetId": {
                    "Ref": "PublicSubnet1"
                },
                "AllocationId": {
                    "Fn::GetAtt": [
                        "NATGatewayEIP",
                        "AllocationId"
                    ]
                }
            },
            "Metadata": {
                "AWS::CloudFormation::Designer": {
                    "id": "96f51360-5805-47e6-ae44-f07399ddbd13"
                }
            }
        },
        "NATGatewayEIP": {
            "Type": "AWS::EC2::EIP",
            "Properties": {
                "Domain": "vpc"
            },
            "Metadata": {
                "AWS::CloudFormation::Designer": {
                    "id": "359e70b3-fa6c-4139-a1b9-0caffbd1bde6"
                }
            }
        },
        "NATGatewayRoute": {
            "Type": "AWS::EC2::Route",
            "Properties": {
                "RouteTableId": {
                    "Ref": "PrivateRouteTable"
                },
                "DestinationCidrBlock": "0.0.0.0/0",
                "NatGatewayId": {
                    "Ref": "NATGateway"
                }
            },
            "Metadata": {
                "AWS::CloudFormation::Designer": {
                    "id": "9f098b89-9397-45b2-9589-c7ed802def3f"
                }
            }
        },
        "InstanceProfile": {
            "Type": "AWS::IAM::InstanceProfile",
            "Properties": {
                "Path": "/",
                "Roles": [
                    {
                        "Ref": "AppRole"
                    }
                ],
                "InstanceProfileName": "Inventory-App-Role"
            },
            "Metadata": {
                "AWS::CloudFormation::Designer": {
                    "id": "98bfadc4-91a1-469c-95a0-782708eec092"
                }
            }
        },
        "AppRole": {
            "Type": "AWS::IAM::Role",
            "Properties": {
                "RoleName": "Inventory-App-Role",
                "AssumeRolePolicyDocument": {
                    "Version": "2012-10-17",
                    "Statement": [
                        {
                            "Effect": "Allow",
                            "Principal": {
                                "Service": [
                                    "ec2.amazonaws.com"
                                ]
                            },
                            "Action": [
                                "sts:AssumeRole"
                            ]
                        }
                    ]
                },
                "Path": "/",
                "Policies": [
                    {
                        "PolicyName": "root",
                        "PolicyDocument": {
                            "Version": "2012-10-17",
                            "Statement": [
                                {
                                    "Effect": "Allow",
                                    "Action": "ssm:*",
                                    "Resource": "*"
                                }
                            ]
                        }
                    }
                ]
            },
            "Metadata": {
                "AWS::CloudFormation::Designer": {
                    "id": "c01117f4-051c-4394-9fa3-7911beb8d4fa"
                }
            }
        },
        "AppSecurityGroup": {
            "Type": "AWS::EC2::SecurityGroup",
            "DependsOn": "VPC",
            "Properties": {
                "GroupName": "Inventory-App",
                "GroupDescription": "Enable access to App",
                "VpcId": {
                    "Ref": "VPC"
                },
                "Tags": [
                    {
                        "Key": "Name",
                        "Value": "Inventory-App"
                    }
                ]
            },
            "Metadata": {
                "AWS::CloudFormation::Designer": {
                    "id": "f6ac4a15-8ed1-42a2-a6b3-1f08ad522e65"
                }
            }
        },
        "DBSubnetGroup": {
            "Type": "AWS::RDS::DBSubnetGroup",
            "Properties": {
                "DBSubnetGroupDescription": "Lab-DB-Subnet-Group",
                "DBSubnetGroupName": "Lab-DB-Subnet-Group",
                "SubnetIds": [
                    {
                        "Ref": "PrivateSubnet1"
                    },
                    {
                        "Ref": "PrivateSubnet2"
                    }
                ],
                "Tags": [
                    {
                        "Key": "Name",
                        "Value": "DBSubnetGroup"
                    }
                ]
            },
            "Metadata": {
                "AWS::CloudFormation::Designer": {
                    "id": "bb6f6f4c-2997-4c80-abea-79744dd94beb"
                }
            }
        },
        "DBSecurityGroup": {
            "Type": "AWS::EC2::SecurityGroup",
            "DependsOn": "VPC",
            "Properties": {
                "GroupName": "Inventory-DB",
                "GroupDescription": "Enable access to MySQL",
                "VpcId": {
                    "Ref": "VPC"
                },
                "SecurityGroupIngress": [
                    {
                        "IpProtocol": "tcp",
                        "FromPort": 3306,
                        "ToPort": 3306,
                        "CidrIp": "10.0.0.0/20"
                    }
                ],
                "Tags": [
                    {
                        "Key": "Name",
                        "Value": "Inventory-DB"
                    }
                ]
            },
            "Metadata": {
                "AWS::CloudFormation::Designer": {
                    "id": "dde20abd-9a9e-4e68-95b2-f476c87b1b0d"
                }
            }
        },
        "RDSDatabase": {
            "Type": "AWS::RDS::DBInstance",
            "Properties": {
                "DBName": "inventory",
                "DBInstanceIdentifier": "inventory-db",
                "AllocatedStorage": 5,
                "DBInstanceClass": "db.t2.micro",
                "Engine": "MySQL",
                "MasterUsername": "master",
                "MasterUserPassword": "lab-password",
                "MultiAZ": false,
                "DBSubnetGroupName": {
                    "Ref": "DBSubnetGroup"
                },
                "VPCSecurityGroups": [
                    {
                        "Ref": "DBSecurityGroup"
                    }
                ],
                "Tags": [
                    {
                        "Key": "Name",
                        "Value": "inventory-db"
                    }
                ]
            },
            "Metadata": {
                "AWS::CloudFormation::Designer": {
                    "id": "20d10aa8-af1e-4637-a2d5-34580fa2cb2d"
                }
            }
        },
        "LambdaClearParameters": {
            "Type": "AWS::Lambda::Function",
            "Properties": {
                "FunctionName": "Clear-parameter-store",
                "Handler": "clear-parameter-store.handler",
                "MemorySize": 128,
                "Timeout": 300,
                "Role": {
                    "Fn::Sub": "${LambdaVPCRole.Arn}"
                },
                "Code": {
                    "S3Bucket": {
                        "Fn::Sub": "${AWS::Region}-tcprod"
                    },
                    "S3Key": "courses/ILT-TF-100-ARCHIT/v6.3.6/lab-2-webapp/scripts/clear-parameter-store.zip"
                },
                "Runtime": "python2.7"
            },
            "Metadata": {
                "AWS::CloudFormation::Designer": {
                    "id": "05599c98-d0da-4eea-a9a2-8886db9c3386"
                }
            }
        },
        "CustomClearParameters": {
            "Type": "Custom::CustomClearParameters",
            "Properties": {
                "ServiceToken": {
                    "Fn::Sub": "${LambdaClearParameters.Arn}"
                }
            },
            "Metadata": {
                "AWS::CloudFormation::Designer": {
                    "id": "779bb41f-4a98-4c65-a7b3-f6d3ac6c5d9c"
                }
            }
        },
        "LambdaVPCRole": {
            "Type": "AWS::IAM::Role",
            "Properties": {
                "AssumeRolePolicyDocument": {
                    "Version": "2012-10-17",
                    "Statement": [
                        {
                            "Effect": "Allow",
                            "Principal": {
                                "Service": [
                                    "lambda.amazonaws.com"
                                ]
                            },
                            "Action": [
                                "sts:AssumeRole"
                            ]
                        }
                    ]
                },
                "Policies": [
                    {
                        "PolicyName": "SSMCleanup",
                        "PolicyDocument": {
                            "Version": "2012-10-17",
                            "Statement": [
                                {
                                    "Effect": "Allow",
                                    "Action": [
                                        "ssm:*",
                                        "ec2:Describe*",
                                        "logs:CreateLogGroup",
                                        "logs:CreateLogStream",
                                        "logs:PutLogEvents"
                                    ],
                                    "Resource": "*"
                                }
                            ]
                        }
                    }
                ]
            },
            "Metadata": {
                "AWS::CloudFormation::Designer": {
                    "id": "891d19e2-43f1-40a3-bd0b-c5e75f7cc4b8"
                }
            }
        }
    },
    "Outputs": {
        "Endpoint": {
            "Value": {
                "Fn::GetAtt": [
                    "RDSDatabase",
                    "Endpoint.Address"
                ]
            },
            "Description": "Database endpoint"
        },
        "PublicSubnet2": {
            "Value": {
                "Ref": "PublicSubnet2"
            },
            "Description": "PublicSubnet2"
        },
        "NATGateway1": {
            "Value": {
                "Ref": "NATGateway"
            },
            "Description": "NATGateway1"
        }
    },
    "Metadata": {
        "AWS::CloudFormation::Designer": {
            "891d19e2-43f1-40a3-bd0b-c5e75f7cc4b8": {
                "size": {
                    "width": 60,
                    "height": 60
                },
                "position": {
                    "x": 990,
                    "y": 90
                },
                "z": 1,
                "embeds": []
            },
            "779bb41f-4a98-4c65-a7b3-f6d3ac6c5d9c": {
                "size": {
                    "width": 60,
                    "height": 60
                },
                "position": {
                    "x": 1110,
                    "y": 90
                },
                "z": 1,
                "embeds": []
            },
            "05599c98-d0da-4eea-a9a2-8886db9c3386": {
                "size": {
                    "width": 60,
                    "height": 60
                },
                "position": {
                    "x": 990,
                    "y": 210
                },
                "z": 1,
                "embeds": []
            },
            "c01117f4-051c-4394-9fa3-7911beb8d4fa": {
                "size": {
                    "width": 60,
                    "height": 60
                },
                "position": {
                    "x": 1110,
                    "y": 210
                },
                "z": 1,
                "embeds": []
            },
            "98bfadc4-91a1-469c-95a0-782708eec092": {
                "size": {
                    "width": 60,
                    "height": 60
                },
                "position": {
                    "x": 990,
                    "y": 330
                },
                "z": 1,
                "embeds": [],
                "isassociatedwith": [
                    "c01117f4-051c-4394-9fa3-7911beb8d4fa"
                ]
            },
            "359e70b3-fa6c-4139-a1b9-0caffbd1bde6": {
                "size": {
                    "width": 60,
                    "height": 60
                },
                "position": {
                    "x": 1110,
                    "y": 330
                },
                "z": 1,
                "embeds": []
            },
            "06fe38c1-3999-48ff-bf87-144303a2ee76": {
                "size": {
                    "width": 60,
                    "height": 60
                },
                "position": {
                    "x": 990,
                    "y": 450
                },
                "z": 1,
                "embeds": []
            },
            "157db3f5-4073-401e-8966-3fd1e9e71305": {
                "size": {
                    "width": 870,
                    "height": 780
                },
                "position": {
                    "x": 50,
                    "y": 180
                },
                "z": 1,
                "embeds": [
                    "dde20abd-9a9e-4e68-95b2-f476c87b1b0d",
                    "f6ac4a15-8ed1-42a2-a6b3-1f08ad522e65",
                    "321926b4-235b-4fa6-8f84-00199d7e8078",
                    "d123a642-4a21-4158-96d3-f409f63a091e",
                    "b53d7efb-08c8-41d4-8ceb-0de7da3ab8ca",
                    "0e359b90-3cec-43bd-b8f4-494db89babb7",
                    "2d1cce8b-dd91-456c-ba10-69d56f57573d",
                    "1c3e3640-6fd2-450a-8ea8-e4226df1af13"
                ]
            },
            "dde20abd-9a9e-4e68-95b2-f476c87b1b0d": {
                "size": {
                    "width": 60,
                    "height": 60
                },
                "position": {
                    "x": 380,
                    "y": 750
                },
                "z": 2,
                "parent": "157db3f5-4073-401e-8966-3fd1e9e71305",
                "embeds": [],
                "dependson": [
                    "157db3f5-4073-401e-8966-3fd1e9e71305"
                ]
            },
            "f6ac4a15-8ed1-42a2-a6b3-1f08ad522e65": {
                "size": {
                    "width": 60,
                    "height": 60
                },
                "position": {
                    "x": 500,
                    "y": 750
                },
                "z": 2,
                "parent": "157db3f5-4073-401e-8966-3fd1e9e71305",
                "embeds": [],
                "dependson": [
                    "157db3f5-4073-401e-8966-3fd1e9e71305"
                ]
            },
            "321926b4-235b-4fa6-8f84-00199d7e8078": {
                "size": {
                    "width": 150,
                    "height": 150
                },
                "position": {
                    "x": 680,
                    "y": 240
                },
                "z": 2,
                "parent": "157db3f5-4073-401e-8966-3fd1e9e71305",
                "embeds": [],
                "dependson": [
                    "157db3f5-4073-401e-8966-3fd1e9e71305"
                ]
            },
            "d123a642-4a21-4158-96d3-f409f63a091e": {
                "size": {
                    "width": 150,
                    "height": 150
                },
                "position": {
                    "x": 590,
                    "y": 540
                },
                "z": 2,
                "parent": "157db3f5-4073-401e-8966-3fd1e9e71305",
                "embeds": [],
                "dependson": [
                    "157db3f5-4073-401e-8966-3fd1e9e71305"
                ]
            },
            "bb6f6f4c-2997-4c80-abea-79744dd94beb": {
                "size": {
                    "width": 240,
                    "height": 240
                },
                "position": {
                    "x": 60,
                    "y": 930
                },
                "z": 1,
                "embeds": [
                    "20d10aa8-af1e-4637-a2d5-34580fa2cb2d"
                ],
                "iscontainedinside": [
                    "d123a642-4a21-4158-96d3-f409f63a091e",
                    "321926b4-235b-4fa6-8f84-00199d7e8078"
                ]
            },
            "20d10aa8-af1e-4637-a2d5-34580fa2cb2d": {
                "size": {
                    "width": 60,
                    "height": 60
                },
                "position": {
                    "x": 90,
                    "y": 990
                },
                "z": 2,
                "parent": "bb6f6f4c-2997-4c80-abea-79744dd94beb",
                "embeds": [],
                "isassociatedwith": [
                    "dde20abd-9a9e-4e68-95b2-f476c87b1b0d"
                ],
                "iscontainedinside": [
                    "bb6f6f4c-2997-4c80-abea-79744dd94beb"
                ]
            },
            "b53d7efb-08c8-41d4-8ceb-0de7da3ab8ca": {
                "size": {
                    "width": 150,
                    "height": 150
                },
                "position": {
                    "x": 380,
                    "y": 540
                },
                "z": 2,
                "parent": "157db3f5-4073-401e-8966-3fd1e9e71305",
                "embeds": [],
                "dependson": [
                    "157db3f5-4073-401e-8966-3fd1e9e71305"
                ]
            },
            "0e359b90-3cec-43bd-b8f4-494db89babb7": {
                "size": {
                    "width": 240,
                    "height": 240
                },
                "position": {
                    "x": 80,
                    "y": 540
                },
                "z": 2,
                "parent": "157db3f5-4073-401e-8966-3fd1e9e71305",
                "embeds": [
                    "96f51360-5805-47e6-ae44-f07399ddbd13"
                ],
                "dependson": [
                    "157db3f5-4073-401e-8966-3fd1e9e71305"
                ]
            },
            "96f51360-5805-47e6-ae44-f07399ddbd13": {
                "size": {
                    "width": 60,
                    "height": 60
                },
                "position": {
                    "x": 110,
                    "y": 600
                },
                "z": 3,
                "parent": "0e359b90-3cec-43bd-b8f4-494db89babb7",
                "embeds": [],
                "iscontainedinside": [
                    "0e359b90-3cec-43bd-b8f4-494db89babb7"
                ],
                "dependson": [
                    "d123a642-4a21-4158-96d3-f409f63a091e"
                ]
            },
            "2d1cce8b-dd91-456c-ba10-69d56f57573d": {
                "size": {
                    "width": 240,
                    "height": 240
                },
                "position": {
                    "x": 380,
                    "y": 240
                },
                "z": 2,
                "parent": "157db3f5-4073-401e-8966-3fd1e9e71305",
                "embeds": [
                    "9f098b89-9397-45b2-9589-c7ed802def3f"
                ],
                "dependson": [
                    "157db3f5-4073-401e-8966-3fd1e9e71305"
                ]
            },
            "9f098b89-9397-45b2-9589-c7ed802def3f": {
                "size": {
                    "width": 60,
                    "height": 60
                },
                "position": {
                    "x": 410,
                    "y": 300
                },
                "z": 3,
                "parent": "2d1cce8b-dd91-456c-ba10-69d56f57573d",
                "embeds": [],
                "isassociatedwith": [
                    "96f51360-5805-47e6-ae44-f07399ddbd13"
                ],
                "iscontainedinside": [
                    "2d1cce8b-dd91-456c-ba10-69d56f57573d"
                ]
            },
            "bafb60c3-585d-4de6-ba5a-4c1953682dc2": {
                "source": {
                    "id": "2d1cce8b-dd91-456c-ba10-69d56f57573d"
                },
                "target": {
                    "id": "321926b4-235b-4fa6-8f84-00199d7e8078"
                }
            },
            "0ce27531-eb00-4e6c-a6a9-170a7654c97b": {
                "source": {
                    "id": "2d1cce8b-dd91-456c-ba10-69d56f57573d"
                },
                "target": {
                    "id": "d123a642-4a21-4158-96d3-f409f63a091e"
                }
            },
            "1c3e3640-6fd2-450a-8ea8-e4226df1af13": {
                "size": {
                    "width": 240,
                    "height": 240
                },
                "position": {
                    "x": 80,
                    "y": 240
                },
                "z": 2,
                "parent": "157db3f5-4073-401e-8966-3fd1e9e71305",
                "embeds": [
                    "9bd11e9b-bb52-4b0f-8fee-2d9651b1b1d9"
                ],
                "dependson": [
                    "157db3f5-4073-401e-8966-3fd1e9e71305"
                ]
            },
            "8cfc0dee-6e23-460d-8aa8-a1370ee74b87": {
                "source": {
                    "id": "1c3e3640-6fd2-450a-8ea8-e4226df1af13"
                },
                "target": {
                    "id": "b53d7efb-08c8-41d4-8ceb-0de7da3ab8ca"
                }
            },
            "3ca6c48e-fea3-4e90-89f1-307fab42ee31": {
                "source": {
                    "id": "1c3e3640-6fd2-450a-8ea8-e4226df1af13"
                },
                "target": {
                    "id": "0e359b90-3cec-43bd-b8f4-494db89babb7"
                }
            },
            "38f66d8e-a8cb-4d60-936f-e21e3fd7a45c": {
                "source": {
                    "id": "157db3f5-4073-401e-8966-3fd1e9e71305"
                },
                "target": {
                    "id": "06fe38c1-3999-48ff-bf87-144303a2ee76"
                }
            },
            "9bd11e9b-bb52-4b0f-8fee-2d9651b1b1d9": {
                "size": {
                    "width": 60,
                    "height": 60
                },
                "position": {
                    "x": 110,
                    "y": 300
                },
                "z": 3,
                "parent": "1c3e3640-6fd2-450a-8ea8-e4226df1af13",
                "embeds": [],
                "isassociatedwith": [
                    "06fe38c1-3999-48ff-bf87-144303a2ee76"
                ],
                "dependson": [
                    "1c3e3640-6fd2-450a-8ea8-e4226df1af13",
                    "38f66d8e-a8cb-4d60-936f-e21e3fd7a45c"
                ]
            }
        }
    }
}








* YAML


AWSTemplateFormatVersion: 2010-09-09
Description: Lab template
Resources:
  VPC:
    Type: 'AWS::EC2::VPC'
    Properties:
      CidrBlock: 10.0.0.0/20
      EnableDnsSupport: true
      EnableDnsHostnames: true
      Tags:
        - Key: Name
          Value: Lab VPC
    Metadata:
      'AWS::CloudFormation::Designer':
        id: 157db3f5-4073-401e-8966-3fd1e9e71305
  IGW:
    Type: 'AWS::EC2::InternetGateway'
    Properties:
      Tags:
        - Key: Name
          Value: Lab IG
    Metadata:
      'AWS::CloudFormation::Designer':
        id: 06fe38c1-3999-48ff-bf87-144303a2ee76
  VPCtoIGWConnection:
    Type: 'AWS::EC2::VPCGatewayAttachment'
    DependsOn:
      - IGW
      - VPC
    Properties:
      InternetGatewayId: !Ref IGW
      VpcId: !Ref VPC
    Metadata:
      'AWS::CloudFormation::Designer':
        id: 38f66d8e-a8cb-4d60-936f-e21e3fd7a45c
  PublicRouteTable:
    Type: 'AWS::EC2::RouteTable'
    DependsOn: VPC
    Properties:
      VpcId: !Ref VPC
      Tags:
        - Key: Name
          Value: Public Route Table
    Metadata:
      'AWS::CloudFormation::Designer':
        id: 1c3e3640-6fd2-450a-8ea8-e4226df1af13
  PublicRoute:
    Type: 'AWS::EC2::Route'
    DependsOn:
      - PublicRouteTable
      - VPCtoIGWConnection
    Properties:
      DestinationCidrBlock: 0.0.0.0/0
      GatewayId: !Ref IGW
      RouteTableId: !Ref PublicRouteTable
    Metadata:
      'AWS::CloudFormation::Designer':
        id: 9bd11e9b-bb52-4b0f-8fee-2d9651b1b1d9
  PrivateRouteTable:
    Type: 'AWS::EC2::RouteTable'
    DependsOn: VPC
    Properties:
      VpcId: !Ref VPC
      Tags:
        - Key: Name
          Value: Private Route Table 1
    Metadata:
      'AWS::CloudFormation::Designer':
        id: 2d1cce8b-dd91-456c-ba10-69d56f57573d
  PublicSubnet1:
    Type: 'AWS::EC2::Subnet'
    DependsOn: VPC
    Properties:
      VpcId: !Ref VPC
      MapPublicIpOnLaunch: true
      CidrBlock: 10.0.0.0/24
      AvailabilityZone: !Select
        - 0
        - !GetAZs
          Ref: 'AWS::Region'
      Tags:
        - Key: Name
          Value: Public Subnet 1
    Metadata:
      'AWS::CloudFormation::Designer':
        id: 0e359b90-3cec-43bd-b8f4-494db89babb7
  PublicSubnet2:
    Type: 'AWS::EC2::Subnet'
    DependsOn: VPC
    Properties:
      VpcId: !Ref VPC
      MapPublicIpOnLaunch: true
      CidrBlock: 10.0.1.0/24
      AvailabilityZone: !Select
        - 1
        - !GetAZs
          Ref: 'AWS::Region'
      Tags:
        - Key: Name
          Value: Public Subnet 2
    Metadata:
      'AWS::CloudFormation::Designer':
        id: b53d7efb-08c8-41d4-8ceb-0de7da3ab8ca
  PublicRouteTableAssociation1:
    Type: 'AWS::EC2::SubnetRouteTableAssociation'
    DependsOn:
      - PublicRouteTable
      - PublicSubnet1
    Properties:
      RouteTableId: !Ref PublicRouteTable
      SubnetId: !Ref PublicSubnet1
    Metadata:
      'AWS::CloudFormation::Designer':
        id: 3ca6c48e-fea3-4e90-89f1-307fab42ee31
  PublicRouteTableAssociation2:
    Type: 'AWS::EC2::SubnetRouteTableAssociation'
    DependsOn:
      - PublicRouteTable
      - PublicSubnet2
    Properties:
      RouteTableId: !Ref PublicRouteTable
      SubnetId: !Ref PublicSubnet2
    Metadata:
      'AWS::CloudFormation::Designer':
        id: 8cfc0dee-6e23-460d-8aa8-a1370ee74b87
  PrivateSubnet1:
    Type: 'AWS::EC2::Subnet'
    DependsOn: VPC
    Properties:
      VpcId: !Ref VPC
      CidrBlock: 10.0.2.0/23
      AvailabilityZone: !Select
        - 0
        - !GetAZs
          Ref: 'AWS::Region'
      Tags:
        - Key: Name
          Value: Private Subnet 1
    Metadata:
      'AWS::CloudFormation::Designer':
        id: d123a642-4a21-4158-96d3-f409f63a091e
  PrivateSubnet2:
    Type: 'AWS::EC2::Subnet'
    DependsOn: VPC
    Properties:
      VpcId: !Ref VPC
      CidrBlock: 10.0.4.0/23
      AvailabilityZone: !Select
        - 1
        - !GetAZs
          Ref: 'AWS::Region'
      Tags:
        - Key: Name
          Value: Private Subnet 2
    Metadata:
      'AWS::CloudFormation::Designer':
        id: 321926b4-235b-4fa6-8f84-00199d7e8078
  PrivateRouteTableAssociation1:
    Type: 'AWS::EC2::SubnetRouteTableAssociation'
    DependsOn:
      - PrivateRouteTable
      - PrivateSubnet1
    Properties:
      RouteTableId: !Ref PrivateRouteTable
      SubnetId: !Ref PrivateSubnet1
    Metadata:
      'AWS::CloudFormation::Designer':
        id: 0ce27531-eb00-4e6c-a6a9-170a7654c97b
  PrivateRouteTableAssociation2:
    Type: 'AWS::EC2::SubnetRouteTableAssociation'
    DependsOn:
      - PrivateRouteTable
      - PrivateSubnet2
    Properties:
      RouteTableId: !Ref PrivateRouteTable
      SubnetId: !Ref PrivateSubnet2
    Metadata:
      'AWS::CloudFormation::Designer':
        id: bafb60c3-585d-4de6-ba5a-4c1953682dc2
  NATGateway:
    DependsOn: PrivateSubnet1
    Type: 'AWS::EC2::NatGateway'
    Properties:
      SubnetId: !Ref PublicSubnet1
      AllocationId: !GetAtt
        - NATGatewayEIP
        - AllocationId
    Metadata:
      'AWS::CloudFormation::Designer':
        id: 96f51360-5805-47e6-ae44-f07399ddbd13
  NATGatewayEIP:
    Type: 'AWS::EC2::EIP'
    Properties:
      Domain: vpc
    Metadata:
      'AWS::CloudFormation::Designer':
        id: 359e70b3-fa6c-4139-a1b9-0caffbd1bde6
  NATGatewayRoute:
    Type: 'AWS::EC2::Route'
    Properties:
      RouteTableId: !Ref PrivateRouteTable
      DestinationCidrBlock: 0.0.0.0/0
      NatGatewayId: !Ref NATGateway
    Metadata:
      'AWS::CloudFormation::Designer':
        id: 9f098b89-9397-45b2-9589-c7ed802def3f
  InstanceProfile:
    Type: 'AWS::IAM::InstanceProfile'
    Properties:
      Path: /
      Roles:
        - !Ref AppRole
      InstanceProfileName: Inventory-App-Role
    Metadata:
      'AWS::CloudFormation::Designer':
        id: 98bfadc4-91a1-469c-95a0-782708eec092
  AppRole:
    Type: 'AWS::IAM::Role'
    Properties:
      RoleName: Inventory-App-Role
      AssumeRolePolicyDocument:
        Version: 2012-10-17
        Statement:
          - Effect: Allow
            Principal:
              Service:
                - ec2.amazonaws.com
            Action:
              - 'sts:AssumeRole'
      Path: /
      Policies:
        - PolicyName: root
          PolicyDocument:
            Version: 2012-10-17
            Statement:
              - Effect: Allow
                Action: 'ssm:*'
                Resource: '*'
    Metadata:
      'AWS::CloudFormation::Designer':
        id: c01117f4-051c-4394-9fa3-7911beb8d4fa
  AppSecurityGroup:
    Type: 'AWS::EC2::SecurityGroup'
    DependsOn: VPC
    Properties:
      GroupName: Inventory-App
      GroupDescription: Enable access to App
      VpcId: !Ref VPC
      Tags:
        - Key: Name
          Value: Inventory-App
    Metadata:
      'AWS::CloudFormation::Designer':
        id: f6ac4a15-8ed1-42a2-a6b3-1f08ad522e65
  DBSubnetGroup:
    Type: 'AWS::RDS::DBSubnetGroup'
    Properties:
      DBSubnetGroupDescription: Lab-DB-Subnet-Group
      DBSubnetGroupName: Lab-DB-Subnet-Group
      SubnetIds:
        - !Ref PrivateSubnet1
        - !Ref PrivateSubnet2
      Tags:
        - Key: Name
          Value: DBSubnetGroup
    Metadata:
      'AWS::CloudFormation::Designer':
        id: bb6f6f4c-2997-4c80-abea-79744dd94beb
  DBSecurityGroup:
    Type: 'AWS::EC2::SecurityGroup'
    DependsOn: VPC
    Properties:
      GroupName: Inventory-DB
      GroupDescription: Enable access to MySQL
      VpcId: !Ref VPC
      SecurityGroupIngress:
        - IpProtocol: tcp
          FromPort: 3306
          ToPort: 3306
          CidrIp: 10.0.0.0/20
      Tags:
        - Key: Name
          Value: Inventory-DB
    Metadata:
      'AWS::CloudFormation::Designer':
        id: dde20abd-9a9e-4e68-95b2-f476c87b1b0d
  RDSDatabase:
    Type: 'AWS::RDS::DBInstance'
    Properties:
      DBName: inventory
      DBInstanceIdentifier: inventory-db
      AllocatedStorage: 5
      DBInstanceClass: db.t2.micro
      Engine: MySQL
      MasterUsername: master
      MasterUserPassword: lab-password
      MultiAZ: false
      DBSubnetGroupName: !Ref DBSubnetGroup
      VPCSecurityGroups:
        - !Ref DBSecurityGroup
      Tags:
        - Key: Name
          Value: inventory-db
    Metadata:
      'AWS::CloudFormation::Designer':
        id: 20d10aa8-af1e-4637-a2d5-34580fa2cb2d
  LambdaClearParameters:
    Type: 'AWS::Lambda::Function'
    Properties:
      FunctionName: Clear-parameter-store
      Handler: clear-parameter-store.handler
      MemorySize: 128
      Timeout: 300
      Role: !Sub '${LambdaVPCRole.Arn}'
      Code:
        S3Bucket: !Sub '${AWS::Region}-tcprod'
        S3Key: >-
          courses/ILT-TF-100-ARCHIT/v6.3.6/lab-2-webapp/scripts/clear-parameter-store.zip
      Runtime: python2.7
    Metadata:
      'AWS::CloudFormation::Designer':
        id: 05599c98-d0da-4eea-a9a2-8886db9c3386
  CustomClearParameters:
    Type: 'Custom::CustomClearParameters'
    Properties:
      ServiceToken: !Sub '${LambdaClearParameters.Arn}'
    Metadata:
      'AWS::CloudFormation::Designer':
        id: 779bb41f-4a98-4c65-a7b3-f6d3ac6c5d9c
  LambdaVPCRole:
    Type: 'AWS::IAM::Role'
    Properties:
      AssumeRolePolicyDocument:
        Version: 2012-10-17
        Statement:
          - Effect: Allow
            Principal:
              Service:
                - lambda.amazonaws.com
            Action:
              - 'sts:AssumeRole'
      Policies:
        - PolicyName: SSMCleanup
          PolicyDocument:
            Version: 2012-10-17
            Statement:
              - Effect: Allow
                Action:
                  - 'ssm:*'
                  - 'ec2:Describe*'
                  - 'logs:CreateLogGroup'
                  - 'logs:CreateLogStream'
                  - 'logs:PutLogEvents'
                Resource: '*'
    Metadata:
      'AWS::CloudFormation::Designer':
        id: 891d19e2-43f1-40a3-bd0b-c5e75f7cc4b8
Outputs:
  Endpoint:
    Value: !GetAtt
      - RDSDatabase
      - Endpoint.Address
    Description: Database endpoint
  PublicSubnet2:
    Value: !Ref PublicSubnet2
    Description: PublicSubnet2
  NATGateway1:
    Value: !Ref NATGateway
    Description: NATGateway1
Metadata:
  'AWS::CloudFormation::Designer':
    891d19e2-43f1-40a3-bd0b-c5e75f7cc4b8:
      size:
        width: 60
        height: 60
      position:
        x: 990
        'y': 90
      z: 1
      embeds: []
    779bb41f-4a98-4c65-a7b3-f6d3ac6c5d9c:
      size:
        width: 60
        height: 60
      position:
        x: 1110
        'y': 90
      z: 1
      embeds: []
    05599c98-d0da-4eea-a9a2-8886db9c3386:
      size:
        width: 60
        height: 60
      position:
        x: 990
        'y': 210
      z: 1
      embeds: []
    c01117f4-051c-4394-9fa3-7911beb8d4fa:
      size:
        width: 60
        height: 60
      position:
        x: 1110
        'y': 210
      z: 1
      embeds: []
    98bfadc4-91a1-469c-95a0-782708eec092:
      size:
        width: 60
        height: 60
      position:
        x: 990
        'y': 330
      z: 1
      embeds: []
      isassociatedwith:
        - c01117f4-051c-4394-9fa3-7911beb8d4fa
    359e70b3-fa6c-4139-a1b9-0caffbd1bde6:
      size:
        width: 60
        height: 60
      position:
        x: 1110
        'y': 330
      z: 1
      embeds: []
    06fe38c1-3999-48ff-bf87-144303a2ee76:
      size:
        width: 60
        height: 60
      position:
        x: 990
        'y': 450
      z: 1
      embeds: []
    157db3f5-4073-401e-8966-3fd1e9e71305:
      size:
        width: 870
        height: 780
      position:
        x: 50
        'y': 180
      z: 1
      embeds:
        - dde20abd-9a9e-4e68-95b2-f476c87b1b0d
        - f6ac4a15-8ed1-42a2-a6b3-1f08ad522e65
        - 321926b4-235b-4fa6-8f84-00199d7e8078
        - d123a642-4a21-4158-96d3-f409f63a091e
        - b53d7efb-08c8-41d4-8ceb-0de7da3ab8ca
        - 0e359b90-3cec-43bd-b8f4-494db89babb7
        - 2d1cce8b-dd91-456c-ba10-69d56f57573d
        - 1c3e3640-6fd2-450a-8ea8-e4226df1af13
    dde20abd-9a9e-4e68-95b2-f476c87b1b0d:
      size:
        width: 60
        height: 60
      position:
        x: 380
        'y': 750
      z: 2
      parent: 157db3f5-4073-401e-8966-3fd1e9e71305
      embeds: []
      dependson:
        - 157db3f5-4073-401e-8966-3fd1e9e71305
    f6ac4a15-8ed1-42a2-a6b3-1f08ad522e65:
      size:
        width: 60
        height: 60
      position:
        x: 500
        'y': 750
      z: 2
      parent: 157db3f5-4073-401e-8966-3fd1e9e71305
      embeds: []
      dependson:
        - 157db3f5-4073-401e-8966-3fd1e9e71305
    321926b4-235b-4fa6-8f84-00199d7e8078:
      size:
        width: 150
        height: 150
      position:
        x: 680
        'y': 240
      z: 2
      parent: 157db3f5-4073-401e-8966-3fd1e9e71305
      embeds: []
      dependson:
        - 157db3f5-4073-401e-8966-3fd1e9e71305
    d123a642-4a21-4158-96d3-f409f63a091e:
      size:
        width: 150
        height: 150
      position:
        x: 590
        'y': 540
      z: 2
      parent: 157db3f5-4073-401e-8966-3fd1e9e71305
      embeds: []
      dependson:
        - 157db3f5-4073-401e-8966-3fd1e9e71305
    bb6f6f4c-2997-4c80-abea-79744dd94beb:
      size:
        width: 240
        height: 240
      position:
        x: 60
        'y': 930
      z: 1
      embeds:
        - 20d10aa8-af1e-4637-a2d5-34580fa2cb2d
      iscontainedinside:
        - d123a642-4a21-4158-96d3-f409f63a091e
        - 321926b4-235b-4fa6-8f84-00199d7e8078
    20d10aa8-af1e-4637-a2d5-34580fa2cb2d:
      size:
        width: 60
        height: 60
      position:
        x: 90
        'y': 990
      z: 2
      parent: bb6f6f4c-2997-4c80-abea-79744dd94beb
      embeds: []
      isassociatedwith:
        - dde20abd-9a9e-4e68-95b2-f476c87b1b0d
      iscontainedinside:
        - bb6f6f4c-2997-4c80-abea-79744dd94beb
    b53d7efb-08c8-41d4-8ceb-0de7da3ab8ca:
      size:
        width: 150
        height: 150
      position:
        x: 380
        'y': 540
      z: 2
      parent: 157db3f5-4073-401e-8966-3fd1e9e71305
      embeds: []
      dependson:
        - 157db3f5-4073-401e-8966-3fd1e9e71305
    0e359b90-3cec-43bd-b8f4-494db89babb7:
      size:
        width: 240
        height: 240
      position:
        x: 80
        'y': 540
      z: 2
      parent: 157db3f5-4073-401e-8966-3fd1e9e71305
      embeds:
        - 96f51360-5805-47e6-ae44-f07399ddbd13
      dependson:
        - 157db3f5-4073-401e-8966-3fd1e9e71305
    96f51360-5805-47e6-ae44-f07399ddbd13:
      size:
        width: 60
        height: 60
      position:
        x: 110
        'y': 600
      z: 3
      parent: 0e359b90-3cec-43bd-b8f4-494db89babb7
      embeds: []
      iscontainedinside:
        - 0e359b90-3cec-43bd-b8f4-494db89babb7
      dependson:
        - d123a642-4a21-4158-96d3-f409f63a091e
    2d1cce8b-dd91-456c-ba10-69d56f57573d:
      size:
        width: 240
        height: 240
      position:
        x: 380
        'y': 240
      z: 2
      parent: 157db3f5-4073-401e-8966-3fd1e9e71305
      embeds:
        - 9f098b89-9397-45b2-9589-c7ed802def3f
      dependson:
        - 157db3f5-4073-401e-8966-3fd1e9e71305
    9f098b89-9397-45b2-9589-c7ed802def3f:
      size:
        width: 60
        height: 60
      position:
        x: 410
        'y': 300
      z: 3
      parent: 2d1cce8b-dd91-456c-ba10-69d56f57573d
      embeds: []
      isassociatedwith:
        - 96f51360-5805-47e6-ae44-f07399ddbd13
      iscontainedinside:
        - 2d1cce8b-dd91-456c-ba10-69d56f57573d
    bafb60c3-585d-4de6-ba5a-4c1953682dc2:
      source:
        id: 2d1cce8b-dd91-456c-ba10-69d56f57573d
      target:
        id: 321926b4-235b-4fa6-8f84-00199d7e8078
    0ce27531-eb00-4e6c-a6a9-170a7654c97b:
      source:
        id: 2d1cce8b-dd91-456c-ba10-69d56f57573d
      target:
        id: d123a642-4a21-4158-96d3-f409f63a091e
    1c3e3640-6fd2-450a-8ea8-e4226df1af13:
      size:
        width: 240
        height: 240
      position:
        x: 80
        'y': 240
      z: 2
      parent: 157db3f5-4073-401e-8966-3fd1e9e71305
      embeds:
        - 9bd11e9b-bb52-4b0f-8fee-2d9651b1b1d9
      dependson:
        - 157db3f5-4073-401e-8966-3fd1e9e71305
    8cfc0dee-6e23-460d-8aa8-a1370ee74b87:
      source:
        id: 1c3e3640-6fd2-450a-8ea8-e4226df1af13
      target:
        id: b53d7efb-08c8-41d4-8ceb-0de7da3ab8ca
    3ca6c48e-fea3-4e90-89f1-307fab42ee31:
      source:
        id: 1c3e3640-6fd2-450a-8ea8-e4226df1af13
      target:
        id: 0e359b90-3cec-43bd-b8f4-494db89babb7
    38f66d8e-a8cb-4d60-936f-e21e3fd7a45c:
      source:
        id: 157db3f5-4073-401e-8966-3fd1e9e71305
      target:
        id: 06fe38c1-3999-48ff-bf87-144303a2ee76
    9bd11e9b-bb52-4b0f-8fee-2d9651b1b1d9:
      size:
        width: 60
        height: 60
      position:
        x: 110
        'y': 300
      z: 3
      parent: 1c3e3640-6fd2-450a-8ea8-e4226df1af13
      embeds: []
      isassociatedwith:
        - 06fe38c1-3999-48ff-bf87-144303a2ee76
      dependson:
        - 1c3e3640-6fd2-450a-8ea8-e4226df1af13
        - 38f66d8e-a8cb-4d60-936f-e21e3fd7a45c

template1-designer.png
0.6MB