| “DBAllocatedStorage” : {“Default”: “5”,
 “Description” : “The size of the database (Gb)”,
 “Type”: “Number”,
 “MinValue”: “5”,
 “MaxValue”: “1024”,
 “ConstraintDescription” : “must be between 5 and 1024Gb.”
 },
 “SSHLocation” : {
 “Description” : ” The IP address range that can be used to SSH to the EC2 instances”,
 “MinLength”: “9”,
 “MaxLength”: “18”,
 “Default”: “0.0.0.0/0”,
 “AllowedPattern”: “(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.”
 }
 },
 //EC2的配置与CPU架构的映射关系.t1.micro是EC2的一个配置,用户只能选择某个EC2配置,而不能随意指定.//EC2的配置包含CPU内存的配置.
 “Mappings” : {
 “AWSInstanceType2Arch” : {
 “t1.micro” : { “Arch” : “64” },
 “m1.small” : { “Arch” : “64” },
 “m1.medium” : { “Arch” : “64” },
 “m1.large” : { “Arch” : “64” },
 “m1.xlarge” : { “Arch” : “64” },
 “m2.xlarge” : { “Arch” : “64” },
 “m2.2xlarge” : { “Arch” : “64” },
 “m2.4xlarge” : { “Arch” : “64” },
 “m3.xlarge” : { “Arch” : “64” },
 “m3.2xlarge” : { “Arch” : “64” },
 “c1.medium” : { “Arch” : “64” },
 “c1.xlarge” : { “Arch” : “64” },
 “cc1.4xlarge” : { “Arch” : “64HVM” },
 “cc2.8xlarge” : { “Arch” : “64HVM” },
 “cg1.4xlarge” : { “Arch” : “64HVM” }
 },
 //AMI与CPU架构和AWS Zone的映射关系.AMI是AWS Machine Image,对应传统服务器就是镜像.“AWSRegionArch2AMI” : {
 “us-east-1” : { “32” : “ami-31814f58”,“64” : “ami-1b814f72”,“64HVM” : “ami-0da96764” },
 “us-west-2” : { “32” : “ami-38fe7308”,“64” : “ami-30fe7300”,“64HVM” : “NOT_YET_SUPPORTED” },
 “us-west-1” : { “32” : “ami-11d68a54”,“64” : “ami-1bd68a5e”,
 “eu-west-1” : { “32” : “ami-973b06e3”,“64” : “ami-953b06e1”,
 “ap-southeast-1” : { “32” : “ami-b4b0cae6”,“64” : “ami-beb0caec”,
 “ap-southeast-2” : { “32” : “ami-b3990e89”,“64” : “ami-bd990e87”,
 “ap-northeast-1” : { “32” : “ami-0644f007”,“64” : “ami-0a44f00b”,
 “sa-east-1” : { “32” : “ami-3e3be423”,“64” : “ami-3c3be421”,“64HVM” : “NOT_YET_SUPPORTED” }
 }
 },
 //资源的申明.必选.//AWS定义了一个资源清单,每个资源有一个Type,Type的值只能从已有的资源类型选择,不能随意指定.
 “Resources” : {
 //申请一个EC2实例.这个实例的逻辑名称为WebServer.//每个资源有一个逻辑名称,在Stack中唯一;当资源创建出来之后,有一个全局唯一的物理ID(PhysicalID),由AWS分配.逻辑名称与PhysicalID对应.
 “WebServer”: {
 “Type”: “AWS::EC2::Instance”,
 “Metadata” : {
 “AWS::CloudFormation::Init” : {
 “config” : {
 “packages” : {
 “yum” : {
 “httpd” : [],
 “php” : [],
 “php-mysql” : []
 }
 },
 “sources” : {
 “/var/www/html” : “http://wordpress.org/latest.tar.gz”
 },
 “files” : {
 “/var/www/html/wordpress/wp-config.php” : {
 “content” : { “Fn::Join” : [“”,[
 “<?phpn”,
 “define(‘DB_NAME’,‘”,{“Ref” : “DBName”},“‘);n”,
 “define(‘DB_USER’,{“Ref” : “DBUsername”},
 “define(‘DB_PASSWORD’,{“Ref” : “DBPassword” },
 “define(‘DB_HOST’,{“Fn::GetAtt” : [“DBInstance”,“Endpoint.Address”]},”‘);n”,
 “define(‘DB_CHARSET’,‘utf8’);n”,
 “define(‘DB_COLLATE’,”);n”
 ]] },
 “mode” : “000644”,
 “owner” : “root”,
 “group” : “root”
 }
 },
 “services” : {
 “sysvinit” : {
 “httpd” : { “enabled” : “true”,“ensureRunning” : “true” },
 “sendmail” : { “enabled” : “false”,“ensureRunning” : “false” }
 }
 }
 }
 }
 },
 “Properties”: {
 //在属性中指定EC2的镜像包AMI.Stack支持FindInMap函数和Ref函数.
 //ImageId的值就是通过在AWSRegionArch2AMI这个Map中找指定Zone的镜像.
 //其中Zone的名称引用引用AWS::Region这个全局函数返回的值,就是获取当前租户的Zone.
 “ImageId” : { “Fn::FindInMap” : [ “AWSRegionArch2AMI”,{ “Ref” : “AWS::Region” },
 { “Fn::FindInMap” : [ “AWSInstanceType2Arch”,{ “Ref” : “InstanceType” },“Arch” ] } ] },
 //EC2实例的类型,引用前面Paramters定义的InstanceType值,这个值由用户输入.
 “InstanceType” : { “Ref” : “InstanceType” },
 “SecurityGroups” : [ {“Ref” : “WebServerSecurityGroup”} ],
 “KeyName” : { “Ref” : “KeyName” },
 (编辑:宣城站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |