{"id":337,"date":"2014-07-29T10:00:55","date_gmt":"2014-07-29T01:00:55","guid":{"rendered":"http:\/\/www.skyarch.net\/blog\/?p=337"},"modified":"2014-11-21T21:42:56","modified_gmt":"2014-11-21T12:42:56","slug":"cloudformation%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%81%9f","status":"publish","type":"post","link":"https:\/\/www.skyarch.net\/blog\/cloudformation%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%81%9f\/","title":{"rendered":"CloudFormation\u3092\u4f7f\u3063\u3066\u307f\u305f"},"content":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\uff01<\/p>\n<p>\u3053\u308c\u307e\u3067\u30d6\u30ed\u30b0\u306b\u66f8\u304b\u305b\u3066\u3082\u3089\u3063\u305f\u5185\u5bb9\u3092CloudFormation\u3092\u4f7f\u3063\u3066\u3001\u81ea\u52d5\u3067\u4f5c\u6210\u3057\u3066\u304f\u308c\u308b\u3088\u3046\u306b\u4f5c\u3063\u3066\u307f\u307e\u3057\u305f\u3002<br \/>\n\u56f3\u306e\u69cb\u6210\u304c\u3001\u81ea\u52d5\u3067\u3067\u304d\u3042\u304c\u308a\u307e\u3059\u3002<\/p>\n<a href=\"http:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2014\/07\/cloudformation1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2014\/07\/cloudformation1-1024x575.png\" alt=\"cloudformation\" width=\"1024\" height=\"575\" class=\"aligncenter size-large wp-image-338\" srcset=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2014\/07\/cloudformation1-1024x575.png 1024w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2014\/07\/cloudformation1-300x168.png 300w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2014\/07\/cloudformation1.png 1366w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a>\n<p>\u4ee5\u4e0b\u3092\u30c6\u30ad\u30b9\u30c8\u4fdd\u5b58\u3057\u3066\u3001CloudFormation\u3067\u304a\u8a66\u3057\u304f\u3060\u3055\u3044\uff01<\/p>\n<p><a href=\"http:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2014\/07\/cloudformation.txt\">\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u8d77\u52d5\u30ea\u30f3\u30af<\/a><\/p>\n<pre>\n{\n  \"AWSTemplateFormatVersion\": \"2010-09-09\",\n  \"Resources\": {\n    \"VPC\": {\n      \"Type\": \"AWS::EC2::VPC\",\n      \"Properties\": {\n        \"CidrBlock\": \"10.0.0.0\/16\",\n        \"InstanceTenancy\": \"default\",\n        \"EnableDnsSupport\": \"true\",\n        \"EnableDnsHostnames\": \"true\"\n      }\n    },\n    \"subnet01\": {\n      \"Type\": \"AWS::EC2::Subnet\",\n      \"Properties\": {\n        \"CidrBlock\": \"10.0.1.0\/24\",\n        \"AvailabilityZone\": \"ap-southeast-1a\",\n        \"VpcId\": {\n          \"Ref\": \"VPC\"\n        }\n      }\n    },\n    \"subnet02\": {\n      \"Type\": \"AWS::EC2::Subnet\",\n      \"Properties\": {\n        \"CidrBlock\": \"10.0.2.0\/24\",\n        \"AvailabilityZone\": \"ap-southeast-1b\",\n        \"VpcId\": {\n          \"Ref\": \"VPC\"\n        }\n      }\n    },\n    \"inetgw\": {\n      \"Type\": \"AWS::EC2::InternetGateway\",\n      \"Properties\": {\n      }\n    },\n    \"dhcpopt\": {\n      \"Type\": \"AWS::EC2::DHCPOptions\",\n      \"Properties\": {\n        \"DomainName\": \"ap-southeast-1.compute.internal\",\n        \"DomainNameServers\": [\n          \"AmazonProvidedDNS\"\n        ]\n      }\n    },\n    \"nwacl\": {\n      \"Type\": \"AWS::EC2::NetworkAcl\",\n      \"Properties\": {\n        \"VpcId\": {\n          \"Ref\": \"VPC\"\n        }\n      }\n    },\n    \"routetable\": {\n      \"Type\": \"AWS::EC2::RouteTable\",\n      \"Properties\": {\n        \"VpcId\": {\n          \"Ref\": \"VPC\"\n        }\n      }\n    },\n    \"elbaslb\": {\n      \"Type\": \"AWS::ElasticLoadBalancing::LoadBalancer\",\n      \"Properties\": {\n        \"Subnets\": [\n          {\n            \"Ref\": \"subnet01\"\n          },\n          {\n            \"Ref\": \"subnet02\"\n          }\n        ],\n        \"HealthCheck\": {\n          \"HealthyThreshold\": \"2\",\n          \"Interval\": \"30\",\n          \"Target\": \"HTTP:80\/index.html\",\n          \"Timeout\": \"5\",\n          \"UnhealthyThreshold\": \"2\"\n        },\n        \"SecurityGroups\": [\n          {\n            \"Ref\": \"sgall\"\n          }\n        ],\n        \"Listeners\": [\n          {\n            \"InstancePort\": \"80\",\n            \"LoadBalancerPort\": \"80\",\n            \"Protocol\": \"HTTP\",\n            \"InstanceProtocol\": \"HTTP\"\n          }\n        ]\n      }\n    },\n    \"asgassg\": {\n      \"Type\": \"AWS::AutoScaling::AutoScalingGroup\",\n      \"Properties\": {\n        \"AvailabilityZones\": [\n          \"ap-southeast-1b\",\n          \"ap-southeast-1a\"\n        ],\n        \"Cooldown\": \"300\",\n        \"DesiredCapacity\": \"1\",\n        \"MaxSize\": \"4\",\n        \"MinSize\": \"2\",\n        \"HealthCheckGracePeriod\": \"300\",\n        \"HealthCheckType\": \"ELB\",\n        \"VPCZoneIdentifier\": [\n          {\n            \"Ref\": \"subnet01\"\n          },\n          {\n            \"Ref\": \"subnet02\"\n          }\n        ],\n        \"LaunchConfigurationName\": {\n          \"Ref\": \"lcaslc\"\n        },\n        \"LoadBalancerNames\": [\n          {\n            \"Ref\": \"elbaslb\"\n          }\n        ]\n      }\n    },\n    \"rdsmaster\": {\n      \"Type\": \"AWS::RDS::DBInstance\",\n      \"Properties\": {\n        \"AutoMinorVersionUpgrade\": \"true\",\n        \"DBInstanceClass\": \"db.t1.micro\",\n        \"DBInstanceIdentifier\": \"master\",\n        \"Port\": \"3306\",\n        \"AllocatedStorage\": \"5\",\n        \"BackupRetentionPeriod\": \"1\",\n        \"DBName\": \"MyDatabase\",\n        \"Engine\": \"mysql\",\n        \"EngineVersion\": \"5.5.33\",\n        \"LicenseModel\": \"general-public-license\",\n        \"MasterUsername\": \"rdsuser\",\n        \"MasterUserPassword\": \"MyPassword\",\n        \"PreferredBackupWindow\": \"16:35-17:05\",\n        \"PreferredMaintenanceWindow\": \"mon:14:02-mon:14:32\",\n        \"MultiAZ\": \"true\",\n        \"VPCSecurityGroups\": [\n          {\n            \"Ref\": \"sgall\"\n          }\n        ],\n        \"DBSubnetGroupName\": {\n          \"Ref\": \"dbsubnetmultiazsg\"\n        },\n        \"Tags\": [\n          {\n            \"Key\": \"workload-type\",\n            \"Value\": \"production\"\n          }\n        ]\n      }\n    },\n    \"rdsslave0\": {\n      \"Type\": \"AWS::RDS::DBInstance\",\n      \"Properties\": {\n        \"AutoMinorVersionUpgrade\": \"true\",\n        \"DBInstanceClass\": \"db.t1.micro\",\n        \"DBInstanceIdentifier\": \"slave0\",\n        \"Port\": \"3306\",\n        \"SourceDBInstanceIdentifier\": {\n          \"Ref\": \"rdsmaster\"\n        }\n      }\n    },\n    \"lcaslc\": {\n      \"Type\": \"AWS::AutoScaling::LaunchConfiguration\",\n      \"Properties\": {\n        \"ImageId\": \"ami-56bee804\",\n        \"InstanceType\": \"t1.micro\",\n        \"KeyName\": \"astest\",\n        \"SecurityGroups\": [\n          {\n            \"Ref\": \"sgall\"\n          }\n        ],         \"BlockDeviceMappings\": [\n          {\n            \"DeviceName\": \"\/dev\/sda1\",\n            \"Ebs\": {\n              \"VolumeSize\": 8\n            }\n          }\n        ]\n      }\n    },\n    \"dbsubnetmultiazsg\": {\n      \"Type\": \"AWS::RDS::DBSubnetGroup\",\n      \"Properties\": {\n        \"DBSubnetGroupDescription\": \"for Multi-AZ\",\n        \"SubnetIds\": [\n          {\n            \"Ref\": \"subnet01\"\n          },\n          {\n            \"Ref\": \"subnet02\"\n          }\n        ]\n      }\n    },\n    \"sgall\": {\n      \"Type\": \"AWS::EC2::SecurityGroup\",\n      \"Properties\": {\n        \"GroupDescription\": \"allow all\",\n        \"VpcId\": {\n          \"Ref\": \"VPC\"\n        },\n        \"SecurityGroupIngress\": [\n          {\n            \"IpProtocol\": \"-1\",\n            \"CidrIp\": \"0.0.0.0\/0\"\n          }\n        ],\n        \"SecurityGroupEgress\": [\n          {\n            \"IpProtocol\": \"-1\",\n            \"CidrIp\": \"0.0.0.0\/0\"\n          }\n        ]\n      }\n    },\n    \"scalingDecreaseGroupSize\": {\n      \"Type\": \"AWS::AutoScaling::ScalingPolicy\",\n      \"Properties\": {\n        \"AdjustmentType\": \"ChangeInCapacity\",\n        \"ScalingAdjustment\": \"-1\",\n        \"AutoScalingGroupName\": {\n          \"Ref\": \"asgassg\"\n        }\n      }\n    },\n    \"scalingIncreaseGroupSize\": {\n      \"Type\": \"AWS::AutoScaling::ScalingPolicy\",\n      \"Properties\": {\n        \"AdjustmentType\": \"ChangeInCapacity\",\n        \"ScalingAdjustment\": \"1\",\n        \"AutoScalingGroupName\": {\n          \"Ref\": \"asgassg\"\n        }\n      }\n    },\n    \"alarmawsec2assgCPUUtilizationadd\": {\n      \"Type\": \"AWS::CloudWatch::Alarm\",\n      \"Properties\": {\n        \"ActionsEnabled\": \"true\",\n        \"ComparisonOperator\": \"GreaterThanOrEqualToThreshold\",\n        \"EvaluationPeriods\": \"1\",\n        \"MetricName\": \"CPUUtilization\",\n        \"Namespace\": \"AWS\/EC2\",\n        \"Period\": \"300\",\n        \"Statistic\": \"Average\",\n        \"Threshold\": \"50.0\",\n        \"AlarmActions\": [\n          {\n            \"Ref\": \"scalingIncreaseGroupSize\"\n          }\n        ],\n        \"Dimensions\": [\n          {\n            \"Name\": \"AutoScalingGroupName\",\n            \"Value\": \"as-sg\"\n          }\n        ]\n      }\n    },\n    \"alarmawsec2assgHighCPUUtilizationremove\": {\n      \"Type\": \"AWS::CloudWatch::Alarm\",\n      \"Properties\": {\n        \"ActionsEnabled\": \"true\",\n        \"ComparisonOperator\": \"LessThanThreshold\",\n        \"EvaluationPeriods\": \"1\",\n        \"MetricName\": \"CPUUtilization\",\n        \"Namespace\": \"AWS\/EC2\",\n        \"Period\": \"300\",\n        \"Statistic\": \"Average\",\n        \"Threshold\": \"50.0\",\n        \"AlarmActions\": [\n          {\n            \"Ref\": \"scalingDecreaseGroupSize\"\n          }\n        ],\n        \"Dimensions\": [\n          {\n            \"Name\": \"AutoScalingGroupName\",\n            \"Value\": \"as-sg\"\n          }\n        ]\n      }\n    },\n    \"acl1\": {\n      \"Type\": \"AWS::EC2::NetworkAclEntry\",\n      \"Properties\": {\n        \"CidrBlock\": \"0.0.0.0\/0\",\n        \"Egress\": true,\n        \"Protocol\": \"-1\",\n        \"RuleAction\": \"allow\",\n        \"RuleNumber\": \"100\",\n        \"NetworkAclId\": {\n          \"Ref\": \"nwacl\"\n        }\n      }\n    },\n    \"acl2\": {\n      \"Type\": \"AWS::EC2::NetworkAclEntry\",\n      \"Properties\": {\n        \"CidrBlock\": \"0.0.0.0\/0\",\n        \"Protocol\": \"-1\",\n        \"RuleAction\": \"allow\",\n        \"RuleNumber\": \"100\",\n        \"NetworkAclId\": {\n          \"Ref\": \"nwacl\"\n        }\n      }\n    },\n    \"subnetacl1\": {\n      \"Type\": \"AWS::EC2::SubnetNetworkAclAssociation\",\n      \"Properties\": {\n        \"NetworkAclId\": {\n          \"Ref\": \"nwacl\"\n        },\n        \"SubnetId\": {\n          \"Ref\": \"subnet01\"\n        }\n      }\n    },\n    \"subnetacl2\": {\n      \"Type\": \"AWS::EC2::SubnetNetworkAclAssociation\",\n      \"Properties\": {\n        \"NetworkAclId\": {\n          \"Ref\": \"nwacl\"\n        },\n        \"SubnetId\": {\n          \"Ref\": \"subnet02\"\n        }\n      }\n    },\n    \"gw1\": {\n      \"Type\": \"AWS::EC2::VPCGatewayAttachment\",\n      \"Properties\": {\n        \"VpcId\": {\n          \"Ref\": \"VPC\"\n        },\n        \"InternetGatewayId\": {\n          \"Ref\": \"inetgw\"\n        }\n      }\n    },\n    \"subnetroute1\": {\n      \"Type\": \"AWS::EC2::SubnetRouteTableAssociation\",\n      \"Properties\": {\n        \"RouteTableId\": {\n          \"Ref\": \"routetable\"\n        },\n        \"SubnetId\": {\n          \"Ref\": \"subnet02\"\n        }\n      }\n    },\n    \"subnetroute2\": {\n      \"Type\": \"AWS::EC2::SubnetRouteTableAssociation\",\n      \"Properties\": {\n        \"RouteTableId\": {\n          \"Ref\": \"routetable\"\n        },\n        \"SubnetId\": {\n          \"Ref\": \"subnet01\"\n        }\n      }\n    },\n    \"route1\": {\n      \"Type\": \"AWS::EC2::Route\",\n      \"Properties\": {\n        \"DestinationCidrBlock\": \"0.0.0.0\/0\",\n        \"RouteTableId\": {\n          \"Ref\": \"routetable\"\n        },\n        \"GatewayId\": {\n          \"Ref\": \"inetgw\"\n        }\n      },\n      \"DependsOn\": \"gw1\"\n    },\n    \"dchpassoc1\": {\n      \"Type\": \"AWS::EC2::VPCDHCPOptionsAssociation\",\n      \"Properties\": {\n        \"VpcId\": {\n          \"Ref\": \"VPC\"\n        },\n        \"DhcpOptionsId\": {\n          \"Ref\": \"dhcpopt\"\n        }\n      }\n    }\n  },\n  \"Description\": \"\"\n}\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\uff01 \u3053\u308c\u307e\u3067\u30d6\u30ed\u30b0\u306b\u66f8\u304b\u305b\u3066\u3082\u3089\u3063\u305f\u5185\u5bb9\u3092CloudFormation\u3092\u4f7f\u3063\u3066\u3001\u81ea\u52d5\u3067\u4f5c\u6210\u3057\u3066\u304f\u308c\u308b\u3088\u3046\u306b\u4f5c\u3063\u3066\u307f\u307e\u3057\u305f\u3002 \u56f3\u306e\u69cb\u6210\u304c\u3001\u81ea\u52d5\u3067\u3067\u304d\u3042\u304c\u308a\u307e\u3059\u3002 \u4ee5\u4e0b\u3092\u30c6\u30ad\u30b9\u30c8\u4fdd\u5b58\u3057\u3066\u3001CloudFormatio&#8230;<\/p>\n","protected":false},"author":1,"featured_media":242,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"","_original_post":"","footnotes":""},"categories":[20,83],"tags":[102,53],"class_list":{"0":"post-337","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-aws","8":"category-devops","9":"tag-aws","10":"tag-cloudformation","11":"ja"},"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts\/337","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/comments?post=337"}],"version-history":[{"count":14,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts\/337\/revisions"}],"predecessor-version":[{"id":562,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts\/337\/revisions\/562"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/media\/242"}],"wp:attachment":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/media?parent=337"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/categories?post=337"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/tags?post=337"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}