Lambda 함수를 구성 요소로 가져오기 () AWS CLI - AWS IoT Greengrass

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

Lambda 함수를 구성 요소로 가져오기 () AWS CLI

CreateComponentVersion작업을 사용하여 Lambda 함수에서 구성 요소를 생성합니다. 이 작업을 호출할 때 Lambda 함수를 lambdaFunction 가져오도록 지정하십시오.

1단계: Lambda 함수 구성 정의

  1. 라는 lambda-function-component.json 파일을 생성한 다음 다음 JSON 객체를 파일에 복사합니다. 를 가져올 Lambda 함수의 lambdaArn ARN으로 대체하십시오.

    { "lambdaFunction": { "lambdaArn": "arn:aws:lambda:region:account-id:function:HelloWorld:1" } }
    중요

    가져올 함수 버전이 포함된 ARN을 지정해야 합니다. $LATEST같은 버전 별칭을 사용할 수 없습니다.

  2. (선택 사항) 구성 요소의 이름 (componentName) 을 지정합니다. 이 파라미터를 생략하면 Lambda 함수의 이름으로 구성 요소가 AWS IoT Greengrass 생성됩니다.

    { "lambdaFunction": { "lambdaArn": "arn:aws:lambda:region:account-id:function:HelloWorld:1", "componentName": "com.example.HelloWorldLambda" } }
  3. (선택 사항) 구성 요소의 version (componentVersion) 을 지정합니다. 이 파라미터를 생략하면 Lambda 함수 버전을 유효한 시맨틱 버전으로 사용하여 구성 요소를 AWS IoT Greengrass 생성합니다. 예를 들어 함수 버전이 3인 경우 구성 요소 버전은 3.0.0가 됩니다.

    참고

    업로드하는 각 구성 요소 버전은 고유해야 합니다. 구성 요소 버전을 업로드한 후에는 편집할 수 없으므로 올바른 구성 요소 버전을 업로드해야 합니다.

    AWS IoT Greengrass구성 요소에 시맨틱 버전을 사용합니다. 시맨틱 버전은 메이저.마이너.패치 번호 시스템을 따릅니다. 예를 들어 버전은 구성 1.0.0 요소의 첫 번째 주요 릴리스를 나타냅니다. 자세한 내용은 시맨틱 버전 사양을 참조하십시오.

    { "lambdaFunction": { "lambdaArn": "arn:aws:lambda:region:account-id:function:HelloWorld:1", "componentName": "com.example.HelloWorldLambda", "componentVersion": "1.0.0" } }
  4. (선택 사항) 이 Lambda 함수가 지원하는 플랫폼을 지정합니다. 각 플랫폼에는 플랫폼을 식별하는 속성 맵이 포함되어 있습니다. 모든 핵심 기기에는 운영 체제 (os) 및 아키텍처 (architecture) 에 대한 속성이 있습니다. AWS IoT Greengrass코어 소프트웨어는 다른 플랫폼 속성을 추가할 수 있습니다. Greengrass nucleus 구성 요소를 코어 디바이스에 배포할 때 사용자 지정 플랫폼 속성을 지정할 수도 있습니다. 다음을 따릅니다.

    1. 의 Lambda 함수에 플랫폼 목록 (componentPlatforms) 을 추가합니다. lambda-function-component.json

      { "lambdaFunction": { "lambdaArn": "arn:aws:lambda:region:account-id:function:HelloWorld:1", "componentName": "com.example.HelloWorldLambda", "componentVersion": "1.0.0", "componentPlatforms": [ ] } }
    2. 지원되는 각 플랫폼을 목록에 추가합니다. 각 플랫폼에는 쉽게 name 식별할 수 있는 기능과 속성 맵이 있습니다. 다음 예제에서는 이 함수가 Linux를 실행하는 x86 장치를 지원하도록 지정합니다.

      { "name": "Linux x86", "attributes": { "os": "linux", "architecture": "x86" } }

      다음 예와 비슷한 문서가 들어 lambda-function-component.json 있을 수 있습니다.

      { "lambdaFunction": { "lambdaArn": "arn:aws:lambda:region:account-id:function:HelloWorld:1", "componentName": "com.example.HelloWorldLambda", "componentVersion": "1.0.0", "componentPlatforms": [ { "name": "Linux x86", "attributes": { "os": "linux", "architecture": "x86" } } ] } }
  5. (선택 사항) Lambda 함수의 구성 요소 종속성을 지정합니다. Lambda 함수 구성 요소를 배포할 때 배포에는 함수 실행에 대한 이러한 종속성이 포함됩니다.

    중요

    AWS IoT GreengrassV1에서 실행하도록 생성한 Lambda 함수를 가져오려면 함수가 사용하는 기능 (예: 비밀, 로컬 섀도우, 스트림 관리자) 에 대한 개별 구성 요소 종속성을 정의해야 합니다. 이러한 구성 요소를 하드 종속성으로 정의하여 종속성 상태가 변경될 경우 Lambda 함수 구성 요소가 다시 시작되도록 합니다. 자세한 설명은 V1 람다 함수 가져오기 섹션을 참조하세요.

    다음을 따릅니다.

    1. 의 Lambda 함수에 구성 요소 종속성 맵 (componentDependencies) 을 추가합니다. lambda-function-component.json

      { "lambdaFunction": { "lambdaArn": "arn:aws:lambda:region:account-id:function:HelloWorld:1", "componentName": "com.example.HelloWorldLambda", "componentVersion": "1.0.0", "componentPlatforms": [ { "name": "Linux x86", "attributes": { "os": "linux", "architecture": "x86" } } ], "componentDependencies": { } } }
    2. 맵에 각 구성 요소 종속성을 추가합니다. 구성 요소 이름을 키로 지정하고 다음 매개 변수를 사용하여 개체를 지정합니다.

      • versionRequirement— 구성 요소 종속성의 호환 버전을 식별하는 npm 스타일 시맨틱 버전 제약 조건입니다. 단일 버전 또는 버전 범위를 지정할 수 있습니다. 시맨틱 버전 제약에 대한 자세한 내용은 npm semver 계산기를 참조하십시오.

      • dependencyType— (선택 사항) 종속성 유형. 다음 중에서 선택합니다.

        • SOFT— Lambda 함수 구성 요소는 종속성의 상태가 변경되어도 재시작되지 않습니다.

        • HARD— 종속성 상태가 변경되면 Lambda 함수 구성 요소가 다시 시작됩니다.

        기본값은 HARD입니다.

      다음 예제는 이 Lambda 함수가 스트림 관리자 구성 요소의 첫 번째 메이저 버전에 있는 모든 버전에 종속되도록 지정합니다. 스트림 관리자가 재시작되거나 업데이트되면 Lambda 함수 구성 요소가 다시 시작됩니다.

      { "aws.greengrass.StreamManager": { "versionRequirement": "^1.0.0", "dependencyType": "HARD" } }

      다음 예제와 비슷한 문서가 lambda-function-component.json 포함될 수 있습니다.

      { "lambdaFunction": { "lambdaArn": "arn:aws:lambda:region:account-id:function:HelloWorld:1", "componentName": "com.example.HelloWorldLambda", "componentVersion": "1.0.0", "componentPlatforms": [ { "name": "Linux x86", "attributes": { "os": "linux", "architecture": "x86" } } ], "componentDependencies": { "aws.greengrass.StreamManager": { "versionRequirement": "^1.0.0", "dependencyType": "HARD" } } } }
  6. (선택 사항) 함수를 실행하는 데 사용할 Lambda 함수 파라미터를 구성합니다. 환경 변수, 메시지 이벤트 소스, 타임아웃, 컨테이너 설정 등의 옵션을 구성할 수 있습니다. 다음을 따릅니다.

    1. 의 Lambda 함수에 Lambda 파라미터 객체 componentLambdaParameters () 를 추가합니다. lambda-function-component.json

      { "lambdaFunction": { "lambdaArn": "arn:aws:lambda:region:account-id:function:HelloWorld:1", "componentName": "com.example.HelloWorldLambda", "componentVersion": "1.0.0", "componentPlatforms": [ { "name": "Linux x86", "attributes": { "os": "linux", "architecture": "x86" } } ], "componentDependencies": { "aws.greengrass.StreamManager": { "versionRequirement": "^1.0.0", "dependencyType": "HARD" } }, "componentLambdaParameters": { } } }
    2. (선택 사항) Lambda 함수가 작업 메시지를 구독하는 이벤트 소스를 지정합니다. 이 함수를 로컬 게시/구독 메시지 및 MQTT 메시지에 구독하도록 이벤트 소스를 지정할 수 있습니다. AWS IoT Core Lambda 함수는 이벤트 소스로부터 메시지를 수신할 때 호출됩니다.

      참고

      이 함수를 다른 Lambda 함수 또는 구성 요소의 메시지를 구독하려면 이 Lambda 함수 구성 요소를 배포할 때 기존 구독 라우터 구성 요소를 배포하십시오. 레거시 구독 라우터 구성 요소를 배포할 때 Lambda 함수가 사용하는 구독을 지정하십시오.

      다음을 따릅니다.

      1. Lambda 함수 파라미터에 이벤트 소스 (eventSources) 목록을 추가합니다.

        { "lambdaFunction": { "lambdaArn": "arn:aws:lambda:region:account-id:function:HelloWorld:1", "componentName": "com.example.HelloWorldLambda", "componentVersion": "1.0.0", "componentPlatforms": [ { "name": "Linux x86", "attributes": { "os": "linux", "architecture": "x86" } } ], "componentDependencies": { "aws.greengrass.StreamManager": { "versionRequirement": "^1.0.0", "dependencyType": "HARD" } }, "componentLambdaParameters": { "eventSources": [ ] } } }
      2. 각 이벤트 소스를 목록에 추가합니다. 각 이벤트 소스에는 다음과 같은 매개변수가 있습니다.

        • topic— 메시지 구독을 위한 주제입니다.

        • type— 이벤트 소스 유형. 다음 옵션 중 하나를 선택합니다.

          • PUB_SUB – 로컬 게시/구독 메시지를 구독합니다.

            Greengrass nucleus v2.6.0 이상 및 Lambda 관리자 v2.2.5 이상을 사용하는 경우, 이 유형을 지정할 때 MQTT 주제 와일드카드 (및) 를 사용할 수 있습니다. + # topic

          • IOT_CORE - AWS IoT Core MQTT 메시지를 구독합니다.

            이 유형을 지정할 때 MQTT 주제 와일드카드 (및) 를 사용할 수 있습니다. + # topic

          다음 예제는 주제 필터와 일치하는 주제에 대해 AWS IoT Core MQTT를 구독합니다. hello/world/+

          { "topic": "hello/world/+", "type": "IOT_CORE" }

          다음 예제와 비슷해 lambda-function-component.json 보일 수 있습니다.

          { "lambdaFunction": { "lambdaArn": "arn:aws:lambda:region:account-id:function:HelloWorld:1", "componentName": "com.example.HelloWorldLambda", "componentVersion": "1.0.0", "componentPlatforms": [ { "name": "Linux x86", "attributes": { "os": "linux", "architecture": "x86" } } ], "componentDependencies": { "aws.greengrass.StreamManager": { "versionRequirement": "^1.0.0", "dependencyType": "HARD" } }, "componentLambdaParameters": { "eventSources": [ { "topic": "hello/world/+", "type": "IOT_CORE" } ] } } }
    3. (선택 사항) Lambda 함수 파라미터 객체에 다음 파라미터 중 하나를 지정합니다.

      • environmentVariables— Lambda 함수가 실행될 때 사용할 수 있는 환경 변수의 맵입니다.

      • execArgs— Lambda 함수가 실행될 때 해당 함수에 전달할 인수 목록입니다.

      • inputPayloadEncodingType— Lambda 함수가 지원하는 페이로드 유형. 다음 옵션 중 하나를 선택합니다.

        • json

        • binary

        기본값: json

      • pinned— Lambda 함수가 고정되었는지 여부. 기본값은 true입니다.

        • 고정된 (또는 수명이 긴) Lambda 함수는 시작 시 AWS IoT Greengrass 시작되어 자체 컨테이너에서 계속 실행됩니다.

        • 고정되지 않은 (또는 온디맨드) Lambda 함수는 작업 항목을 수신할 때만 시작되고 지정된 최대 유휴 시간 동안 유휴 상태를 유지한 후에 종료됩니다. 함수에 여러 작업 항목이 있는 경우 AWS IoT Greengrass Core 소프트웨어는 함수의 여러 인스턴스를 생성합니다.

        함수의 최대 maxIdleTimeInSeconds 유휴 시간을 설정하는 데 사용합니다.

      • timeoutInSeconds— 제한 시간이 초과되기 전에 Lambda 함수를 실행할 수 있는 최대 시간 (초). 기본값은 3초입니다.

      • statusTimeoutInSeconds— Lambda 함수 구성 요소가 Lambda 관리자 구성 요소에 상태 업데이트를 보내는 간격 (초). 이 파라미터는 고정된 함수에만 적용됩니다. 기본값은 60초입니다.

      • maxIdleTimeInSeconds— 고정되지 않은 Lambda 함수가 Core 소프트웨어가 프로세스를 중지하기 전에 유휴 상태로 유지할 수 있는 최대 시간 (초). AWS IoT Greengrass 기본값은 60초입니다.

      • maxInstancesCount— 고정되지 않은 Lambda 함수가 동시에 실행할 수 있는 최대 인스턴스 수입니다. 기본값은 100개의 인스턴스입니다.

      • maxQueueSize— Lambda 함수 구성 요소에 대한 메시지 대기열의 최대 크기. AWS IoT GreengrassCore 소프트웨어는 Lambda 함수를 실행하여 각 메시지를 사용할 수 있을 때까지 메시지를 FIFO (first-in-first-out) 대기열에 저장합니다. 기본값은 1,000개의 메시지입니다.

      다음 예와 비슷한 문서가 들어 lambda-function-component.json 있을 수 있습니다.

      { "lambdaFunction": { "lambdaArn": "arn:aws:lambda:region:account-id:function:HelloWorld:1", "componentName": "com.example.HelloWorldLambda", "componentVersion": "1.0.0", "componentPlatforms": [ { "name": "Linux x86", "attributes": { "os": "linux", "architecture": "x86" } } ], "componentDependencies": { "aws.greengrass.StreamManager": { "versionRequirement": "^1.0.0", "dependencyType": "HARD" } }, "componentLambdaParameters": { "eventSources": [ { "topic": "hello/world/+", "type": "IOT_CORE" } ], "environmentVariables": { "LIMIT": "300" }, "execArgs": [ "-d" ], "inputPayloadEncodingType": "json", "pinned": true, "timeoutInSeconds": 120, "statusTimeoutInSeconds": 30, "maxIdleTimeInSeconds": 30, "maxInstancesCount": 50, "maxQueueSize": 500 } } }
    4. (선택 사항) Lambda 함수의 컨테이너 설정을 구성합니다. 기본적으로 Lambda 함수는 Core 소프트웨어 내의 AWS IoT Greengrass 격리된 런타임 환경에서 실행됩니다. 또한 격리 없이 Lambda 함수를 프로세스로 실행하도록 선택할 수 있습니다. 컨테이너에서 Lambda 함수를 실행하는 경우 컨테이너의 메모리 크기와 Lambda 함수에 사용할 수 있는 시스템 리소스를 구성합니다. 다음을 따릅니다.

      1. Linux 프로세스 파라미터 객체 (linuxProcessParams) 를 의 Lambda 파라미터 객체에 추가합니다. lambda-function-component.json

        { "lambdaFunction": { "lambdaArn": "arn:aws:lambda:region:account-id:function:HelloWorld:1", "componentName": "com.example.HelloWorldLambda", "componentVersion": "1.0.0", "componentPlatforms": [ { "name": "Linux x86", "attributes": { "os": "linux", "architecture": "x86" } } ], "componentDependencies": { "aws.greengrass.StreamManager": { "versionRequirement": "^1.0.0", "dependencyType": "HARD" } }, "componentLambdaParameters": { "eventSources": [ { "topic": "hello/world/+", "type": "IOT_CORE" } ], "environmentVariables": { "LIMIT": "300" }, "execArgs": [ "-d" ], "inputPayloadEncodingType": "json", "pinned": true, "timeoutInSeconds": 120, "statusTimeoutInSeconds": 30, "maxIdleTimeInSeconds": 30, "maxInstancesCount": 50, "maxQueueSize": 500, "linuxProcessParams": { } } } }
      2. (선택 사항) Lambda 함수가 컨테이너에서 실행되는지 여부를 지정합니다. 프로세스 isolationMode 파라미터 객체에 파라미터를 추가하고 다음 옵션 중에서 선택하십시오.

        • GreengrassContainer— Lambda 함수는 컨테이너에서 실행됩니다.

        • NoContainer— Lambda 함수는 격리 없이 프로세스로 실행됩니다.

        기본값은 GreengrassContainer입니다.

      3. (선택 사항) 컨테이너에서 Lambda 함수를 실행하는 경우 컨테이너에서 사용할 수 있도록 메모리 양과 시스템 리소스 (예: 볼륨 및 디바이스) 를 구성할 수 있습니다. 다음을 따릅니다.

        1. 의 Linux 프로세스 파라미터 객체에 컨테이너 파라미터 객체 (containerParams) 를 추가합니다. lambda-function-component.json

          { "lambdaFunction": { "lambdaArn": "arn:aws:lambda:region:account-id:function:HelloWorld:1", "componentName": "com.example.HelloWorldLambda", "componentVersion": "1.0.0", "componentPlatforms": [ { "name": "Linux x86", "attributes": { "os": "linux", "architecture": "x86" } } ], "componentDependencies": { "aws.greengrass.StreamManager": { "versionRequirement": "^1.0.0", "dependencyType": "HARD" } }, "componentLambdaParameters": { "eventSources": [ { "topic": "hello/world/+", "type": "IOT_CORE" } ], "environmentVariables": { "LIMIT": "300" }, "execArgs": [ "-d" ], "inputPayloadEncodingType": "json", "pinned": true, "timeoutInSeconds": 120, "statusTimeoutInSeconds": 30, "maxIdleTimeInSeconds": 30, "maxInstancesCount": 50, "maxQueueSize": 500, "linuxProcessParams": { "containerParams": { } } } } }
        2. (선택 사항) memorySizeInKB 매개 변수를 추가하여 컨테이너의 메모리 크기를 지정합니다. 기본값은 16,384KB (16MB) 입니다.

        3. (선택 사항) mountROSysfs 매개 변수를 추가하여 컨테이너가 장치 폴더에서 정보를 읽을 수 있는지 여부를 지정합니다. /sys 기본값은 false입니다.

        4. (선택 사항) 컨테이너화된 Lambda 함수가 액세스할 수 있는 로컬 볼륨을 구성합니다. 볼륨을 정의할 때 AWS IoT Greengrass Core 소프트웨어는 소스 파일을 컨테이너 내의 대상에 탑재합니다. 다음을 따릅니다.

          1. 볼륨 목록 (volumes) 을 컨테이너 파라미터에 추가합니다.

            { "lambdaFunction": { "lambdaArn": "arn:aws:lambda:region:account-id:function:HelloWorld:1", "componentName": "com.example.HelloWorldLambda", "componentVersion": "1.0.0", "componentPlatforms": [ { "name": "Linux x86", "attributes": { "os": "linux", "architecture": "x86" } } ], "componentDependencies": { "aws.greengrass.StreamManager": { "versionRequirement": "^1.0.0", "dependencyType": "HARD" } }, "componentLambdaParameters": { "eventSources": [ { "topic": "hello/world/+", "type": "IOT_CORE" } ], "environmentVariables": { "LIMIT": "300" }, "execArgs": [ "-d" ], "inputPayloadEncodingType": "json", "pinned": true, "timeoutInSeconds": 120, "statusTimeoutInSeconds": 30, "maxIdleTimeInSeconds": 30, "maxInstancesCount": 50, "maxQueueSize": 500, "linuxProcessParams": { "containerParams": { "memorySizeInKB": 32768, "mountROSysfs": true, "volumes": [ ] } } } } }
          2. 각 볼륨을 목록에 추가합니다. 각 볼륨에는 다음과 같은 매개변수가 있습니다.

            • sourcePath— 코어 디바이스의 소스 폴더 경로.

            • destinationPath— 컨테이너의 대상 폴더 경로.

            • permission— (선택 사항) 컨테이너에서 소스 폴더에 액세스할 수 있는 권한. 다음 옵션 중 하나를 선택합니다.

              • ro— Lambda 함수는 소스 폴더에 대한 읽기 전용 액세스 권한을 가집니다.

              • rw— Lambda 함수는 소스 폴더에 대한 읽기/쓰기 액세스 권한을 가집니다.

              기본값은 ro입니다.

            • addGroupOwner— (선택 사항) Lambda 함수 구성 요소를 실행하는 시스템 그룹을 소스 폴더의 소유자로 추가할지 여부. 기본값은 false입니다.

            다음 예와 비슷한 문서가 포함되어 lambda-function-component.json 있을 수 있습니다.

            { "lambdaFunction": { "lambdaArn": "arn:aws:lambda:region:account-id:function:HelloWorld:1", "componentName": "com.example.HelloWorldLambda", "componentVersion": "1.0.0", "componentPlatforms": [ { "name": "Linux x86", "attributes": { "os": "linux", "architecture": "x86" } } ], "componentDependencies": { "aws.greengrass.StreamManager": { "versionRequirement": "^1.0.0", "dependencyType": "HARD" } }, "componentLambdaParameters": { "eventSources": [ { "topic": "hello/world/+", "type": "IOT_CORE" } ], "environmentVariables": { "LIMIT": "300" }, "execArgs": [ "-d" ], "inputPayloadEncodingType": "json", "pinned": true, "timeoutInSeconds": 120, "statusTimeoutInSeconds": 30, "maxIdleTimeInSeconds": 30, "maxInstancesCount": 50, "maxQueueSize": 500, "linuxProcessParams": { "containerParams": { "memorySizeInKB": 32768, "mountROSysfs": true, "volumes": [ { "sourcePath": "/var/data/src", "destinationPath": "/var/data/dest", "permission": "rw", "addGroupOwner": true } ] } } } } }
        5. (선택 사항) 컨테이너화된 Lambda 함수가 액세스할 수 있는 로컬 시스템 디바이스를 구성합니다. 다음을 따릅니다.

          1. 시스템 디바이스 목록 (devices) 을 컨테이너 파라미터에 추가합니다.

            { "lambdaFunction": { "lambdaArn": "arn:aws:lambda:region:account-id:function:HelloWorld:1", "componentName": "com.example.HelloWorldLambda", "componentVersion": "1.0.0", "componentPlatforms": [ { "name": "Linux x86", "attributes": { "os": "linux", "architecture": "x86" } } ], "componentDependencies": { "aws.greengrass.StreamManager": { "versionRequirement": "^1.0.0", "dependencyType": "HARD" } }, "componentLambdaParameters": { "eventSources": [ { "topic": "hello/world/+", "type": "IOT_CORE" } ], "environmentVariables": { "LIMIT": "300" }, "execArgs": [ "-d" ], "inputPayloadEncodingType": "json", "pinned": true, "timeoutInSeconds": 120, "statusTimeoutInSeconds": 30, "maxIdleTimeInSeconds": 30, "maxInstancesCount": 50, "maxQueueSize": 500, "linuxProcessParams": { "containerParams": { "memorySizeInKB": 32768, "mountROSysfs": true, "volumes": [ { "sourcePath": "/var/data/src", "destinationPath": "/var/data/dest", "permission": "rw", "addGroupOwner": true } ], "devices": [ ] } } } } }
          2. 각 시스템 장치를 목록에 추가합니다. 각 시스템 장치에는 다음과 같은 매개변수가 있습니다.

            • path— 코어 장치의 시스템 장치 경로.

            • permission— (선택 사항) 컨테이너에서 시스템 장치에 액세스할 수 있는 권한. 다음 옵션 중 하나를 선택합니다.

              • ro— Lambda 함수는 시스템 디바이스에 대한 읽기 전용 액세스 권한을 가집니다.

              • rw— Lambda 함수는 시스템 디바이스에 대한 읽기/쓰기 액세스 권한을 가집니다.

              기본값은 ro입니다.

            • addGroupOwner— (선택 사항) Lambda 함수 구성 요소를 실행하는 시스템 그룹을 시스템 디바이스의 소유자로 추가할지 여부. 기본값은 false입니다.

          다음 예와 비슷한 문서가 포함되어 lambda-function-component.json 있을 수 있습니다.

          { "lambdaFunction": { "lambdaArn": "arn:aws:lambda:region:account-id:function:HelloWorld:1", "componentName": "com.example.HelloWorldLambda", "componentVersion": "1.0.0", "componentPlatforms": [ { "name": "Linux x86", "attributes": { "os": "linux", "architecture": "x86" } } ], "componentDependencies": { "aws.greengrass.StreamManager": { "versionRequirement": "^1.0.0", "dependencyType": "HARD" } }, "componentLambdaParameters": { "eventSources": [ { "topic": "hello/world/+", "type": "IOT_CORE" } ], "environmentVariables": { "LIMIT": "300" }, "execArgs": [ "-d" ], "inputPayloadEncodingType": "json", "pinned": true, "timeoutInSeconds": 120, "statusTimeoutInSeconds": 30, "maxIdleTimeInSeconds": 30, "maxInstancesCount": 50, "maxQueueSize": 500, "linuxProcessParams": { "containerParams": { "memorySizeInKB": 32768, "mountROSysfs": true, "volumes": [ { "sourcePath": "/var/data/src", "destinationPath": "/var/data/dest", "permission": "rw", "addGroupOwner": true } ], "devices": [ { "path": "/dev/sda3", "permission": "rw", "addGroupOwner": true } ] } } } } }
  7. (선택 사항) 구성 요소에 태그 (tags) 를 추가합니다. 자세한 설명은 AWS IoT Greengrass Version 2 리소스 태깅 섹션을 참조하세요.

2단계: Lambda 함수 구성 요소 생성

  1. 다음 명령을 실행하여 Lambda 함수 구성 요소를 생성합니다. lambda-function-component.json

    aws greengrassv2 create-component-version --cli-input-json file://lambda-function-component.json

    요청이 성공하면 응답은 다음 예제와 비슷해 보입니다.

    { "arn": "arn:aws:greengrass:region:123456789012:components:com.example.HelloWorldLambda:versions:1.0.0", "componentName": "com.example.HelloWorldLambda", "componentVersion": "1.0.0", "creationTimestamp": "Mon Dec 15 20:56:34 UTC 2020", "status": { "componentState": "REQUESTED", "message": "NONE", "errors": {} } }

    arn출력에서 를 복사하여 다음 단계에서 구성 요소의 상태를 확인합니다.

  2. 구성 요소를 만들면 해당 상태는 입니다REQUESTED. 그런 다음 구성 요소를 배포할 수 있는지 AWS IoT Greengrass 확인합니다. 다음 명령을 실행하여 구성 요소 상태를 쿼리하고 구성 요소가 배포 가능한지 확인할 수 있습니다. 를 이전 단계의 arn ARN으로 교체합니다.

    aws greengrassv2 describe-component \ --arn "arn:aws:greengrass:region:account-id:components:com.example.HelloWorldLambda:versions:1.0.0"

    구성 요소가 검증되면 응답은 구성 요소 상태가 유효하다는 것을 나타냅니다. DEPLOYABLE

    { "arn": "arn:aws:greengrass:region:account-id:components:com.example.HelloWorldLambda:versions:1.0.0", "componentName": "com.example.HelloWorldLambda", "componentVersion": "1.0.0", "creationTimestamp": "2020-12-15T20:56:34.376000-08:00", "publisher": "AWS Lambda", "status": { "componentState": "DEPLOYABLE", "message": "NONE", "errors": {} }, "platforms": [ { "name": "Linux x86", "attributes": { "architecture": "x86", "os": "linux" } } ] }

    구성 요소가 DEPLOYABLE 완성되면 Lambda 함수를 코어 디바이스에 배포할 수 있습니다. 자세한 내용은 디바이스에 AWS IoT Greengrass 구성 요소 배포을(를) 참조하세요.