本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
規格格式
CloudFormation 會為每個資源類型建立規格,例如 AWS::S3::Bucket
或 AWS::EC2::Instance
。下列各節會說明格式及規格的每個欄位。
規格區段
每種資源類型的正式定義分為三大區段:PropertyTypes
、ResourceSpecificationVersion
和 ResourceTypes
,如下列範例所示:
{ "PropertyTypes": { Property specifications }, "ResourceSpecificationVersion": "
Specification version number
", "ResourceTypes": { Resource specification } }
PropertyTypes
-
在屬性內有屬性 (也稱為子屬性) 的資源,為子屬性規格清單,例如需要哪些屬性、每個屬性允許的值類型及其更新行為。如需詳細資訊,請參閱屬性規格。
如果資源沒有子屬性,會略過這個區段。
ResourceSpecificationVersion
-
資源規格的版本。版本格式為
,每個版次都會增加版本號碼。無論資源是否更新,所有資源都有相同的版本號碼。majorVersion
.minorVersion
.patch
CloudFormation 當服務進行回溯相容的錯誤修正時,例如修正損毀的文件連結, 會增加修補程式編號。當 CloudFormation 新增向下相容的資源或屬性時,它會遞增次要版本編號。例如,較新版本的規格可能會新增其他資源屬性,以支援 AWS 服務的新功能。
回溯不相容變更會遞增主要版本號碼。回溯不相容變更的成因可能是資源規格變更 (例如欄位的名稱變更),或資源變更 (例如建立選用資源屬性)。
ResourceTypes
-
每個資源屬性的資源和資訊清單,例如其屬性名稱、所需屬性,以及其更新行為。如需詳細資訊,請參閱資源規格。
注意
如果您檢視包含一個資源類型定義的檔案,此屬性名稱為
ResourceType
(單數)。
屬性規格
每個屬性的規格都包含下列欄位。子屬性的屬性名稱使用
格式。resourceType
.subpropertyName
"
Property name
": { "Documentation": "Link to the relevant documentation
" "DuplicatesAllowed": "true or false
", "ItemType": "Type of list or map (non-primitive)
", "PrimitiveItemType": "Type of list or map (primitive)
", "PrimitiveType": "Type of value (primitive)
", "Required": "true or false
", "Type": "Type of value (non-primitive)
", "UpdateType": "Mutable, Immutable, or Conditional
", }
Documentation
-
《AWS CloudFormation 使用者指南》的連結,提供有關屬性的資訊。
DuplicatesAllowed
-
如果
Type
欄位的值為List
,則指出 是否 CloudFormation 允許重複的值。如果該值為true
,則 CloudFormation 會忽略重複的值。如果值為false
,則提交重複值時, 會 CloudFormation 傳回錯誤。 ItemType
-
如果
Type
欄位的值是List
或Map
,會指示清單或映射的類型是否包含非基本類型。否則,略過此欄位。針對包含基本類型的清單或映射,PrimitiveItemType
屬性會指示有效的值類型。子屬性名稱是有效的項目類型。例如,如果類型值是
List
而項目類型值是PortMapping
,您可以指定連接埠映射屬性的清單。 PrimitiveItemType
-
如果
Type
欄位的值是List
或Map
,會指示清單或映射的類型是否包含基本類型。否則,略過此欄位。針對包含非基本類型的清單或映射,ItemType
屬性會指示有效的值類型。有效的清單和映射基本類型為
String
、Long
、Integer
、Double
、Boolean
或Timestamp
。例如,如果類型值是
List
而項目類型值是String
,您可以指定屬性的字串清單。如果類型值是Map
而項目類型值是Boolean
,您可以指定屬性的布林值映射字串。 PrimitiveType
-
針對基本值,為屬性的有效基本類型。基本類型是資源屬性值的基本資料類型。有效的基本類型為
String
、Long
、Integer
、Double
、Boolean
、Timestamp
或Json
。如果有效值為非基本類型,則略過此欄位,且Type
欄位會指示有效值類型。 Required
-
指示屬性是否為必要。
Type
-
針對非基本類型,為屬性的有效值。有效的類型是子屬性名稱
List
或Map
。如果有效值為基本類型,則略過此欄位,且PrimitiveType
欄位會指示有效值類型。清單是以逗號分隔的值清單。映射是一組鍵/值對,其中的金鑰一律為字串。清單和映射的值類型由
ItemType
或PrimitiveItemType
欄位指示。 UpdateType
-
在堆疊更新期間,當您新增、移除或修改 屬性時的更新行為。當您變更不可變屬性時, 會 CloudFormation 取代資源。 CloudFormation當您變更不可變屬性時, 不會取代資源。條件式更新可變或不可變,例如,取決於您更新的其他屬性。如需詳細資訊,請參閱相關的資源類型文件。
資源規格
每個資源類型的規格都包含下列欄位。
"
Resource type name
": { "Attributes": { "AttributeName
": { "ItemType": "Return list or map type (non-primitive)
", "PrimitiveItemType": "Return list or map type (primitive)
", "PrimitiveType": "Return value type (primitive)
", "Type": "Return value type (non-primitive)
", } }, "Documentation": "Link to the relevant documentation
", "Properties": { Property specifications } }
Attributes
-
您可以在 Fn::GetAtt 函數中使用的資源屬性清單。對於每個屬性,本節提供屬性名稱和 CloudFormation 傳回的值類型。
ItemType
-
如果
Type
欄位的值是List
,指示清單包含非基本類型時,Fn::GetAtt
函數傳回的屬性清單類型。有效的類型是屬性名稱。 PrimitiveItemType
-
如果
Type
欄位的值是List
,指示清單包含基本類型時,Fn::GetAtt
函數傳回的屬性清單類型。針對包含非基本類型的清單,ItemType
屬性會指示有效的值類型。有效的清單基本類型為String
、Long
、Integer
、Double
、Boolean
或Timestamp
。例如,如果類型值是
List
而基本項目類型值是String
,則Fn::GetAtt
函數會傳回字串清單。 PrimitiveType
-
針對基本傳回值,為
Fn::GetAtt
函數傳回的屬性基本值類型。基本類型是資源屬性值的基本資料類型。有效的基本類型為String
、Long
、Integer
、Double
、Boolean
、Timestamp
或Json
。 Type
-
針對非基本傳回值,為
Fn::GetAtt
函數傳回的屬性值類型。有效的類型是屬性名稱或List
。清單是以逗號分隔的值清單。清單的值類型由
ItemType
或PrimitiveItemType
欄位指示。
Documentation
-
《AWS CloudFormation 使用者指南》的連結,提供有關資源的資訊。
Properties
-
資源的屬性規格清單。如需詳細資訊,請參閱 屬性規格。
範例資源規格
下列範例強調和說明 AWS::Elasticsearch::Domain
資源規格的部分。
AWS::Elasticsearch::Domain
資源類型包含子屬性,因此規格包含 PropertyTypes
區段。此區段後面接著 ResourceSpecificationVersion
區段,規格版本顯示為 1.0.0
。規格版本之後是指定資源類型的 ResourceType
區段,提供文件連結及資源屬性的詳細資訊。
{ "PropertyTypes": { ... }, "ResourceSpecificationVersion": "1.0.0", "ResourceType": { "AWS::Elasticsearch::Domain": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticsearch-domain.html", "Properties": { ... } } } } }
聚焦於 ResourceType
區段,下列範例會顯示 AWS::Elasticsearch::Domain
資源類型的兩個屬性。AdvancedOptions
屬性非為必要,且能接受字串對字串映射。映射是一組鍵/值對,其中的金鑰一律為字串。值類型由 ItemType
欄位指示,它是 String
。因此,類型是字串映射的字串。此屬性的更新行為是可變的。如果更新此屬性, 會 CloudFormation 保留資源,而不是建立新的資源,然後刪除舊資源 (不可變的更新)。
SnapshotOptions
屬性非為必要,且接受名為 SnapshotOptions
的子屬性。SnapshotOptions
區段提供 PropertyTypes
子屬性的詳細資訊。
{ "PropertyTypes": { ... }, "ResourceSpecificationVersion": "1.0.0", "ResourceType": { "AWS::Elasticsearch::Domain": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticsearch-domain.html", "Properties": { ... "AdvancedOptions": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticsearch-domain.html#cfn-elasticsearch-domain-advancedoptions", "DuplicatesAllowed": false, "PrimitiveItemType": "String", "Required": false, "Type": "Map", "UpdateType": "Mutable" }, ... "SnapshotOptions": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticsearch-domain.html#cfn-elasticsearch-domain-snapshotoptions", "Required": false, "Type": "SnapshotOptions", "UpdateType": "Mutable" }, ... } } } }
在 PropertyTypes
中,規格列出資源的所有子屬性 (包括巢狀子屬性)。下列範例詳細說明 AWS::Elasticsearch::Domain.SnapshotOptions
子屬性。其包含名為 AutomatedSnapshotStartHour
的屬性,此屬性非為必要,且接受整數值類型。
"PropertyTypes": { ... "AWS::Elasticsearch::Domain.SnapshotOptions": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-elasticsearch-domain-snapshotoptions.html", "Properties": { "AutomatedSnapshotStartHour": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-elasticsearch-domain-snapshotoptions.html#cfn-elasticsearch-domain-snapshotoptions-automatedsnapshotstarthour", "PrimitiveType": "Integer", "Required": false, "UpdateType": "Mutable" } } }, ... }
下列範例提供完整 AWS::Elasticsearch::Domain
資源規格供您參考。
{ "PropertyTypes": { "AWS::Elasticsearch::Domain.EBSOptions": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-elasticsearch-domain-ebsoptions.html", "Properties": { "EBSEnabled": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-elasticsearch-domain-ebsoptions.html#cfn-elasticsearch-domain-ebsoptions-ebsenabled", "PrimitiveType": "Boolean", "Required": false, "UpdateType": "Mutable" }, "Iops": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-elasticsearch-domain-ebsoptions.html#cfn-elasticsearch-domain-ebsoptions-iops", "PrimitiveType": "Integer", "Required": false, "UpdateType": "Mutable" }, "VolumeSize": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-elasticsearch-domain-ebsoptions.html#cfn-elasticsearch-domain-ebsoptions-volumesize", "PrimitiveType": "Integer", "Required": false, "UpdateType": "Mutable" }, "VolumeType": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-elasticsearch-domain-ebsoptions.html#cfn-elasticsearch-domain-ebsoptions-volumetype", "PrimitiveType": "String", "Required": false, "UpdateType": "Mutable" } } }, "AWS::Elasticsearch::Domain.ElasticsearchClusterConfig": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-elasticsearch-domain-elasticsearchclusterconfig.html", "Properties": { "DedicatedMasterCount": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-elasticsearch-domain-elasticsearchclusterconfig.html#cfn-elasticsearch-domain-elasticseachclusterconfig-dedicatedmastercount", "PrimitiveType": "Integer", "Required": false, "UpdateType": "Mutable" }, "DedicatedMasterEnabled": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-elasticsearch-domain-elasticsearchclusterconfig.html#cfn-elasticsearch-domain-elasticseachclusterconfig-dedicatedmasterenabled", "PrimitiveType": "Boolean", "Required": false, "UpdateType": "Mutable" }, "DedicatedMasterType": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-elasticsearch-domain-elasticsearchclusterconfig.html#cfn-elasticsearch-domain-elasticseachclusterconfig-dedicatedmastertype", "PrimitiveType": "String", "Required": false, "UpdateType": "Mutable" }, "InstanceCount": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-elasticsearch-domain-elasticsearchclusterconfig.html#cfn-elasticsearch-domain-elasticseachclusterconfig-instancecount", "PrimitiveType": "Integer", "Required": false, "UpdateType": "Mutable" }, "InstanceType": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-elasticsearch-domain-elasticsearchclusterconfig.html#cfn-elasticsearch-domain-elasticseachclusterconfig-instancetype", "PrimitiveType": "String", "Required": false, "UpdateType": "Mutable" }, "ZoneAwarenessEnabled": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-elasticsearch-domain-elasticsearchclusterconfig.html#cfn-elasticsearch-domain-elasticseachclusterconfig-zoneawarenessenabled", "PrimitiveType": "Boolean", "Required": false, "UpdateType": "Mutable" } } }, "AWS::Elasticsearch::Domain.SnapshotOptions": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-elasticsearch-domain-snapshotoptions.html", "Properties": { "AutomatedSnapshotStartHour": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-elasticsearch-domain-snapshotoptions.html#cfn-elasticsearch-domain-snapshotoptions-automatedsnapshotstarthour", "PrimitiveType": "Integer", "Required": false, "UpdateType": "Mutable" } } }, "Tag": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-resource-tags.html", "Properties": { "Key": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-resource-tags.html#cfn-resource-tags-key", "PrimitiveType": "String", "Required": true, "UpdateType": "Immutable" }, "Value": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-resource-tags.html#cfn-resource-tags-value", "PrimitiveType": "String", "Required": true, "UpdateType": "Immutable" } } } }, "ResourceType": { "AWS::Elasticsearch::Domain": { "Attributes": { "DomainArn": { "PrimitiveType": "String" }, "DomainEndpoint": { "PrimitiveType": "String" } }, "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticsearch-domain.html", "Properties": { "AccessPolicies": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticsearch-domain.html#cfn-elasticsearch-domain-accesspolicies", "PrimitiveType": "Json", "Required": false, "UpdateType": "Mutable" }, "AdvancedOptions": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticsearch-domain.html#cfn-elasticsearch-domain-advancedoptions", "DuplicatesAllowed": false, "PrimitiveItemType": "String", "Required": false, "Type": "Map", "UpdateType": "Mutable" }, "DomainName": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticsearch-domain.html#cfn-elasticsearch-domain-domainname", "PrimitiveType": "String", "Required": false, "UpdateType": "Immutable" }, "EBSOptions": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticsearch-domain.html#cfn-elasticsearch-domain-ebsoptions", "Required": false, "Type": "EBSOptions", "UpdateType": "Mutable" }, "ElasticsearchClusterConfig": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticsearch-domain.html#cfn-elasticsearch-domain-elasticsearchclusterconfig", "Required": false, "Type": "ElasticsearchClusterConfig", "UpdateType": "Mutable" }, "ElasticsearchVersion": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticsearch-domain.html#cfn-elasticsearch-domain-elasticsearchversion", "PrimitiveType": "String", "Required": false, "UpdateType": "Immutable" }, "SnapshotOptions": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticsearch-domain.html#cfn-elasticsearch-domain-snapshotoptions", "Required": false, "Type": "SnapshotOptions", "UpdateType": "Mutable" }, "Tags": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticsearch-domain.html#cfn-elasticsearch-domain-tags", "DuplicatesAllowed": true, "ItemType": "Tag", "Required": false, "Type": "List", "UpdateType": "Mutable" } } } }, "ResourceSpecificationVersion": "1.4.1" }