CloudFormationを書いていこう

{
	"AWSTemplateFormatVersion" : "2010-09-09",

	"Description" : "Test template.",

	"Resources" : {

		"VPC" : {
			"Type" : "AWS::EC2::VPC",
			"Properties" : {
				"CidrBlock" : "10.0.0.0/16",
				"Tags" : [{"Key": "Application", "Value" : {"Ref" : "AWS::StackId"} }]
			}
		},

		"PublicSubnet" : {
			"Type" : "AWS::EC2::Subnet",
			"Properties" : {
				"VpcId" : {"Ref" : "VPC" },
				"CidrBlock" : "10.0.0.0/24",
				"Tags" : [{"Key" : "Application", "Value" : { "Ref" : "AWS::StackId"}}]
			}
		},

		"PrivateSubnet" : {
			"Type" : "AWS::EC2::Subnet",
			"Properties" : {
				"VpcId" : {"Ref" : "VPC"},
				"CidrBlock" : "10.0.1.0/24",
				"Tags" : [{"Key": "Application", "Value" : {"Ref": "AWS::StackId"}}]
			}
		},

		"InternetGateway" : {
			"Type" : "AWS::EC2::InternetGateway",
			"Properties" : {
				"Tags" : [ {"Key" : "Application", "Value" : {"Ref" : "AWS::StackId"}}]
			}
		},

		"AttachGateway" : {
			"Type" : "AWS::EC2::VPCGatewayAttachment",
			"Properties" : {
				"VpcId" : {"Ref": "VPC"},
				"InternetGatewayId" : {"Ref" : "InternetGateway"}
			}
		},

		"RouteTable" : {
			"Type" : "AWS::EC2::RouteTable",
			"Properties" : {
				"VpcId" : {"Ref" : "VPC"},
				"Tags" : [{"Key" : "Application", "Value" : {"Ref" : "AWS::StackId"}}]
			}
		},

		"Route" : {
			"Type" : "AWS::EC2::Route",
			"DependsOn" : "AttachGateway",
			"Properties" : {
				"RouteTableId" : {"Ref" : "RouteTable"},
				"DestinationCidrBlock": "0.0.0.0/0",
				"GatewayId" : {"Ref" : "InternetGateway"}
			}
		},

		"SubnetRouteTableAssociation" : {
			"Type" : "AWS::EC2::SubnetRouteTableAssociation",
			"Properties" : {
				"SubnetId" : {"Ref" : "PublicSubnet"},
				"RouteTableId" : {"Ref" : "RouteTable"}
			}
		},

		"NetworkAcl" : {
			"Type" : "AWS::EC2::NetworkAcl",
			"Properties" : {
				"VpcId" : {"Ref" : "VPC"},
				"Tags" : [ {"Key" : "Application", "Value": {"Ref" : "AWS::StackId"}}]
			}
		},

		"SubnetNetworkAclAssociation" : {
			"Type" : "AWS::EC2::SubnetNetworkAclAssociation",
			"Properties" : {
				"SubnetId" : {"Ref" : "PublicSubnet" },
				"NetworkAclId" : {"Ref" : "NetworkAcl"}
			}
		}
	}
}

なんじゃこりゃーーーーーーーーーーーー
エンジニアってどうやってモチベーション保ってんだろう。。
まったく、意味が分からんよ。

AWS CloudFormation

AWS CloudFormation is a service that help you model and set up Amazon Web Services resources. You can spend less time managing resources and focus more on the applications that run on AWS. If you create a template that describes all of the AWS resources that you wan to use, such as Amazon EC2 instances or Amazon RDS DB instances, AWS CloudFormation will be responsible for provisioning and configuring these resources on your behalf. You don’t have to create and design individual AWS resources and think about their dependencies. AWS CloudFormation handles everything.

{
	"AWSTempleteFormatVersion": "2010-09-09",

	"Description": "CloudFormation tutorial",

	"Resources" : {
	  "InstanceSecurityGroup": {
	     "Type": "AWS::EC2::SecurityGroup",
	     "Properties": {
	         "GroupDescription" : "Enable HTTP Access on the configured port",
	         "securityGroupIngress" : [
	            {"IpProtocol": "tcp", "FromPort":"80", "ToPort":"80","CidrIp":"0.0.0.0/0"}
	         ]
	     }
	  }
	}
}

CloudFormation

what?

AWS CloudFormation gives developers and systems administrators an easy way to create and manage a collection of related AWS resources, provisioning and updating them in an orderly and predictable fashion.

You can use AWS CloudFormation’s sample templates or create your own templates to describe the AWS resources, and any associated dependencies or runtime parameters, required to run your application. You don’t need to figure out the order for provisioning AWS services or the subtleties of making those dependencies work. CloudFormation takes care of this for you. After the AWS resources are deployed, you can modify and update them in a controlled and predictable way, in effect applying version control to your AWS infrastructure the same way you do with your software.