

This is the new *Amazon CloudFormation Template Reference Guide*. Please update your bookmarks and links. For help getting started with CloudFormation, see the [Amazon CloudFormation User Guide](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/Welcome.html).

# AWS::GreengrassV2::ComponentVersion
<a name="aws-resource-greengrassv2-componentversion"></a>

Creates a component. Components are software that run on Amazon IoT Greengrass core devices. After you develop and test a component on your core device, you can use this operation to upload your component to Amazon IoT Greengrass. Then, you can deploy the component to other core devices.

You can use this operation to do the following:
+  **Create components from recipes** 

  Create a component from a recipe, which is a file that defines the component's metadata, parameters, dependencies, lifecycle, artifacts, and platform capability. For more information, see [Amazon IoT Greengrass component recipe reference](https://docs.amazonaws.cn/greengrass/v2/developerguide/component-recipe-reference.html) in the *Amazon IoT Greengrass V2 Developer Guide*.

  To create a component from a recipe, specify `inlineRecipe` when you call this operation.
+  **Create components from Lambda functions** 

  Create a component from an Amazon Lambda function that runs on Amazon IoT Greengrass. This creates a recipe and artifacts from the Lambda function's deployment package. You can use this operation to migrate Lambda functions from Amazon IoT Greengrass V1 to Amazon IoT Greengrass V2.

  This function accepts Lambda functions in all supported versions of Python, Node.js, and Java runtimes. Amazon IoT Greengrass doesn't apply any additional restrictions on deprecated Lambda runtime versions.

  To create a component from a Lambda function, specify `lambdaFunction` when you call this operation.

## Syntax
<a name="aws-resource-greengrassv2-componentversion-syntax"></a>

To declare this entity in your Amazon CloudFormation template, use the following syntax:

### JSON
<a name="aws-resource-greengrassv2-componentversion-syntax.json"></a>

```
{
  "Type" : "AWS::GreengrassV2::ComponentVersion",
  "Properties" : {
      "[InlineRecipe](#cfn-greengrassv2-componentversion-inlinerecipe)" : String,
      "[LambdaFunction](#cfn-greengrassv2-componentversion-lambdafunction)" : LambdaFunctionRecipeSource,
      "[Tags](#cfn-greengrassv2-componentversion-tags)" : {Key: Value, ...}
    }
}
```

### YAML
<a name="aws-resource-greengrassv2-componentversion-syntax.yaml"></a>

```
Type: AWS::GreengrassV2::ComponentVersion
Properties:
  [InlineRecipe](#cfn-greengrassv2-componentversion-inlinerecipe): String
  [LambdaFunction](#cfn-greengrassv2-componentversion-lambdafunction): 
    LambdaFunctionRecipeSource
  [Tags](#cfn-greengrassv2-componentversion-tags): 
    Key: Value
```

## Properties
<a name="aws-resource-greengrassv2-componentversion-properties"></a>

`InlineRecipe`  <a name="cfn-greengrassv2-componentversion-inlinerecipe"></a>
The recipe to use to create the component. The recipe defines the component's metadata, parameters, dependencies, lifecycle, artifacts, and platform compatibility.  
You must specify either `InlineRecipe` or `LambdaFunction`.  
*Required*: No  
*Type*: String  
*Update requires*: [Replacement](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-replacement)

`LambdaFunction`  <a name="cfn-greengrassv2-componentversion-lambdafunction"></a>
The parameters to create a component from a Lambda function.  
You must specify either `InlineRecipe` or `LambdaFunction`.  
*Required*: No  
*Type*: [LambdaFunctionRecipeSource](aws-properties-greengrassv2-componentversion-lambdafunctionrecipesource.md)  
*Update requires*: [Replacement](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-replacement)

`Tags`  <a name="cfn-greengrassv2-componentversion-tags"></a>
Application-specific metadata to attach to the component version. You can use tags in IAM policies to control access to Amazon IoT Greengrass resources. You can also use tags to categorize your resources. For more information, see [Tag your Amazon IoT Greengrass Version 2 resources](https://docs.amazonaws.cn/greengrass/v2/developerguide/tag-resources.html) in the *Amazon IoT Greengrass V2 Developer Guide*.  
This `Json` property type is processed as a map of key-value pairs. It uses the following format, which is different from most `Tags` implementations in Amazon CloudFormation templates.  

```
"Tags": {
    "KeyName0": "value",
    "KeyName1": "value",
    "KeyName2": "value"
}
```
*Required*: No  
*Type*: Object of String  
*Pattern*: `^(?!aws:)[a-zA-Z+-=._:/]{1,128}$`  
*Maximum*: `256`  
*Update requires*: [No interruption](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

## Return values
<a name="aws-resource-greengrassv2-componentversion-return-values"></a>

### Ref
<a name="aws-resource-greengrassv2-componentversion-return-values-ref"></a>

When you pass the logical ID of this resource to the intrinsic `Ref` function, `Ref` returns the `Arn`.

For more information about using the `Ref` function, see [https://docs.amazonaws.cn/AWSCloudFormation/latest/TemplateReference/intrinsic-function-reference-ref.html](https://docs.amazonaws.cn/AWSCloudFormation/latest/TemplateReference/intrinsic-function-reference-ref.html).

### Fn::GetAtt
<a name="aws-resource-greengrassv2-componentversion-return-values-fn--getatt"></a>

The `Fn::GetAtt` intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.

For more information about using the `Fn::GetAtt` intrinsic function, see [https://docs.amazonaws.cn/AWSCloudFormation/latest/TemplateReference/intrinsic-function-reference-getatt.html](https://docs.amazonaws.cn/AWSCloudFormation/latest/TemplateReference/intrinsic-function-reference-getatt.html).

#### 
<a name="aws-resource-greengrassv2-componentversion-return-values-fn--getatt-fn--getatt"></a>

`Arn`  <a name="Arn-fn::getatt"></a>
The ARN of the component version.

`ComponentName`  <a name="ComponentName-fn::getatt"></a>
The name of the component.

`ComponentVersion`  <a name="ComponentVersion-fn::getatt"></a>
The version of the component.