AWS::ImageBuilder::Component - AWS CloudFormation
AWS 文档中描述的 AWS 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅中国的 AWS 服务入门

AWS::ImageBuilder::Component

组件是编排文档,用于定义一系列步骤以下载、安装和配置软件包或定义要在软件包上运行的测试。它们还定义验证和安全强化步骤。组件是使用 YAML 文档格式定义的。有关更多信息,请参阅在 EC2 Image Builder 中使用文档

语法

要在 AWS CloudFormation 模板中声明此实体,请使用以下语法:

JSON

{ "Type" : "AWS::ImageBuilder::Component", "Properties" : { "ChangeDescription" : String, "Data" : String, "Description" : String, "KmsKeyId" : String, "Name" : String, "Platform" : String, "SupportedOsVersions" : [ String, ... ], "Tags" : {Key : Value, ...}, "Uri" : String, "Version" : String } }

YAML

Type: AWS::ImageBuilder::Component Properties: ChangeDescription: String Data: String Description: String KmsKeyId: String Name: String Platform: String SupportedOsVersions: - String Tags: Key : Value Uri: String Version: String

属性

ChangeDescription

组件的更改描述。例如 initial version.

必需:否

类型:字符串

最低1

最高1024

Update requires: Replacement

Data

组件的数据。例如:name: HelloWorldTestingDocument\ndescription: This is hello world testing document.\nschemaVersion: 1.0\n\nphases:\n - name: test\n steps:\n - name: HelloWorldStep\n action: ExecuteBash\n inputs:\n commands:\n - echo \"Hello World! Test.\"\n。有关使用数据创建组件的架构,请参阅下面的示例。

必需:否

类型:字符串

Update requires: Replacement

Description

组件的描述。

必需:否

类型:字符串

最低1

最高1024

Update requires: Replacement

KmsKeyId

用于加密组件的 KMS 密钥标识符。

必需:否

类型:字符串

最低1

最高1024

Update requires: Replacement

Name

组件名称。

必需:是

类型:字符串

模式^[-_A-Za-z-0-9][-_A-Za-z0-9 ]{1,126}[-_A-Za-z-0-9]$

Update requires: Replacement

Platform

组件的平台。例如:Windows

必需:是

类型:字符串

允许的值Linux | Windows

Update requires: Replacement

SupportedOsVersions

组件支持的操作系统 (OS) 版本。如果操作系统信息可用,则会在创建映像配方期间对父映像操作系统版本执行前缀匹配。

必需:否

类型:字符串列表

最高25

Update requires: Replacement

Tags

与组件关联的标签。

必需:否

类型:字符串的映射

Update requires: Replacement

Uri

组件文档的 URI。

必需:否

类型:字符串

Update requires: Replacement

Version

组件版本。例如:1.0.0

必需:是

类型:字符串

模式^[0-9]+\.[0-9]+\.[0-9]+$

Update requires: Replacement

返回值

Ref

在将此资源的逻辑 ID 传递给内部 Ref 函数时,Ref 返回 资源 ARN,如 arn:aws:imagebuilder:us-west-2:123456789012:component/examplecomponent/2019.12.02/1

For more information about using the Ref function, see Ref.

Fn::GetAtt

Fn::GetAtt 内部函数返回此类型的一个指定属性的值。以下为可用属性和示例返回值。

有关使用 Fn::GetAtt 内部函数的更多信息,请参阅 Fn::GetAtt

Arn

返回组件的 Amazon 资源名称 (ARN)。应用以下模式:^arn:aws[^:]*:imagebuilder:[^:]+:(?:\d{12}|aws):(?:image-recipe|infrastructure-configuration|distribution-configuration|component|image|image-pipeline)/[a-z0-9-_]+(?:/(?:(?:x|\d+)\.(?:x|\d+)\.(?:x|\d+))(?:/\d+)?)?$

Encrypted

返回组件的加密状态。例如,truefalse

Type

返回组件类型。例如,BUILDTEST

示例

使用数据创建组件

以下示例同时以 YAML 和 JSON 格式显示 Component 资源文档的架构。此示例包括 Data 字段的详细信息。可以使用 DataUri 字段来引用组件文档。

YAML

Resources: ComponentAllParameters: Type: 'AWS::ImageBuilder::Component' Properties: Name: 'component-name' Platform: 'Linux' Version: "1.0.0" Description: 'description' ChangeDescription: 'change-description' KmsKeyId: 'customer-kms-key-id' Tags: CustomerComponentTagKey1: 'CustomerComponentTagValue1' CustomerComponentTagKey2: 'CustomerComponentTagValue2' # Require one of 'Data' or 'Uri' for Component template Data: | name: HelloWorldTestingLinuxDoc - InlineData description: This is hello world testing doc schemaVersion: 1.0 phases: - name: build steps: - name: HelloWorldStep action: ExecuteBash inputs: commands: - echo "Hello World! Build." - name: validate steps: - name: HelloWorldStep action: ExecuteBash inputs: commands: - echo "Hello World! Validate." - name: test steps: - name: HelloWorldStep action: ExecuteBash inputs: commands: - echo "Hello World! Test."

JSON

{ "Resources": { "ComponentAllParameters": { "Type": "AWS::ImageBuilder::Component", "Properties": { "Name": "component-name", "Platform": "Linux", "Version": "1.0.0", "Description": "description", "ChangeDescription": "change-description", "KmsKeyId": "customer-kms-key-id", "Tags": { "CustomerComponentTagKey1": "CustomerComponentTagValue1", "CustomerComponentTagKey2": "CustomerComponentTagValue2" }, "Data": "name: HelloWorldTestingLinuxDoc - InlineData\ndescription: This is hello world testing doc\nschemaVersion: 1.0\n\nphases:\n - name: build\n steps:\n - name: HelloWorldStep\n action: ExecuteBash\n inputs:\n commands:\n - echo \"Hello World! Build.\"\n - name: validate\n steps:\n - name: HelloWorldStep\n action: ExecuteBash\n inputs:\n commands:\n - echo \"Hello World! Validate.\"\n - name: test\n steps:\n - name: HelloWorldStep\n action: ExecuteBash\n inputs:\n commands:\n - echo \"Hello World! Test.\"\n" } } } }

使用 Uri 创建组件

以下示例同时以 YAML 和 JSON 格式显示 Component 资源文档的架构。此示例包括 Uri 字段的详细信息。可以使用 DataUri 字段来引用组件文档。

YAML

Resources: ComponentAllParameters: Type: 'AWS::ImageBuilder::Component' Properties: Name: 'component-name' Platform: 'Linux' Version: "1.0.0" # Require one of 'Data' or 'Uri' for Component template Uri: 's3://imagebuilder/component_document.yml' Description: 'description' ChangeDescription: 'change-description' KmsKeyId: 'customer-kms-key-id' Tags: CustomerComponentTagKey1: 'CustomerComponentTagValue1' CustomerComponentTagKey2: 'CustomerComponentTagValue2'

JSON

{ "Resources": { "ComponentAllParameters": { "Type": "AWS::ImageBuilder::Component", "Properties": { "Name": "component-name", "Platform": "Linux", "Version": "1.0.0", "Uri": "s3://imagebuilder/component_document.yml", "Description": "description", "ChangeDescription": "change-description", "KmsKeyId": "customer-kms-key-id", "Tags": { "CustomerComponentTagKey1": "CustomerComponentTagValue1", "CustomerComponentTagKey2": "CustomerComponentTagValue2" } } } } }