Help us understand the problem. What is going on with this article?

[JAWS-UG CLI] CloudFormation:#7 テンプレートの作成 (デザイナの利用)

More than 3 years have passed since last update.

デザイナーによるテンプレート作成の例

ウォークスルー: AWS CloudFormation デザイナー を使用して基本的なウェブサーバーを作成します。: http://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/working-with-templates-cfn-designer-walkthrough-createbasicwebserver.html

ステップ3まで実施します。

スクリーンショット 2017-06-12 17.32.57.png

テンプレートの作成結果例

テンプレートの例
{
    "AWSTemplateFormatVersion": "2010-09-09",
    "Metadata": {
        "AWS::CloudFormation::Designer": {
            "2e84feb3-cb7f-47d8-a50b-73d6e89de7bc": {
                "size": {
                    "width": 710,
                    "height": 220
                },
                "position": {
                    "x": 100,
                    "y": 130
                },
                "z": 0,
                "embeds": [
                    "25d45e53-d776-4534-b244-b9a49c15b6ff",
                    "09677cca-68f1-478f-842e-32018f9bf5fa",
                    "4a16106f-3988-4902-ba28-2fcf5bc1d48d"
                ]
            },
            "09677cca-68f1-478f-842e-32018f9bf5fa": {
                "size": {
                    "width": 140,
                    "height": 140
                },
                "position": {
                    "x": 180,
                    "y": 200
                },
                "z": 1,
                "parent": "2e84feb3-cb7f-47d8-a50b-73d6e89de7bc",
                "embeds": [
                    "5227546f-a488-4322-b146-17e159d2657f"
                ]
            },
            "5227546f-a488-4322-b146-17e159d2657f": {
                "size": {
                    "width": 60,
                    "height": 60
                },
                "position": {
                    "x": 228,
                    "y": 236
                },
                "z": 2,
                "parent": "09677cca-68f1-478f-842e-32018f9bf5fa",
                "embeds": [],
                "dependson": [
                    "1e86fca9-84d1-4d05-9e68-efb1df27d4c5"
                ],
                "isrelatedto": [
                    "25d45e53-d776-4534-b244-b9a49c15b6ff"
                ]
            },
            "25d45e53-d776-4534-b244-b9a49c15b6ff": {
                "size": {
                    "width": 60,
                    "height": 60
                },
                "position": {
                    "x": 480,
                    "y": 180
                },
                "z": 1,
                "parent": "2e84feb3-cb7f-47d8-a50b-73d6e89de7bc",
                "embeds": []
            },
            "0e5d222f-40cb-4c52-b251-80c744846be5": {
                "size": {
                    "width": 60,
                    "height": 60
                },
                "position": {
                    "x": 880,
                    "y": 220
                },
                "z": 0,
                "embeds": []
            },
            "5637b4f3-df45-40fb-a91d-dae734a3abdd": {
                "source": {
                    "id": "0e5d222f-40cb-4c52-b251-80c744846be5"
                },
                "target": {
                    "id": "2e84feb3-cb7f-47d8-a50b-73d6e89de7bc"
                },
                "z": 0
            },
            "75da879a-0efa-427e-8071-077ba3a16212": {
                "source": {
                    "id": "0e5d222f-40cb-4c52-b251-80c744846be5"
                },
                "target": {
                    "id": "2e84feb3-cb7f-47d8-a50b-73d6e89de7bc"
                },
                "z": 0
            },
            "4a16106f-3988-4902-ba28-2fcf5bc1d48d": {
                "size": {
                    "width": 140,
                    "height": 140
                },
                "position": {
                    "x": 650,
                    "y": 170
                },
                "z": 1,
                "parent": "2e84feb3-cb7f-47d8-a50b-73d6e89de7bc",
                "embeds": [
                    "1e86fca9-84d1-4d05-9e68-efb1df27d4c5"
                ],
                "dependson": [
                    "09677cca-68f1-478f-842e-32018f9bf5fa"
                ]
            },
            "1e86fca9-84d1-4d05-9e68-efb1df27d4c5": {
                "size": {
                    "width": 60,
                    "height": 60
                },
                "position": {
                    "x": 700,
                    "y": 240
                },
                "z": 2,
                "parent": "4a16106f-3988-4902-ba28-2fcf5bc1d48d",
                "embeds": [],
                "references": [
                    "0e5d222f-40cb-4c52-b251-80c744846be5"
                ],
                "dependson": [
                    "0e5d222f-40cb-4c52-b251-80c744846be5"
                ]
            },
            "a1cc9b57-b454-483b-8e86-4e4e0cd9cacb": {
                "source": {
                    "id": "1e86fca9-84d1-4d05-9e68-efb1df27d4c5"
                },
                "target": {
                    "id": "0e5d222f-40cb-4c52-b251-80c744846be5"
                },
                "z": 3
            },
            "522ea7e3-d856-43d9-97c0-ab3da44fc19c": {
                "source": {
                    "id": "5227546f-a488-4322-b146-17e159d2657f"
                },
                "target": {
                    "id": "1e86fca9-84d1-4d05-9e68-efb1df27d4c5"
                },
                "z": 4
            },
            "b617925c-337f-46dc-bf6c-d8d61ff8d687": {
                "source": {
                    "id": "4a16106f-3988-4902-ba28-2fcf5bc1d48d"
                },
                "target": {
                    "id": "09677cca-68f1-478f-842e-32018f9bf5fa"
                },
                "z": 5
            },
            "b8d8deca-616b-4d76-8797-873228e79f9d": {
                "source": {
                    "id": "1e86fca9-84d1-4d05-9e68-efb1df27d4c5"
                },
                "target": {
                    "id": "0e5d222f-40cb-4c52-b251-80c744846be5"
                },
                "z": 3
            },
            "25d0fe02-7713-433a-88a0-7f85890eb289": {
                "source": {
                    "id": "1e86fca9-84d1-4d05-9e68-efb1df27d4c5"
                },
                "target": {
                    "id": "0e5d222f-40cb-4c52-b251-80c744846be5"
                },
                "z": 4
            },
            "f818e69a-a5cb-4569-92b0-a5bbab980380": {
                "source": {
                    "id": "4a16106f-3988-4902-ba28-2fcf5bc1d48d"
                },
                "target": {
                    "id": "09677cca-68f1-478f-842e-32018f9bf5fa"
                },
                "z": 3
            }
        }
    },
    "Resources": {
        "VPC": {
            "Type": "AWS::EC2::VPC",
            "Properties": {
                "EnableDnsSupport": "true",
                "EnableDnsHostnames": "true",
                "CidrBlock": "10.0.0.0/16"
            },
            "Metadata": {
                "AWS::CloudFormation::Designer": {
                    "id": "2e84feb3-cb7f-47d8-a50b-73d6e89de7bc"
                }
            }
        },
        "PublicSubnet": {
            "Type": "AWS::EC2::Subnet",
            "Properties": {
                "VpcId": {
                    "Ref": "VPC"
                },
                "CidrBlock": "10.0.0.0/24"
            },
            "Metadata": {
                "AWS::CloudFormation::Designer": {
                    "id": "09677cca-68f1-478f-842e-32018f9bf5fa"
                }
            }
        },
        "WebServerInstance": {
            "Type": "AWS::EC2::Instance",
            "Properties": {
                "InstanceType": {
                    "Ref": "InstanceType"
                },
                "ImageId": {
                    "Fn::FindInMap": [
                        "AWSRegionArch2AMI",
                        {
                            "Ref": "AWS::Region"
                        },
                        {
                            "Fn::FindInMap": [
                                "AWSInstanceType2Arch",
                                {
                                    "Ref": "InstanceType"
                                },
                                "Arch"
                            ]
                        }
                    ]
                },
                "KeyName": {
                    "Ref": "KeyName"
                },
                "NetworkInterfaces": [
                    {
                        "GroupSet": [
                            {
                                "Ref": "WebServerSecurityGroup"
                            }
                        ],
                        "AssociatePublicIpAddress": "true",
                        "DeviceIndex": "0",
                        "DeleteOnTermination": "true",
                        "SubnetId": {
                            "Ref": "PublicSubnet"
                        }
                    }
                ],
                "UserData": {
                    "Fn::Base64": {
                        "Fn::Join": [
                            "",
                            [
                                "#!/bin/bash -xe\n",
                                "yum install -y aws-cfn-bootstrap\n",
                                "# Install the files and packages from the metadata\n",
                                "/opt/aws/bin/cfn-init -v ",
                                "         --stack ",
                                {
                                    "Ref": "AWS::StackName"
                                },
                                "         --resource WebServerInstance ",
                                "         --configsets All ",
                                "         --region ",
                                {
                                    "Ref": "AWS::Region"
                                },
                                "\n",
                                "# Signal the status from cfn-init\n",
                                "/opt/aws/bin/cfn-signal -e $? ",
                                "         --stack ",
                                {
                                    "Ref": "AWS::StackName"
                                },
                                "         --resource WebServerInstance ",
                                "         --region ",
                                {
                                    "Ref": "AWS::Region"
                                },
                                "\n"
                            ]
                        ]
                    }
                }
            },
            "Metadata": {
                "AWS::CloudFormation::Designer": {
                    "id": "5227546f-a488-4322-b146-17e159d2657f"
                },
                "AWS::CloudFormation::Init": {
                    "configSets": {
                        "All": [
                            "ConfigureSampleApp"
                        ]
                    },
                    "ConfigureSampleApp": {
                        "packages": {
                            "yum": {
                                "httpd": []
                            }
                        },
                        "files": {
                            "/var/www/html/index.html": {
                                "content": {
                                    "Fn::Join": [
                                        "\n",
                                        [
                                            "<h1>Congratulations, you have successfully launched the AWS CloudFormation sample.</h1>"
                                        ]
                                    ]
                                },
                                "mode": "000644",
                                "owner": "root",
                                "group": "root"
                            }
                        },
                        "services": {
                            "sysvinit": {
                                "httpd": {
                                    "enabled": "true",
                                    "ensureRunning": "true"
                                }
                            }
                        }
                    }
                }
            },
            "DependsOn": [
                "PublicRoute"
            ]
        },
        "WebServerSecurityGroup": {
            "Type": "AWS::EC2::SecurityGroup",
            "Properties": {
                "VpcId": {
                    "Ref": "VPC"
                },
                "GroupDescription": "Allow access from HTTP and SSH traffic",
                "SecurityGroupIngress": [
                    {
                        "IpProtocol": "tcp",
                        "FromPort": "80",
                        "ToPort": "80",
                        "CidrIp": "0.0.0.0/0"
                    },
                    {
                        "IpProtocol": "tcp",
                        "FromPort": "22",
                        "ToPort": "22",
                        "CidrIp": {
                            "Ref": "SSHLocation"
                        }
                    }
                ]
            },
            "Metadata": {
                "AWS::CloudFormation::Designer": {
                    "id": "25d45e53-d776-4534-b244-b9a49c15b6ff"
                }
            }
        },
        "InternetGateway": {
            "Type": "AWS::EC2::InternetGateway",
            "Properties": {},
            "Metadata": {
                "AWS::CloudFormation::Designer": {
                    "id": "0e5d222f-40cb-4c52-b251-80c744846be5"
                }
            }
        },
        "EC2VPCG1BZXP": {
            "Type": "AWS::EC2::VPCGatewayAttachment",
            "Properties": {
                "InternetGatewayId": {
                    "Ref": "InternetGateway"
                },
                "VpcId": {
                    "Ref": "VPC"
                }
            },
            "Metadata": {
                "AWS::CloudFormation::Designer": {
                    "id": "5637b4f3-df45-40fb-a91d-dae734a3abdd"
                }
            }
        },
        "EC2VPCGO08Z": {
            "Type": "AWS::EC2::VPCGatewayAttachment",
            "Properties": {
                "InternetGatewayId": {
                    "Ref": "InternetGateway"
                },
                "VpcId": {
                    "Ref": "VPC"
                }
            },
            "Metadata": {
                "AWS::CloudFormation::Designer": {
                    "id": "75da879a-0efa-427e-8071-077ba3a16212"
                }
            }
        },
        "PublicRouteTable": {
            "Type": "AWS::EC2::RouteTable",
            "Properties": {
                "VpcId": {
                    "Ref": "VPC"
                }
            },
            "Metadata": {
                "AWS::CloudFormation::Designer": {
                    "id": "4a16106f-3988-4902-ba28-2fcf5bc1d48d"
                }
            },
            "DependsOn": [
                "PublicSubnet"
            ]
        },
        "PublicRoute": {
            "Type": "AWS::EC2::Route",
            "Properties": {
                "DestinationCidrBlock": "0.0.0.0/0",
                "RouteTableId": {
                    "Ref": "PublicRouteTable"
                },
                "GatewayId": {
                    "Ref": "InternetGateway"
                }
            },
            "Metadata": {
                "AWS::CloudFormation::Designer": {
                    "id": "1e86fca9-84d1-4d05-9e68-efb1df27d4c5"
                }
            },
            "DependsOn": [
                "InternetGateway"
            ]
        },
        "EC2SRTA3CLE1": {
            "Type": "AWS::EC2::SubnetRouteTableAssociation",
            "Properties": {
                "RouteTableId": {
                    "Ref": "PublicRouteTable"
                },
                "SubnetId": {
                    "Ref": "PublicSubnet"
                }
            },
            "Metadata": {
                "AWS::CloudFormation::Designer": {
                    "id": "f818e69a-a5cb-4569-92b0-a5bbab980380"
                }
            }
        }
    },
    "Parameters": {
        "InstanceType": {
            "Description": "WebServer EC2 instance type",
            "Type": "String",
            "Default": "t2.micro",
            "AllowedValues": [
                "t1.micro",
                "t2.micro",
                "t2.small",
                "t2.medium",
                "m1.small",
                "m1.medium",
                "m1.large",
                "m1.xlarge",
                "m2.xlarge",
                "m2.2xlarge",
                "m2.4xlarge",
                "m3.medium",
                "m3.large",
                "m3.xlarge",
                "m3.2xlarge",
                "c1.medium",
                "c1.xlarge",
                "c3.large",
                "c3.xlarge",
                "c3.2xlarge",
                "c3.4xlarge",
                "c3.8xlarge",
                "c4.large",
                "c4.xlarge",
                "c4.2xlarge",
                "c4.4xlarge",
                "c4.8xlarge",
                "g2.2xlarge",
                "r3.large",
                "r3.xlarge",
                "r3.2xlarge",
                "r3.4xlarge",
                "r3.8xlarge",
                "i2.xlarge",
                "i2.2xlarge",
                "i2.4xlarge",
                "i2.8xlarge",
                "d2.xlarge",
                "d2.2xlarge",
                "d2.4xlarge",
                "d2.8xlarge",
                "hi1.4xlarge",
                "hs1.8xlarge",
                "cr1.8xlarge",
                "cc2.8xlarge",
                "cg1.4xlarge"
            ],
            "ConstraintDescription": "must be a valid EC2 instance type."
        },
        "KeyName": {
            "Description": "Name of an EC2 KeyPair to enable SSH access to the instance.",
            "Type": "AWS::EC2::KeyPair::KeyName",
            "ConstraintDescription": "must be the name of an existing EC2 KeyPair."
        },
        "SSHLocation": {
            "Description": " The IP address range that can be usedto access the web server using SSH.",
            "Type": "String",
            "MinLength": "9",
            "MaxLength": "18",
            "Default": "0.0.0.0/0",
            "AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})",
            "ConstraintDescription": "must be a valid IP CIDR range of the form x.x.x.x/x."
        }
    },
    "Mappings": {
        "AWSInstanceType2Arch": {
            "t1.micro": {
                "Arch": "PV64"
            },
            "t2.micro": {
                "Arch": "HVM64"
            },
            "t2.small": {
                "Arch": "HVM64"
            },
            "t2.medium": {
                "Arch": "HVM64"
            },
            "m1.small": {
                "Arch": "PV64"
            },
            "m1.medium": {
                "Arch": "PV64"
            },
            "m1.large": {
                "Arch": "PV64"
            },
            "m1.xlarge": {
                "Arch": "PV64"
            },
            "m2.xlarge": {
                "Arch": "PV64"
            },
            "m2.2xlarge": {
                "Arch": "PV64"
            },
            "m2.4xlarge": {
                "Arch": "PV64"
            },
            "m3.medium": {
                "Arch": "HVM64"
            },
            "m3.large": {
                "Arch": "HVM64"
            },
            "m3.xlarge": {
                "Arch": "HVM64"
            },
            "m3.2xlarge": {
                "Arch": "HVM64"
            },
            "c1.medium": {
                "Arch": "PV64"
            },
            "c1.xlarge": {
                "Arch": "PV64"
            },
            "c3.large": {
                "Arch": "HVM64"
            },
            "c3.xlarge": {
                "Arch": "HVM64"
            },
            "c3.2xlarge": {
                "Arch": "HVM64"
            },
            "c3.4xlarge": {
                "Arch": "HVM64"
            },
            "c3.8xlarge": {
                "Arch": "HVM64"
            },
            "c4.large": {
                "Arch": "HVM64"
            },
            "c4.xlarge": {
                "Arch": "HVM64"
            },
            "c4.2xlarge": {
                "Arch": "HVM64"
            },
            "c4.4xlarge": {
                "Arch": "HVM64"
            },
            "c4.8xlarge": {
                "Arch": "HVM64"
            },
            "g2.2xlarge": {
                "Arch": "HVMG2"
            },
            "r3.large": {
                "Arch": "HVM64"
            },
            "r3.xlarge": {
                "Arch": "HVM64"
            },
            "r3.2xlarge": {
                "Arch": "HVM64"
            },
            "r3.4xlarge": {
                "Arch": "HVM64"
            },
            "r3.8xlarge": {
                "Arch": "HVM64"
            },
            "i2.xlarge": {
                "Arch": "HVM64"
            },
            "i2.2xlarge": {
                "Arch": "HVM64"
            },
            "i2.4xlarge": {
                "Arch": "HVM64"
            },
            "i2.8xlarge": {
                "Arch": "HVM64"
            },
            "d2.xlarge": {
                "Arch": "HVM64"
            },
            "d2.2xlarge": {
                "Arch": "HVM64"
            },
            "d2.4xlarge": {
                "Arch": "HVM64"
            },
            "d2.8xlarge": {
                "Arch": "HVM64"
            },
            "hi1.4xlarge": {
                "Arch": "HVM64"
            },
            "hs1.8xlarge": {
                "Arch": "HVM64"
            },
            "cr1.8xlarge": {
                "Arch": "HVM64"
            },
            "cc2.8xlarge": {
                "Arch": "HVM64"
            }
        },
        "AWSRegionArch2AMI": {
            "us-east-1": {
                "PV64": "ami-1ccae774",
                "HVM64": "ami-1ecae776",
                "HVMG2": "ami-8c6b40e4"
            },
            "us-west-2": {
                "PV64": "ami-ff527ecf",
                "HVM64": "ami-e7527ed7",
                "HVMG2": "ami-abbe919b"
            },
            "us-west-1": {
                "PV64": "ami-d514f291",
                "HVM64": "ami-d114f295",
                "HVMG2": "ami-f31ffeb7"
            },
            "eu-west-1": {
                "PV64": "ami-bf0897c8",
                "HVM64": "ami-a10897d6",
                "HVMG2": "ami-d5bc24a2"
            },
            "eu-central-1": {
                "PV64": "ami-ac221fb1",
                "HVM64": "ami-a8221fb5",
                "HVMG2": "ami-7cd2ef61"
            },
            "ap-northeast-1": {
                "PV64": "ami-27f90e27",
                "HVM64": "ami-cbf90ecb",
                "HVMG2": "ami-6318e863"
            },
            "ap-southeast-1": {
                "PV64": "ami-acd9e8fe",
                "HVM64": "ami-68d8e93a",
                "HVMG2": "ami-3807376a"
            },
            "ap-southeast-2": {
                "PV64": "ami-ff9cecc5",
                "HVM64": "ami-fd9cecc7",
                "HVMG2": "ami-89790ab3"
            },
            "sa-east-1": {
                "PV64": "ami-bb2890a6",
                "HVM64": "ami-b52890a8",
                "HVMG2": "NOT_SUPPORTED"
            },
            "cn-north-1": {
                "PV64": "ami-fa39abc3",
                "HVM64": "ami-f239abcb",
                "HVMG2": "NOT_SUPPORTED"
            }
        }
    },
    "Outputs": {
        "URL": {
            "Value": {
                "Fn::Join": [
                    "",
                    [
                        "http://",
                        {
                            "Fn::GetAtt": [
                                "WebServerInstance",
                                "PublicIp"
                            ]
                        }
                    ]
                ]
            },
            "Description": "Newly created application URL"
        }
    }
}
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away