AWS CloudFormation
User Guide (API Version 2010-05-15)
AWS 服务或AWS文档中描述的功能,可能因地区/位置而异。请点击 Amazon AWS 入门,可查看中国地区的具体差异

AWS CloudFormation 堆栈参数

类型 ParametersAWS::CloudFormation::Stack 类型的嵌入式属性。

Parameters 类型包含一组值对,这些值对表示将传递到用于创建 AWS::CloudFormation::Stack 资源的模板的参数。每个参数都具有对应于该嵌入式模板中定义的参数的名称,以及表示要为该参数设置的值。例如,示例模板 EC2ChooseAMI.template 包含以下 Parameters 部分:

JSON

"Parameters" : { "InstanceType" : { "Type" : "String", "Default" : "m1.small", "Description" : "EC2 instance type, e.g. m1.small, m1.large, etc." }, "WebServerPort" : { "Type" : "String", "Default" : "80", "Description" : "TCP/IP port of the web server" }, "KeyName" : { "Type" : "String", "Description" : "Name of an existing EC2 KeyPair to enable SSH access to the web server" } }

YAML

Parameters: InstanceType: Type: "String" Default: "m1.small" Description: "EC2 instance type, e.g. m1.small, m1.large, etc." WebServerPort: Type: "String" Default: "80" Description: "TCP/IP port of the web server" KeyName: Type: "String" Description: "Name of an existing EC2 KeyPair to enable SSH access to the web server"

嵌套堆栈

您可以使用以下模板来嵌入使用 EC2ChooseAMI.template 的堆栈 (myStackWithParams),并使用 AWS::CloudFormation::Stack 资源中的 Parameters 属性来指定 InstanceType 和 KeyName:

JSON

{ "AWSTemplateFormatVersion" : "2010-09-09", "Resources" : { "myStackWithParams" : { "Type" : "AWS::CloudFormation::Stack", "Properties" : { "TemplateURL" : "https://s3.amazonaws.com/cloudformation-templates-us-east-1/EC2ChooseAMI.template", "Parameters" : { "InstanceType" : "t1.micro", "KeyName" : "mykey" } } } } }

YAML

AWSTemplateFormatVersion: "2010-09-09" Resources: myStackWithParams: Type: "AWS::CloudFormation::Stack" Properties: TemplateURL: "https://s3.amazonaws.com/cloudformation-templates-us-east-1/EC2ChooseAMI.template" Parameters: InstanceType: "t1.micro" KeyName: "mykey"

本页内容: