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

AWS::Greengrass::ResourceDefinition

AWS::Greengrass::ResourceDefinition 资源表示 AWS IoT Greengrass 的资源定义。资源定义用于组织资源定义版本。

资源定义可引用多个资源定义版本。所有资源定义版本都必须与资源定义关联。每个资源定义版本均可包含一个或多个资源。(在 AWS CloudFormation 中,资源是命名的资源实例。)

注意

在创建资源定义时,您可以选择包含初始资源定义版本。要稍后关联资源定义版本,请创建 AWS::Greengrass::ResourceDefinitionVersion 资源并指定该资源定义的 ID。

在创建包含要部署的资源的资源定义版本后,您必须将其添加到组版本。有关更多信息,请参阅 AWS::Greengrass::Group

语法

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

JSON

{ "Type" : "AWS::Greengrass::ResourceDefinition", "Properties" : { "InitialVersion" : ResourceDefinitionVersion, "Name" : String, "Tags" : Json } }

YAML

Type: AWS::Greengrass::ResourceDefinition Properties: InitialVersion: ResourceDefinitionVersion Name: String Tags: Json

属性

InitialVersion

在创建资源定义时要包含的资源定义版本。资源定义版本包含 resource instance 属性类型的列表。

注意

要在创建资源定义后关联资源定义版本,请创建 AWS::Greengrass::ResourceDefinitionVersion 资源并指定此资源定义的 ID。

必需:否

类型ResourceDefinitionVersion

Update requires: Replacement

Name

资源定义的名称。

必需:是

类型:字符串

Update requires: No interruption

Tags

要附加到资源定义的特定于应用程序的元数据。您可以在 IAM 策略中使用标签来控制对 AWS IoT Greengrass 资源的访问。您还可以使用标签对资源进行分类。有关更多信息,请参阅AWS IoT Greengrass 开发人员指南中的标记您的 AWS IoT Greengrass 资源

Json 属性类型作为键值对的映射处理。它使用以下格式,这不同于 AWS CloudFormation 模板中的大部分 Tags 实施。

"Tags": { "KeyName0": "value", "KeyName1": "value", "KeyName2": "value" }

必需:否

类型:Json

Update requires: No interruption

返回值

Ref

在将此资源的逻辑 ID 传递给内部 Ref 函数时,Ref 返回资源定义的 ID,例如 1234a5b6-78cd-901e-2fgh-3i45j6k178l9

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

Fn::GetAtt

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

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

Arn

ResourceDefinition 的 Amazon 资源名称 (ARN),例如 arn:aws:greengrass:us-east-1:123456789012:/greengrass/definition/resources/1234a5b6-78cd-901e-2fgh-3i45j6k178l9

Id

ResourceDefinition 的 ID,例如 1234a5b6-78cd-901e-2fgh-3i45j6k178l9

LatestVersionArn

已添加到 ResourceDefinition 的最新 ResourceDefinitionVersion 的 ARN,例如 arn:aws:greengrass:us-east-1:123456789012:/greengrass/definition/resources/1234a5b6-78cd-901e-2fgh-3i45j6k178l9/versions/9876ac30-4bdb-4f9d-95af-b5fdb66be1a2

Name

ResourceDefinition 的名称,例如 MyResourceDefinition

示例

资源定义代码段

以下代码段使用包含每种资源的初始版本定义资源定义资源。

有关完整模板的示例,请参阅 AWS::Greengrass::Group 资源。

JSON

"TestResourceDefinition": { "Type": "AWS::Greengrass::ResourceDefinition", "Properties": { "Name": "DemoTestResourceDefinition", "InitialVersion": { "Resources": [ { "Id": "ResourceId1", "Name": "LocalDeviceResource", "ResourceDataContainer": { "LocalDeviceResourceData": { "SourcePath": "/dev/TestSourcePath1", "GroupOwnerSetting": { "AutoAddGroupOwner": "false", "GroupOwner": "TestOwner" } } } }, { "Id": "ResourceId2", "Name": "LocalVolumeResourceData", "ResourceDataContainer": { "LocalVolumeResourceData": { "SourcePath": "/dev/TestSourcePath2", "DestinationPath": "/volumes/TestDestinationPath2", "GroupOwnerSetting": { "AutoAddGroupOwner": "false", "GroupOwner": "TestOwner" } } } }, { "Id": "ResourceId3", "Name": "SageMakerMachineLearningModelResourceData", "ResourceDataContainer": { "SageMakerMachineLearningModelResourceData": { "SageMakerJobArn": { "Fn::Join": [ ":", [ "arn:aws:sagemaker", { "Ref": "AWS::Region" }, { "Ref": "AWS::AccountId" }, "training-job/testJob" ] ] }, "DestinationPath": "/sagemakermodels/TestDestinationPath3" } } }, { "Id": "ResourceId4", "Name": "S3MachineLearningModelResourceData", "ResourceDataContainer": { "S3MachineLearningModelResourceData": { "S3Uri": "http://testBucket.s3.amazonaws.com/testUri.zip", "DestinationPath": "/mlModels/TestDestinationPath4" } } }, { "Id": "ResourceId5", "Name": "SecretsManagerSecretResourceData", "ResourceDataContainer": { "SecretsManagerSecretResourceData": { "ARN": { "Fn::Join": [ ":", [ "arn:aws:secretsmanager", { "Ref": "AWS::Region" }, { "Ref": "AWS::AccountId" }, "secret:testARN" ] ] }, "AdditionalStagingLabelsToDownload": [ "label1", "label2" ] } } } ] } } }

YAML

TestResourceDefinition: Type: 'AWS::Greengrass::ResourceDefinition' Properties: Name: DemoTestResourceDefinition TestResourceDefinitionVersion: Type: 'AWS::Greengrass::ResourceDefinitionVersion' Properties: ResourceDefinitionId: !Ref TestResourceDefinition Resources: - Id: ResourceId1 Name: LocalDeviceResource ResourceDataContainer: LocalDeviceResourceData: SourcePath: /dev/TestSourcePath1 GroupOwnerSetting: AutoAddGroupOwner: 'false' GroupOwner: TestOwner - Id: ResourceId2 Name: LocalVolumeResourceData ResourceDataContainer: LocalVolumeResourceData: SourcePath: /dev/TestSourcePath2 DestinationPath: /volumes/TestDestinationPath2 GroupOwnerSetting: AutoAddGroupOwner: 'false' GroupOwner: TestOwner - Id: ResourceId3 Name: SageMakerMachineLearningModelResourceData ResourceDataContainer: SageMakerMachineLearningModelResourceData: SageMakerJobArn: !Join - ':' - - 'arn:aws:sagemaker' - !Ref 'AWS::Region' - !Ref 'AWS::AccountId' - training-job/testJob DestinationPath: /sagemakermodels/TestDestinationPath3 - Id: ResourceId4 Name: S3MachineLearningModelResourceData ResourceDataContainer: S3MachineLearningModelResourceData: S3Uri: 'http://testBucket.s3.amazonaws.com/testUri.zip' DestinationPath: /mlModels/TestDestinationPath4 - Id: ResourceId5 Name: SecretsManagerSecretResourceData ResourceDataContainer: SecretsManagerSecretResourceData: ARN: !Join - ':' - - 'arn:aws:secretsmanager' - !Ref 'AWS::Region' - !Ref 'AWS::AccountId' - 'secret:testARN' AdditionalStagingLabelsToDownload: - label1 - label2

另请参阅