Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
182 lines (149 sloc) 9.73 KB

AWS::Greengrass::FunctionDefinition

The AWS::Greengrass::FunctionDefinition resource represents a function definition for AWS IoT Greengrass. Function definitions are used to organize your function definition versions.

Function definitions can reference multiple function definition versions. All function definition versions must be associated with a function definition. Each function definition version can contain one or more functions.

Note
When you create a function definition, you can optionally include an initial function definition version. To associate a function definition version later, create an https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-greengrass-functiondefinitionversion.html resource and specify the ID of this function definition.
After you create the function definition version that contains the functions you want to deploy, you must add it to your group version. For more information, see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-greengrass-group.html.

Syntax

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

JSON

{
  "Type" : "AWS::Greengrass::FunctionDefinition",
  "Properties" : {
      "[InitialVersion](#cfn-greengrass-functiondefinition-initialversion)" : [FunctionDefinitionVersion](aws-properties-greengrass-functiondefinition-functiondefinitionversion.md),
      "[Name](#cfn-greengrass-functiondefinition-name)" : String
    }
}

YAML

Type: AWS::Greengrass::FunctionDefinition
Properties: 
  [InitialVersion](#cfn-greengrass-functiondefinition-initialversion): 
    [FunctionDefinitionVersion](aws-properties-greengrass-functiondefinition-functiondefinitionversion.md)
  [Name](#cfn-greengrass-functiondefinition-name): String

Properties

InitialVersion The function definition version to include when the function definition is created. A function definition version contains a list of https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-greengrass-functiondefinition-function.html property types.
To associate a function definition version after the function definition is created, create an https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-greengrass-functiondefinitionversion.html resource and specify the ID of this function definition. Required: No
Type: FunctionDefinitionVersion
Update requires: Replacement

Name The name of the function definition.
Required: Yes
Type: String
Update requires: No interruption

Return Values

Ref

When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns the ID of the function definition, such as 1234a5b6-78cd-901e-2fgh-3i45j6k178l9.

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

Fn::GetAtt

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 Fn::GetAtt.

Arn The Amazon Resource Name (ARN) of the FunctionDefinition, such as arn:aws:greengrass:us-east-1:123456789012:/greengrass/definition/functions/1234a5b6-78cd-901e-2fgh-3i45j6k178l9.

Id The ID of the FunctionDefinition, such as 1234a5b6-78cd-901e-2fgh-3i45j6k178l9.

LatestVersionArn The ARN of the last FunctionDefinitionVersion that was added to the FunctionDefinition, such as arn:aws:greengrass:us-east-1:123456789012:/greengrass/definition/functions/1234a5b6-78cd-901e-2fgh-3i45j6k178l9/versions/9876ac30-4bdb-4f9d-95af-b5fdb66be1a2.

Name The name of the FunctionDefinition, such as MyFunctionDefinition.

Examples

Function Definition Snippet

The following snippet defines a function definition resource with an initial version that contains a function. In this example, the Lambda function is created in another stack and is referenced using the ImportValue function.

For an example of a complete template, see the https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-greengrass-group.html resource.

JSON

"TestFunctionDefinition": {
    "Type": "AWS::Greengrass::FunctionDefinition",
    "Properties": {
        "Name": "DemoTestFunctionDefinition",
        "InitialVersion": {
            "DefaultConfig": {
                "Execution": {
                    "IsolationMode": "GreengrassContainer"
                }
            },
            "Functions": [
                {
                    "Id": "TestLambda1",
                    "FunctionArn": {
                        "Fn::ImportValue": "TestCanaryLambdaVersionArn"
                    },
                    "FunctionConfiguration": {
                        "Pinned": "false",
                        "Executable": "run.exe",
                        "ExecArgs": "argument1",
                        "MemorySize": "256",
                        "Timeout": "3000",
                        "EncodingType": "binary",
                        "Environment": {
                            "Variables": {
                                "variable1": "value1"
                            },
                            "ResourceAccessPolicies": [
                                {
                                    "ResourceId": "ResourceId1",
                                    "Permission": "ro"
                                },
                                {
                                    "ResourceId": "ResourceId2",
                                    "Permission": "rw"
                                }
                            ],
                            "AccessSysfs": "true",
                            "Execution": {
                                "RunAs": {
                                    "Uid": "1",
                                    "Gid": "10"
                                }
                            }
                        }
                    }
                }
            ]
        }
    }
}

YAML

TestFunctionDefinition:
  Type: 'AWS::Greengrass::FunctionDefinition'
  Properties:
    Name: DemoTestFunctionDefinition
    InitialVersion:
      DefaultConfig:
        Execution:
          IsolationMode: GreengrassContainer
      Functions:
        - Id: TestLambda1
          FunctionArn: !ImportValue TestCanaryLambdaVersionArn
          FunctionConfiguration:
            Pinned: 'false'
            Executable: run.exe
            ExecArgs: argument1
            MemorySize: '256'
            Timeout: '3000'
            EncodingType: binary
            Environment:
              Variables:
                variable1: value1
              ResourceAccessPolicies:
                - ResourceId: ResourceId1
                  Permission: ro
                - ResourceId: ResourceId2
                  Permission: rw
              AccessSysfs: 'true'
              Execution:
                RunAs:
                  Uid: '1'
                  Gid: '10'

See Also

You can’t perform that action at this time.