| 
                        副标题[/!--empirenews.page--]
                         《理解亚马逊 Amazon AWS CloudFormation》要点: 本文介绍了理解亚马逊 Amazon AWS CloudFormation,希望对您有用。如果有疑问,可以联系我们。 
			             
Amazon最初始推出AWS时候,提供给用户的是虚拟机(EC2),存储(Volume),弹性IP(Elastic IP)等这些在云计算中被划分为基础设施层(I层)的资源. 
稍后AWS又推出了RDS(Relation Database Service),用户可以申请MySQL,Oracle,Postgres,SQLServer这些数据库实例(DBInstance).这个在云计算中被划分为平台层(P层). 
到目前位置,AWS的利润也只是上面说到的I层和P层资源得到,用户只有使用了这些资源,才需要付费. 
AWS为了方便用户申请这些资源.开发了CloudFormation这个工具. 
CloudFormation实现的功能是维护一个资源申请模版的生命周期.包括资源的申明,创建,销毁,监控(通过CloudWatch监控,CloudWatch是AWS提供的监控服务). 
这个模板在AWS中命名为Stack. 
因此我们学习CloudFormation,就是需要掌握Stack的含义. 
在学习Stack之前,需要再补充说明亮点: 
- AWS根据一些用户典型场景,定义了一些典型场景下的Stack模版,供用户使用.如安装一个WordPress服务器的模板.安装Wordpress服务器,需要至少一个服务器,一个EIP,一个MySQL实例.
 
- Stack模板中有很多关于安全的资源定义,如SecurityGroup,这些我们不讲解.我们只关注I层和P层资源的申请.
 
 
我们以Wordpress的Stack模板,讲解如何通过Stack申请资源(I层和P层资源).我们以注解方式说明,绿色为注解. 
讲解使用的Sample Stack下载地址:https://s3.amazonaws.com/cloudformation-templates-us-east-1/WordPress_Single_Instance_With_RDS.template 
Stack是一个JSON文件. 
{ 
//Stack的版本信息,下面的JSON格式是2010-09-09版本的. 
“AWSTemplateFormatVersion” : “2010-09-09”, 
//Stack描述信息 
“Description” : “AWS CloudFormation Sample Template WordPress_Single_Instance_With_RDS: WordPress is web software you can use to create a beautiful website or blog. This template installs a single-instance WordPress deployment using an Amazon RDS database instance for storage. It demonstrates using the AWS CloudFormation bootstrap scripts to install packages and files at instance launch time. **WARNING** This template creates an Amazon EC2 instance and an Amazon RDS database instance. You will be billed for the AWS resources used if you create a stack from this template.”, 
//Stack的参数.这些参数会在执行Stack时候,生成界面,让用户输入. 
//参数可以被Stack中其他元素通过名称引用. 
“Parameters” : { 
“KeyName”: { 
“Description” : “Name of an existing EC2 KeyPair to enable SSH access to the instances”, 
“Type”: “String”, 
“MinLength”: “1”, 
“MaxLength”: “255”, 
“AllowedPattern” : “[x20-x7E]*”, 
“ConstraintDescription” : “can contain only ASCII characters.” 
}, 
“InstanceType” : { 
“Description” : “WebServer EC2 instance type”, 
“Type” : “String”, 
“Default” : “m1.small”, 
“AllowedValues” : [ “t1.micro”,”m1.small”,”m1.medium”,”m1.large”,”m1.xlarge”,”m2.xlarge”,”m2.2xlarge”,”m2.4xlarge”,”m3.xlarge”,”m3.2xlarge”,”c1.medium”,”c1.xlarge”,”cc1.4xlarge”,”cc2.8xlarge”,”cg1.4xlarge”], 
“ConstraintDescription” : “must be a valid EC2 instance type.” 
}, 
“DBClass” : { 
“Default” : “db.m1.small”, 
“Description” : “Database instance class”, 
“AllowedValues” : [ “db.m1.small”,“db.m1.large”,“db.m1.xlarge”,“db.m2.xlarge”,“db.m2.2xlarge”,“db.m2.4xlarge” ], 
“ConstraintDescription” : “must select a valid database instance type.” 
}, 
“DBName” : { 
“Default”: “wordpress”, 
“Description” : “The WordPress database name”, 
“MaxLength”: “64”, 
“AllowedPattern” : “[a-zA-Z][a-zA-Z0-9]*”, 
“ConstraintDescription” : “must begin with a letter and contain only alphanumeric characters.” 
}, 
“DBUsername” : { 
“Default”: “admin”, 
“NoEcho”: “true”, 
“Description” : “The WordPress database admin account username”, 
“MaxLength”: “16”, 
“DBPassword” : { 
“Default”: “password”, 
“Description” : “The WordPress database admin account password”, 
“MinLength”: “8”, 
“MaxLength”: “41”, 
“AllowedPattern” : “[a-zA-Z0-9]*”, 
“ConstraintDescription” : “must contain only alphanumeric characters.” 
}, 
                                                (编辑:滁州站长网) 
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! 
                     |