

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

# 레지스트리로 사물 관리
<a name="thing-registry"></a>

 AWS IoT 콘솔, AWS IoT API 또는를 사용하여 레지스트리와 AWS CLI 상호 작용합니다. 다음 섹션에서는 CLI를 사용하여 레지스트리 작업을 수행하는 방법을 설명합니다.

**사물의 이름을 지정할 때:**
+ 사물 이름에 개인 식별 정보를 사용하면 안 됩니다. 사물 이름은 암호화되지 않은 통신 및 보고서에 나타날 수 있습니다.

**Topics**
+ [사물 생성](create-thing.md)
+ [사물 목록 표시](list-things.md)
+ [사물 설명](search-things.md)
+ [사물 업데이트](update-thing.md)
+ [사물 삭제](delete-thing.md)
+ [사물에 위탁자 연결](attach-thing-principal.md)
+ [위탁자와 연결된 사물 나열](list-principal-things.md)
+ [사물에 연결된 위탁자 나열](list-thing-principals.md)
+ [위탁자와 연결된 사물 나열 V2](list-principal-things-v2.md)
+ [사물에 연결된 위탁자 나열 V2](list-thing-principals-v2.md)
+ [사물에서 보안 주체 분리](detach-thing-principal.md)

# 사물 생성
<a name="create-thing"></a>

다음 명령은 CLI의 AWS IoT **CreateThing** 명령을 사용하여 사물을 생성하는 방법을 보여줍니다. 사물을 생성한 후에는 사물 이름을 변경할 수 없습니다. 사물 이름을 변경하려면 새 사물을 생성하고 새 이름을 지정한 다음 이전 사물을 삭제해야 합니다.

```
$ aws iot create-thing \
    --thing-type-name "MyLightBulb" \ 
    --attribute-payload "{\"attributes\": {\"wattage\":\"75\", \"model\":\"123\"}}"
```

**CreateThing** 명령은 새 사물의 이름과 Amazon 리소스 이름(ARN)을 표시합니다.

```
{
    "thingArn": "arn:aws:iot:us-east-1:123456789012:thing/MyLightBulb",
    "thingName": "MyLightBulb",
    "thingId": "12345678abcdefgh12345678ijklmnop12345678"
}
```

**참고**  
사물 이름에 개인 식별 정보를 사용하지 않는 것이 좋습니다.

자세한 내용은 AWS CLI 명령 참조의 [create-thing](https://docs.aws.amazon.com//cli/latest/reference/iot/create-thing.html)을 참조하세요.

# 사물 목록 표시
<a name="list-things"></a>

다음과 같이 **ListThings** 명령을 사용하여 계정에 속한 모든 사물을 나열할 수 있습니다.

```
$ aws iot list-things
```

```
{
    "things": [
       {
            "attributes": {
                "model": "123",
                "wattage": "75"
            },
            "version": 1,
            "thingName": "MyLightBulb"
        },
        {
            "attributes": {
                "numOfStates":"3"
             },
            "version": 11,
            "thingName": "MyWallSwitch"
        }
    ]
}
```

**ListThings** 명령을 사용하여 특정 사물 유형의 모든 사물을 검색할 수 있습니다.

```
$  aws iot list-things --thing-type-name "LightBulb"
```

```
{
    "things": [
        {
            "thingTypeName": "LightBulb",
            "attributes": {
                "model": "123",
                "wattage": "75"
            },
            "version": 1,
            "thingName": "MyRGBLight"
        },
        {
            "thingTypeName": "LightBulb",
            "attributes": {
                "model": "123",
                "wattage": "75"
            },
            "version": 1,
            "thingName": "MySecondLightBulb"
        }
    ]
}
```

다음과 같이 **ListThings** 명령을 사용하여 특정 값의 속성을 갖는 모든 사물을 검색할 수 있습니다. 이 명령은 최대 세 개의 속성을 검색합니다.

```
$  aws iot list-things --attribute-name "wattage" --attribute-value "75"
```

```
{
    "things": [
        {
            "thingTypeName": "StopLight",
            "attributes": {
                "model": "123",
                "wattage": "75"
            },
            "version": 3,
            "thingName": "MyLightBulb"
        },
        {
            "thingTypeName": "LightBulb",
            "attributes": {
                "model": "123",
                "wattage": "75"
            },
            "version": 1,
            "thingName": "MyRGBLight"
        },
        {
            "thingTypeName": "LightBulb",
            "attributes": {
                "model": "123",
                "wattage": "75"
            },
            "version": 1,
            "thingName": "MySecondLightBulb"
        }
    ]
}
```

자세한 내용은 AWS CLI 명령 참조의 [list-things](https://docs.aws.amazon.com//cli/latest/reference/iot/list-things.html)를 참조하세요.

# 사물 설명
<a name="search-things"></a>

**DescribeThing** 명령을 사용하여 사물에 대한 자세한 정보를 표시할 수 있습니다.

```
$ aws iot describe-thing --thing-name "MyLightBulb"
{
    "version": 3,
    "thingName": "MyLightBulb",
    "thingArn": "arn:aws:iot:us-east-1:123456789012:thing/MyLightBulb",
    "thingId": "12345678abcdefgh12345678ijklmnop12345678",
    "defaultClientId": "MyLightBulb",
    "thingTypeName": "StopLight",
    "attributes": {
        "model": "123",
        "wattage": "75"
    }
}
```

인라인 함수를 사용하여 규칙 엔진 내에서이 API에 액세스할 수도 있습니다`get_registry_data()`. 이 함수를 사용하면 AWS IoT 규칙 내에서 `DescribeThing` 직접 및 `ListThingGroupsForThing` APIs를 호출하여 사물 레지스트리 정보(속성, 사물 유형 및 그룹 멤버십 포함)에 동적으로 액세스하고 활용하여 디바이스 레지스트리 데이터를 기반으로 실시간 메시지 처리 및 라우팅을 활성화할 수 있습니다. 자세한 내용은 [https://docs.aws.amazon.com//iot/latest/developerguide/iot-sql-functions.html#iot-sql-function-get-registry_data](https://docs.aws.amazon.com//iot/latest/developerguide/iot-sql-functions.html#iot-sql-function-get-registry_data) 단원을 참조하십시오.

자세한 내용은 AWS CLI 명령 참조의 [describe-thing](https://docs.aws.amazon.com//cli/latest/reference/iot/describe-thing.html)을 참조하세요.

# 사물 업데이트
<a name="update-thing"></a>

**UpdateThing** 명령을 사용하여 사물을 업데이트할 수 있습니다. 이 명령은 사물의 속성만 업데이트합니다. 사물의 이름은 변경할 수 없습니다. 사물 이름을 변경하려면 새 사물을 생성하고 새 이름을 지정한 다음 이전 사물을 삭제해야 합니다.

```
$ aws iot update-thing --thing-name "MyLightBulb" --attribute-payload "{\"attributes\": {\"wattage\":\"150\", \"model\":\"456\"}}"
```

**UpdateThing** 명령은 출력을 생성하지 않습니다. **DescribeThing** 명령을 사용하여 결과를 확인할 수 있습니다.

```
$ aws iot describe-thing --thing-name "MyLightBulb"
{
    "attributes": {
        "model": "456",
        "wattage": "150"
    },
    "version": 2,
    "thingName": "MyLightBulb"
}
```

자세한 내용은 AWS CLI 명령 참조의 [update-thing](https://docs.aws.amazon.com//cli/latest/reference/iot/update-thing.html)을 참조하세요.

# 사물 삭제
<a name="delete-thing"></a>

다음과 같이 **DeleteThing** 명령을 사용하여 사물을 삭제할 수 있습니다.

```
$ aws iot delete-thing --thing-name "MyThing"
```

삭제에 성공하거나 존재하지 않는 사물을 지정하는 경우 이 명령은 오류가 발생하지 않고 성공적으로 반환합니다.

자세한 내용은 AWS CLI 명령 참조의 [delete-thing](https://docs.aws.amazon.com//cli/latest/reference/iot/delete-thing.html)을 참조하세요.

# 사물에 위탁자 연결
<a name="attach-thing-principal"></a>

물리적 디바이스는 보안 주체를 사용하여 통신할 수 있습니다 AWS IoT. 위탁자는 X.509 인증서 또는 Amazon Cognito ID일 수 있습니다. [attach-thing-principal](https://docs.aws.amazon.com//cli/latest/reference/iot/attach-thing-principal.html) 명령을 실행하여, 디바이스를 나타내는 레지스트리의 사물과 인증서 또는 Amazon Cognito ID를 연결할 수 있습니다.

인증서 또는 Amazon Cognito ID를 사물에 연결하려면 [attach-thing-principal](https://docs.aws.amazon.com//cli/latest/reference/iot/attach-thing-principal.html) 명령을 사용합니다.

```
$ aws iot attach-thing-principal \
    --thing-name "MyLightBulb1" \
    --principal "arn:aws:iot:us-east-1:123456789012:cert/a0c01f5835079de0a7514643d68ef8414ab739a1e94ee4162977b02b12842847"
```

연결 유형(독점 연결 또는 비독점 연결)을 사용하여 사물에 인증서를 연결하려면 [https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iot/attach-thing-principal.html](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iot/attach-thing-principal.html) 명령을 사용하고 `--thing-principal-type` 필드에 유형을 지정합니다. 독점 연결은 사용자의 IoT 사물만 유일하게 인증서에 연결되어 있으며, 이 인증서를 다른 사물과는 연결할 수 없다는 것을 의미합니다. 비독점 연결은 사용자의 IoT 사물이 인증서에 연결되어 있고 이 인증서를 다른 사물과도 연결할 수 있다는 것을 의미합니다. 자세한 내용은 [AWS IoT 사물을 MQTT 클라이언트 연결에 연결](exclusive-thing.md) 단원을 참조하십시오.

**참고**  
이 [AWS IoT 사물을 MQTT 클라이언트 연결에 연결](exclusive-thing.md) 기능의 경우, X.509 인증서만 위탁자로 사용할 수 있습니다.

```
$ aws iot attach-thing-principal \
    --thing-name "MyLightBulb2" \
    --principal "arn:aws:iot:us-east-1:123456789012:cert/a0c01f5835079de0a7514643d68ef8414ab739a1e94ee4162977b02b12842847" \
    --thing-principal-type "EXCLUSIVE_THING"
```

연결에 성공하면 **AttachThingPrincipal** 명령이 출력을 생성하지 않습니다. 연결을 설명하려면 list-thing-principals-v2 CLI 명령을 사용합니다.

자세한 내용은 *AWS IoT Core API 참조*의 [AttachThingPrincipal](https://docs.aws.amazon.com//iot/latest/apireference/API_AttachThingPrincipal.html)을 참조하세요.

# 위탁자와 연결된 사물 나열
<a name="list-principal-things"></a>

지정한 위탁자와 연결된 사물을 나열하려면, [https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iot/list-principal-things.htmls](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iot/list-principal-things.htmls) 명령을 실행합니다. 단, 이 명령은 사물과 인증서 간의 연결 유형을 나열하지 않습니다. 연결 유형을 나열하려면 [https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iot/list-principal-thingsv2.html](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iot/list-principal-thingsv2.html) 명령을 사용합니다. 자세한 내용은 [위탁자와 연결된 사물 나열 V2](list-principal-things-v2.md) 단원을 참조하십시오.

```
$ aws iot list-principal-things \
    --principal "arn:aws:iot:us-east-1:123456789012:cert/2e1eb273792174ec2b9bf4e9b37e6c6c692345499506002a35159767055278e8"
```

출력은 다음과 같습니다.

```
{
    "things": [
        "MyLightBulb1",
        "MyLightBulb2"
    ]
}
```

자세한 내용은 *AWS IoT Core API 참조*의 [ListPrincipalThings](https://docs.aws.amazon.com//iot/latest/apireference/API_ListPrincipalThings.html)를 참조하세요.

# 사물에 연결된 위탁자 나열
<a name="list-thing-principals"></a>

지정한 사물에 연결된 위탁자를 나열하려면, [https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iot/list-thing-principals.html](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iot/list-thing-principals.html) 명령을 실행합니다. 단, 이 명령은 사물과 인증서 간의 연결 유형을 나열하지 않습니다. 연결 유형을 나열하려면 [https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iot/list-thing-principalsv2.html](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iot/list-thing-principalsv2.html) 명령을 사용합니다. 자세한 내용은 [사물에 연결된 위탁자 나열 V2](list-thing-principals-v2.md) 단원을 참조하십시오.

```
$ aws iot list-thing-principals \
    --thing-name "MyLightBulb1"
```

출력은 다음과 같습니다.

```
{
    "principals": [
         "arn:aws:iot:us-east-1:123456789012:cert/2e1eb273792174ec2b9bf4e9b37e6c6c692345499506002a35159767055278e8",
         "arn:aws:iot:us-east-1:123456789012:cert/1a234b39b4b68278f2e9d84bf97eac2cbf4a1c28b23ea29a44559b9bcf8d395b"
    ]
}
```

자세한 내용은 *AWS IoT Core API 참조*의 [ListThingPrincipals](https://docs.aws.amazon.com//iot/latest/apireference/API_ListThingPrincipals.html)를 참조하세요.

# 위탁자와 연결된 사물 나열 V2
<a name="list-principal-things-v2"></a>

지정된 인증서와 연결된 사물을 연결 유형과 함께 나열하려면 [https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iot/list-principal-thingsv2.html](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iot/list-principal-thingsv2.html) 명령을 실행합니다. 연결 유형은 인증서가 사물에 연결되는 방식을 나타냅니다.

```
$ aws iot list-principal-things-v2 \
    --principal "arn:aws:iot:us-east-1:123456789012:cert/2e1eb273792174ec2b9bf4e9b37e6c6c692345499506002a35159767055278e8"
```

출력은 다음과 같습니다.

```
{
    "PrincipalThingObjects": [
        {
            "thingPrincipalType": "NON_EXCLUSIVE_THING",
            "thing": "arn:aws:iot:us-east-1:123456789012:thing/thing_1"
        }, 
        {
            "thingPrincipalType": "NON_EXCLUSIVE_THING",
            "thing": "arn:aws:iot:us-east-1:123456789012:thing/thing_2"
        }

    ]
}
```

자세한 내용은 *AWS IoT Core API 참조*의 [ListPrincipalThingsV2](https://docs.aws.amazon.com//iot/latest/apireference/API_ListPrincipalThingsV2.html)를 참조하세요.

# 사물에 연결된 위탁자 나열 V2
<a name="list-thing-principals-v2"></a>

지정된 사물에 연결된 인증서를 연결 유형과 함께 나열하려면 [https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iot/list-thing-principalsv2.html](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iot/list-thing-principalsv2.html) 명령을 실행합니다. 연결 유형은 인증서가 사물에 연결되는 방식을 나타냅니다.

```
$ aws iot list-thing-principals-v2 \
    --thing-name "thing_1"
```

출력은 다음과 같습니다.

```
{
    "ThingPrincipalObjects": [
        {
            "thingPrincipalType": "NON_EXCLUSIVE_THING",
            "principal": "arn:aws:iot:us-east-1:123456789012:cert/2e1eb273792174ec2b9bf4e9b37e6c6c692345499506002a35159767055278e8"
        },
        {
            "thingPrincipalType": "NON_EXCLUSIVE_THING",
            "principal": "arn:aws:iot:us-east-1:123456789012:cert/1a234b39b4b68278f2e9d84bf97eac2cbf4a1c28b23ea29a44559b9bcf8d395b"
        }
    ]
}
```

자세한 내용은 *AWS IoT Core API 참조*의 [ListThingsPrincipalV2](https://docs.aws.amazon.com//iot/latest/apireference/API_ListThingPrincipalsV2.html)를 참조하세요.

# 사물에서 보안 주체 분리
<a name="detach-thing-principal"></a>

다음과 같이 `DetachThingPrincipal` 명령을 사용하여 사물에서 인증서를 분리할 수 있습니다.

```
$ aws iot detach-thing-principal \
    --thing-name "MyLightBulb" \
    --principal "arn:aws:iot:us-east-1:123456789012:cert/2e1eb273792174ec2b9bf4e9b37e6c6c692345499506002a35159767055278e8"
```

**DetachThingPrincipal** 명령은 출력을 생성하지 않습니다.

자세한 내용은 *AWS IoT Core API 참조*의 [detach-thing-principal](https://docs.aws.amazon.com//iot/latest/apireference/API_DetachThingPrincipal.html)을 참조하세요.