

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

# 사용자 지정 프로비저닝 플러그인 개발
<a name="develop-custom-provisioning-plugins"></a>

사용자 지정 프로비저닝 플러그인을 개발하려면 `com.aws.greengrass.provisioning.DeviceIdentityInterface` 인터페이스가 구현되는 Java 클래스를 생성합니다. 프로젝트에 Greengrass nucleus JAR 파일을 포함하여 이 인터페이스와 해당 클래스에 액세스할 수 있습니다. 이 인터페이스에서는 플러그인 구성이 입력되고 프로비저닝 구성이 출력되는 방법이 정의됩니다. 프로비저닝 구성에서는 시스템 및 [Greengrass nucleus 구성 요소](greengrass-nucleus-component.md)에 대한 구성 정의됩니다. AWS IoT Greengrass 코어 소프트웨어 설치 관리자는이 프로비저닝 구성을 사용하여 디바이스에서 AWS IoT Greengrass 코어 소프트웨어를 구성합니다.

사용자 지정 프로비저닝 플러그인을 개발한 후 설치 중에 플러그인을 실행하기 위해 AWS IoT Greengrass 코어 소프트웨어 설치 프로그램에 제공할 수 있는 JAR 파일로 빌드합니다. 설치 프로그램에서는 설치 프로그램에서 사용되는 동일한 JVM에서 사용자 지정 프로비저닝 플러그인이 실행되므로 플러그인 코드만 있는 JAR를 생성할 수 있습니다.

**참고**  
[AWS IoT 플릿 프로비저닝 플러그인](fleet-provisioning.md)에서는 설치 중 플릿 프로비저닝이 사용되도록 `DeviceIdentityInterface`가 구현됩니다. 플릿 프로비저닝 플러그인은 오픈 소스이므로 소스 코드를 탐색하여 프로비저닝 플러그인 인터페이스를 사용하는 방법의 예제를 참조할 수 있습니다. 자세한 내용은 GitHub의 [AWS IoT 플릿 프로비저닝 플러그인](https://github.com/aws-greengrass/aws-greengrass-fleet-provisioning-by-claim)을 참조하세요.

**Topics**
+ [요구 사항](#custom-provisioning-plugin-requirements)
+ [DeviceIdentityInterface 인터페이스 구현](#implement-device-identity-interface)

## 요구 사항
<a name="custom-provisioning-plugin-requirements"></a>

사용자 지정 프로비저닝 플러그인을 개발하려면 다음과 같은 요구 사항이 충족되는 Java 클래스를 생성해야 합니다.
+ `com.aws.greengrass` 패키지 또는 패키지 내 `com.aws.greengrass` 패키지를 사용합니다.
+ 인수가 없는 생성자가 있습니다.
+ `DeviceIdentityInterface` 인터페이스를 구현합니다. 자세한 내용은 [DeviceIdentityInterface 인터페이스 구현](#implement-device-identity-interface) 단원을 참조하십시오.

## DeviceIdentityInterface 인터페이스 구현
<a name="implement-device-identity-interface"></a>

사용자 지정 플러그인에서 `com.aws.greengrass.provisioning.DeviceIdentityInterface` 인터페이스를 사용하려면 프로젝트에 Greengrass nucleus를 종속성으로 추가합니다.

**사용자 지정 프로비저닝 플러그인 프로젝트에서 DeviceIdentityInterface를 사용하려면**
+ Greengrass nucleus JAR 파일을 라이브러리로 추가하거나 Greengrass nucleus를 Maven 종속성으로 추가할 수 있습니다. 다음 중 하나를 수행하세요.
  + Greengrass nucleus JAR 파일을 라이브러리로 추가하려면 Greengrass nucleus JAR이 포함된 AWS IoT Greengrass 코어 소프트웨어를 다운로드합니다. 다음 위치에서 최신 버전의 AWS IoT Greengrass 코어 소프트웨어를 다운로드할 수 있습니다.
    + [https://d2s8p88vqu9w66.cloudfront.net/releases/greengrass-nucleus-latest.zip](https://d2s8p88vqu9w66.cloudfront.net/releases/greengrass-nucleus-latest.zip)

    ZIP 파일의 `lib` 폴더에서 Greengrass nucleus JAR 파일(`Greengrass.jar`)을 찾을 수 있습니다. 프로젝트에 이 JAR 파일을 추가합니다.
  + Maven 프로젝트에서 Greengrass nucleus를 사용하려면 `com.aws.greengrass` 그룹의 `nucleus` 아티팩트에서 종속성을 추가합니다. Greengrass nucleus는 Maven Central Repository에서 사용될 수 없으므로 `greengrass-common` 리포지토리도 추가해야 합니다.

    ```
    <project ...>
        ...
        <repositories>
            <repository>
                <id>greengrass-common</id>
                <name>greengrass common</name>
                <url>https://d2jrmugq4soldf.cloudfront.net/snapshots</url>
            </repository>
        </repositories>
        ...
        <dependencies>
            <dependency>
                <groupId>com.aws.greengrass</groupId>
                <artifactId>nucleus</artifactId>
                <version>2.5.0-SNAPSHOT</version>
                <scope>provided</scope>
            </dependency>
        </dependencies>
    </project>
    ```

### DeviceIdentityInterface 인터페이스
<a name="device-identity-interface-shape"></a>

`com.aws.greengrass.provisioning.DeviceIdentityInterface` 인터페이스의 모양은 다음과 같습니다.

**참고**  
GitHub에서 [Greengrass nucleus 소스 코드](https://github.com/aws-greengrass/aws-greengrass-nucleus)의 [com.aws.greengrass.provisioning package](https://github.com/aws-greengrass/aws-greengrass-nucleus/tree/main/src/main/java/com/aws/greengrass/provisioning)에서도 이러한 클래스를 탐색할 수 있습니다.

```
public interface com.aws.greengrass.provisioning.DeviceIdentityInterface {
    ProvisionConfiguration updateIdentityConfiguration(ProvisionContext context)
            throws RetryableProvisioningException, InterruptedException;

    // Return the name of the plugin.
    String name(); 
}

com.aws.greengrass.provisioning.ProvisionConfiguration {
    SystemConfiguration systemConfiguration;
    NucleusConfiguration nucleusConfiguration    
}

com.aws.greengrass.provisioning.ProvisionConfiguration.SystemConfiguration {
    String certificateFilePath;
    String privateKeyPath;
    String rootCAPath;
    String thingName;
}

com.aws.greengrass.provisioning.ProvisionConfiguration.NucleusConfiguration {
    String awsRegion;
    String iotCredentialsEndpoint;
    String iotDataEndpoint;
    String iotRoleAlias;
}

com.aws.greengrass.provisioning.ProvisioningContext {
    Map<String, Object> parameterMap;
    String provisioningPolicy;  // The policy is always "PROVISION_IF_NOT_PROVISIONED".
}
   
com.aws.greengrass.provisioning.exceptions.RetryableProvisioningException {}
```

`SystemConfiguration` 및의 각 구성 값은 AWS IoT Greengrass 코어 소프트웨어를 설치하는 데 `NucleusConfiguration` 필요하지만를 반환할 수 있습니다`null`. 사용자 지정 프로비저닝 플러그인이 구성 값에 `null` 대해를 반환하는 경우 AWS IoT Greengrass 코어 소프트웨어 설치 프로그램에 제공할 `config.yaml` 파일을 생성할 때 시스템 또는 nucleus 구성에 해당 값을 제공해야 합니다. `config.yaml`에서도 정의한 옵션에 대해 null이 아닌 값이 사용자 지정 프로비저닝 플러그인이 반환되면 설치 프로그램에서는 플러그인에서 반환된 값으로 `config.yaml`의 값이 바뀝니다.