쿠키 기본 설정 선택

당사는 사이트와 서비스를 제공하는 데 필요한 필수 쿠키 및 유사한 도구를 사용합니다. 고객이 사이트를 어떻게 사용하는지 파악하고 개선할 수 있도록 성능 쿠키를 사용해 익명의 통계를 수집합니다. 필수 쿠키는 비활성화할 수 없지만 '사용자 지정' 또는 ‘거부’를 클릭하여 성능 쿠키를 거부할 수 있습니다.

사용자가 동의하는 경우 AWS와 승인된 제3자도 쿠키를 사용하여 유용한 사이트 기능을 제공하고, 사용자의 기본 설정을 기억하고, 관련 광고를 비롯한 관련 콘텐츠를 표시합니다. 필수가 아닌 모든 쿠키를 수락하거나 거부하려면 ‘수락’ 또는 ‘거부’를 클릭하세요. 더 자세한 내용을 선택하려면 ‘사용자 정의’를 클릭하세요.

게시/구독 정책 예제

포커스 모드
게시/구독 정책 예제 - AWS IoT Core

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

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

사용하는 정책은 연결하는 방법에 따라 다릅니다 AWS IoT Core. MQTT 클라이언트, HTTP 또는 WebSocket을 사용하여 AWS IoT Core 에 연결할 수 있습니다. MQTT 클라이언트를 사용하여 연결하는 경우 X.509 인증서를 사용하여 인증합니다. HTTP 또는 WebSocket 프로토콜을 통해 연결하는 경우 서명 버전 4 및 Amazon Cognito를 사용하여 인증합니다.

참고

등록된 디바이스의 경우 Connect 작업에 사물 정책 변수를 사용하고 연결에 사용되는 보안 주체에 사물을 연결하는 것이 좋습니다.

MQTT 및 AWS IoT Core 정책에 와일드카드 문자 사용

MQTT와 AWS IoT Core 정책은 와일드카드 문자가 다르므로 신중하게 고려한 후 선택해야 합니다. MQTT에서 와일드카드 문자 +#MQTT 주제 필터에서 여러 주제 이름을 구독하는 데 사용됩니다. AWS IoT Core 정책은 * 및를 와일드카드 문자?로 사용하고 IAM 정책의 규칙을 따릅니다. 정책 문서에서 *는 문자 조합을 나타내고 ?는 단일 문자를 나타냅니다. 정책 문서에서 MQTT 와일드카드 문자 +#은 특별한 의미가 없는 문자로 취급됩니다. 정책의 resource 속성에서 여러 주제 이름과 주제 필터를 설명하려면 MQTT 와일드카드 문자 대신 *? 와일드카드 문자를 사용하세요.

정책 문서에서 사용할 와일드카드 문자를 선택할 때는 * 문자가 하나의 주제 수준에 국한되지 않는다는 점을 고려하세요. + 문자는 MQTT 주제 필터에서 단일 주제 수준으로 제한됩니다. 와일드카드 사양을 단일 MQTT 주제 필터 수준으로 제한하려면 여러 개의 ? 문자를 사용해 보세요. 정책 리소스에서 와일드카드 문자를 사용하는 방법과 와일드카드 문자가 무엇과 일치하는지에 대한 자세한 내용은 리소스 ARN에서 와일드카드 사용을 참조하세요.

아래 표는 MQTT 및 MQTT 클라이언트의 AWS IoT Core 정책에 사용되는 다양한 와일드카드 문자를 보여줍니다.

와일드카드 문자 MQTT 와일드카드 문자입니까 MQTT 예제 AWS IoT Core 정책 와일드카드 문자임 MQTT 클라이언트 AWS IoT Core 정책 예제
# some/# No N/A
+ some/+/topic No N/A
* No N/A

topicfilter/some/*/topic

topicfilter/some/sensor*/topic

? No N/A

topic/some/?????/topic

topicfilter/some/sensor???/topic

특정 주제에 대한 메시지 게시, 구독 및 수신 정책

다음은 등록된 디바이스와 등록되지 않은 디바이스에서 'some_specific _topic'이라는 주제에 대해 메시지를 게시, 구독 및 수신하는 예를 보여줍니다. 또한 예제에서는 PublishReceive가이 'topic'을 리소스로 사용하고 Subscribe가 topicfilter'를 리소스로 사용함을 강조합니다.

Registered devices

AWS IoT Core 레지스트리에 등록된 디바이스의 경우 다음 정책은 디바이스가 레지스트리의 사물 이름과 일치하는 clientId에 연결하도록 허용합니다. 또한 'some_specific_topic'이라는 주제에 대한 Publish, SubscribeReceive 권한을 제공합니다.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:client/${iot:Connection.Thing.ThingName}" ], "Condition": { "Bool": { "iot:Connection.Thing.IsAttached": "true" } } }, { "Effect": "Allow", "Action": [ "iot:Publish" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/some_specific_topic" ] }, { "Effect": "Allow", "Action": [ "iot:Subscribe" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topicfilter/some_specific_topic" ] }, { "Effect": "Allow", "Action": [ "iot:Receive" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/some_specific_topic" ] } ] }
Unregistered devices

AWS IoT Core 레지스트리에 등록되지 않은 디바이스의 경우 다음 정책은 디바이스가 clientId1, clientId2 또는 clientId3를 사용하여 연결되도록 허용합니다. 또한 'some_specific_topic'이라는 주제에 대한 Publish, SubscribeReceive 권한을 제공합니다.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:client/clientId1", "arn:aws:iot:us-east-1:123456789012:client/clientId2", "arn:aws:iot:us-east-1:123456789012:client/clientId3" ] }, { "Effect": "Allow", "Action": [ "iot:Publish" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/some_specific_topic" ] }, { "Effect": "Allow", "Action": [ "iot:Subscribe" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topicfilter/some_specific_topic" ] }, { "Effect": "Allow", "Action": [ "iot:Receive" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/some_specific_topic" ] } ] }

AWS IoT Core 레지스트리에 등록된 디바이스의 경우 다음 정책은 디바이스가 레지스트리의 사물 이름과 일치하는 clientId에 연결하도록 허용합니다. 또한 'some_specific_topic'이라는 주제에 대한 Publish, SubscribeReceive 권한을 제공합니다.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:client/${iot:Connection.Thing.ThingName}" ], "Condition": { "Bool": { "iot:Connection.Thing.IsAttached": "true" } } }, { "Effect": "Allow", "Action": [ "iot:Publish" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/some_specific_topic" ] }, { "Effect": "Allow", "Action": [ "iot:Subscribe" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topicfilter/some_specific_topic" ] }, { "Effect": "Allow", "Action": [ "iot:Receive" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/some_specific_topic" ] } ] }

특정 접두사가 붙은 주제에 대한 메시지 게시, 구독 및 수신 정책

다음은 등록된 디바이스와 등록되지 않은 디바이스에서 'topic_prefix'라는 접두사가 붙은 주제에 대해 메시지를 게시, 구독 및 수신하는 예를 보여줍니다.

참고

이 예제에서는 와일드카드 문자 *를 사용한다는 점에 유의하세요. *는 단일 명령문에서 여러 주제 이름에 대한 권한을 제공하는 데 유용하지만 디바이스에 필요한 것보다 더 많은 권한을 제공하여 의도하지 않은 결과를 초래할 수 있습니다. 따라서 와일드카드 문자 *는 신중하게 고려한 후에만 사용하는 것이 좋습니다.

Registered devices

AWS IoT Core 레지스트리에 등록된 디바이스의 경우 다음 정책은 디바이스가 레지스트리의 사물 이름과 일치하는 clientId에 연결하도록 허용합니다. 또한 'topic_prefix' 접두사가 붙은 주제에 대한 Publish, SubscribeReceive 권한을 제공합니다.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:client/${iot:Connection.Thing.ThingName}" ], "Condition": { "Bool": { "iot:Connection.Thing.IsAttached": "true" } } }, { "Effect": "Allow", "Action": [ "iot:Publish", "iot:Receive" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/topic_prefix*" ] }, { "Effect": "Allow", "Action": [ "iot:Subscribe" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topicfilter/topic_prefix*" ] } ] }
Unregistered devices

AWS IoT Core 레지스트리에 등록되지 않은 디바이스의 경우 다음 정책은 디바이스가 clientId1, clientId2 또는 clientId3를 사용하여 연결되도록 허용합니다. 또한 'topic_prefix' 접두사가 붙은 주제에 대한 Publish, SubscribeReceive 권한을 제공합니다.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:client/clientId1", "arn:aws:iot:us-east-1:123456789012:client/clientId2", "arn:aws:iot:us-east-1:123456789012:client/clientId3" ] }, { "Effect": "Allow", "Action": [ "iot:Publish", "iot:Receive" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/topic_prefix*" ] }, { "Effect": "Allow", "Action": [ "iot:Subscribe" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topicfilter/topic_prefix*" ] } ] }

AWS IoT Core 레지스트리에 등록된 디바이스의 경우 다음 정책은 디바이스가 레지스트리의 사물 이름과 일치하는 clientId에 연결하도록 허용합니다. 또한 'topic_prefix' 접두사가 붙은 주제에 대한 Publish, SubscribeReceive 권한을 제공합니다.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:client/${iot:Connection.Thing.ThingName}" ], "Condition": { "Bool": { "iot:Connection.Thing.IsAttached": "true" } } }, { "Effect": "Allow", "Action": [ "iot:Publish", "iot:Receive" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/topic_prefix*" ] }, { "Effect": "Allow", "Action": [ "iot:Subscribe" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topicfilter/topic_prefix*" ] } ] }

각 디바이스와 관련된 주제에 대한 메시지 게시, 구독 및 수신 정책

다음은 등록된 디바이스와 등록되지 않은 디바이스에서 해당 디바이스와 관련된 주제에 대해 메시지를 게시, 구독 및 수신하는 예를 보여줍니다.

Registered devices

AWS IoT Core 레지스트리에 등록된 디바이스의 경우 다음 정책은 디바이스가 레지스트리의 사물 이름과 일치하는 clientId에 연결하도록 허용합니다. 이 정책은 사물별 주제(sensor/device/${iot:Connection.Thing.ThingName})에 게시하고 사물별 주제(command/device/${iot:Connection.Thing.ThingName})를 구독 및 수신할 수 있는 권한을 제공합니다. 레지스트리의 사물 이름이 ‘thing1’인 경우 디바이스는 ‘sensor/device/thing1’ 주제에 게시할 수 있습니다. 또한 디바이스는 'command/device/thing1' 주제를 구독하고 수신할 수 있습니다.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:client/${iot:Connection.Thing.ThingName}" ], "Condition": { "Bool": { "iot:Connection.Thing.IsAttached": "true" } } }, { "Effect": "Allow", "Action": [ "iot:Publish" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/sensor/device/${iot:Connection.Thing.ThingName}" ] }, { "Effect": "Allow", "Action": [ "iot:Subscribe" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topicfilter/command/device/${iot:Connection.Thing.ThingName}" ] }, { "Effect": "Allow", "Action": [ "iot:Receive" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/command/device/${iot:Connection.Thing.ThingName}" ] } ] }
Unregistered devices

AWS IoT Core 레지스트리에 등록되지 않은 디바이스의 경우 다음 정책은 디바이스가 clientId1, clientId2 또는 clientId3를 사용하여 연결되도록 허용합니다. 이 정책은 클라이언트별 주제(sensor/device/${iot:ClientId})에 게시하고 클라이언트별 주제(command/device/${iot:ClientId})를 구독 및 수신할 수 있는 권한을 제공합니다. 디바이스가 clientId1으로 clientId와 연결되는 경우 'sensor/device/clientId1' 주제에 게시할 수 있습니다. 또한 디바이스는 device/clientId1/command 주제를 구독하고 수신할 수 있습니다.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:client/clientId1", "arn:aws:iot:us-east-1:123456789012:client/clientId2", "arn:aws:iot:us-east-1:123456789012:client/clientId3" ] }, { "Effect": "Allow", "Action": [ "iot:Publish" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/sensor/device/${iot:Connection.Thing.ThingName}" ] }, { "Effect": "Allow", "Action": [ "iot:Subscribe" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topicfilter/command/device/${iot:Connection.Thing.ThingName}" ] }, { "Effect": "Allow", "Action": [ "iot:Receive" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/command/device/${iot:Connection.Thing.ThingName}" ] } ] }

AWS IoT Core 레지스트리에 등록된 디바이스의 경우 다음 정책은 디바이스가 레지스트리의 사물 이름과 일치하는 clientId에 연결하도록 허용합니다. 이 정책은 사물별 주제(sensor/device/${iot:Connection.Thing.ThingName})에 게시하고 사물별 주제(command/device/${iot:Connection.Thing.ThingName})를 구독 및 수신할 수 있는 권한을 제공합니다. 레지스트리의 사물 이름이 ‘thing1’인 경우 디바이스는 ‘sensor/device/thing1’ 주제에 게시할 수 있습니다. 또한 디바이스는 'command/device/thing1' 주제를 구독하고 수신할 수 있습니다.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:client/${iot:Connection.Thing.ThingName}" ], "Condition": { "Bool": { "iot:Connection.Thing.IsAttached": "true" } } }, { "Effect": "Allow", "Action": [ "iot:Publish" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/sensor/device/${iot:Connection.Thing.ThingName}" ] }, { "Effect": "Allow", "Action": [ "iot:Subscribe" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topicfilter/command/device/${iot:Connection.Thing.ThingName}" ] }, { "Effect": "Allow", "Action": [ "iot:Receive" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/command/device/${iot:Connection.Thing.ThingName}" ] } ] }

주제 이름에 사물 속성이 포함된 주제에 대한 메시지 게시, 구독 및 수신 정책

다음은 등록된 디바이스에서 이름에 사물 속성이 포함된 주제를 게시, 구독 및 수신하는 예를 보여줍니다.

참고

사물 속성은 AWS IoT Core 레지스트리에 등록된 디바이스에만 존재합니다. 등록되지 않은 디바이스에 해당하는 예제는 없습니다.

Registered devices

AWS IoT Core 레지스트리에 등록된 디바이스의 경우 다음 정책은 디바이스가 레지스트리의 사물 이름과 일치하는 clientId에 연결하도록 허용합니다. 이 정책은 주제 이름에 사물 속성이 포함된 경우 주제(sensor/${iot:Connection.Thing.Attributes[version]})에 게시하고 주제(command/${iot:Connection.Thing.Attributes[location]})를 구독 및 수신할 수 있는 권한을 제공합니다. 레지스트리에 있는 사물 이름에 version=v1location=Seattle이 있는 경우 디바이스는 'sensor/v1' 주제에 게시하고 'command/Seattle' 주제를 구독 및 수신할 수 있습니다.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:client/${iot:Connection.Thing.ThingName}" ], "Condition": { "Bool": { "iot:Connection.Thing.IsAttached": "true" } } }, { "Effect": "Allow", "Action": [ "iot:Publish" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/sensor/${iot:Connection.Thing.Attributes[version]}" ] }, { "Effect": "Allow", "Action": [ "iot:Subscribe" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topicfilter/command/${iot:Connection.Thing.Attributes[location]}" ] }, { "Effect": "Allow", "Action": [ "iot:Receive" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/command/${iot:Connection.Thing.Attributes[location]}" ] } ] }
Unregistered devices

사물 속성은 AWS IoT Core 의 레지스트리에 등록된 디바이스에만 존재하므로 등록되지 않은 사물에 해당하는 예제는 없습니다.

AWS IoT Core 레지스트리에 등록된 디바이스의 경우 다음 정책은 디바이스가 레지스트리의 사물 이름과 일치하는 clientId에 연결하도록 허용합니다. 이 정책은 주제 이름에 사물 속성이 포함된 경우 주제(sensor/${iot:Connection.Thing.Attributes[version]})에 게시하고 주제(command/${iot:Connection.Thing.Attributes[location]})를 구독 및 수신할 수 있는 권한을 제공합니다. 레지스트리에 있는 사물 이름에 version=v1location=Seattle이 있는 경우 디바이스는 'sensor/v1' 주제에 게시하고 'command/Seattle' 주제를 구독 및 수신할 수 있습니다.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:client/${iot:Connection.Thing.ThingName}" ], "Condition": { "Bool": { "iot:Connection.Thing.IsAttached": "true" } } }, { "Effect": "Allow", "Action": [ "iot:Publish" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/sensor/${iot:Connection.Thing.Attributes[version]}" ] }, { "Effect": "Allow", "Action": [ "iot:Subscribe" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topicfilter/command/${iot:Connection.Thing.Attributes[location]}" ] }, { "Effect": "Allow", "Action": [ "iot:Receive" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/command/${iot:Connection.Thing.Attributes[location]}" ] } ] }

주제 이름의 하위 주제에 대한 메시지 게시를 거부하는 정책

다음은 등록된 디바이스와 등록되지 않은 디바이스에서 특정 하위 주제를 제외한 모든 주제에 메시지를 게시하는 예를 보여줍니다.

Registered devices

AWS IoT Core 레지스트리에 등록된 디바이스의 경우 다음 정책은 디바이스가 레지스트리의 사물 이름과 일치하는 clientId에 연결하도록 허용합니다. 이 정책은 'department/' 접두사가 붙은 모든 주제에 게시할 수 있는 권한을 제공하지만 'department/admins' 하위 주제에 게시할 수 있는 권한은 제공하지 않습니다.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:client/${iot:Connection.Thing.ThingName}" ], "Condition": { "Bool": { "iot:Connection.Thing.IsAttached": "true" } } }, { "Effect": "Allow", "Action": [ "iot:Publish" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/department/*" ] }, { "Effect": "Deny", "Action": [ "iot:Publish" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/department/admins" ] } ] }
Unregistered devices

AWS IoT Core 레지스트리에 등록되지 않은 디바이스의 경우 다음 정책은 디바이스가 clientId1, clientId2 또는 clientId3를 사용하여 연결되도록 허용합니다. 이 정책은 'department/' 접두사가 붙은 모든 주제에 게시할 수 있는 권한을 제공하지만 'department/admins' 하위 주제에 게시할 수 있는 권한은 제공하지 않습니다.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:client/clientId1", "arn:aws:iot:us-east-1:123456789012:client/clientId2", "arn:aws:iot:us-east-1:123456789012:client/clientId3" ] }, { "Effect": "Allow", "Action": [ "iot:Publish" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/department/*" ] }, { "Effect": "Deny", "Action": [ "iot:Publish" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/department/admins" ] } ] }

AWS IoT Core 레지스트리에 등록된 디바이스의 경우 다음 정책은 디바이스가 레지스트리의 사물 이름과 일치하는 clientId에 연결하도록 허용합니다. 이 정책은 'department/' 접두사가 붙은 모든 주제에 게시할 수 있는 권한을 제공하지만 'department/admins' 하위 주제에 게시할 수 있는 권한은 제공하지 않습니다.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:client/${iot:Connection.Thing.ThingName}" ], "Condition": { "Bool": { "iot:Connection.Thing.IsAttached": "true" } } }, { "Effect": "Allow", "Action": [ "iot:Publish" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/department/*" ] }, { "Effect": "Deny", "Action": [ "iot:Publish" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/department/admins" ] } ] }

주제 이름의 하위 주제에 대한 메시지 수신을 거부하는 정책

다음은 등록된 디바이스와 등록되지 않은 디바이스에서 특정 하위 주제를 제외한 특정 접두사가 붙은 주제에 대해 메시지를 구독하고 수신하는 예를 보여줍니다.

Registered devices

AWS IoT Core 레지스트리에 등록된 디바이스의 경우 다음 정책은 디바이스가 레지스트리의 사물 이름과 일치하는 clientId에 연결하도록 허용합니다. 이 정책은 디바이스가 'topic_prefix' 접두사가 붙은 모든 주제를 구독할 수 있도록 허용합니다. iot:Receive 명령문에서 NotResource를 사용하면 'topic_prefix/restricted' 접두사가 붙은 주제를 제외하고 디바이스가 구독한 모든 주제에서 메시지를 수신할 수 있습니다. 예를 들어, 이 정책에 따라 디바이스는 'topic_prefix/topic1' 및 'topic_prefix/restricted'를 구독할 수 있지만 'topic_prefix/topic1' 주제의 메시지만 수신하고 'topic_prefix/restricted' 주제의 메시지는 수신하지 않습니다.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:client/${iot:Connection.Thing.ThingName}" ], "Condition": { "Bool": { "iot:Connection.Thing.IsAttached": "true" } } }, { "Effect": "Allow", "Action": "iot:Subscribe", "Resource": "arn:aws:iot:us-east-1:123456789012:topicfilter/topic_prefix/*" }, { "Effect": "Allow", "Action": "iot:Receive", "NotResource": "arn:aws:iot:us-east-1:123456789012:topic/topic_prefix/restricted/*" } ] }
Unregistered devices

AWS IoT Core 레지스트리에 등록되지 않은 디바이스의 경우 다음 정책은 디바이스가 clientId1, clientId2 또는 clientId3를 사용하여 연결되도록 허용합니다. 이 정책은 디바이스가 'topic_prefix' 접두사가 붙은 모든 주제를 구독할 수 있도록 허용합니다. iot:Receive 명령문에서 NotResource를 사용하면 'topic_prefix/restricted' 접두사가 붙은 주제를 제외하고 디바이스가 구독한 모든 주제에서 메시지를 수신할 수 있습니다. 예를 들어 이 정책을 사용하면 디바이스가 'topic_prefix/topic1'과 'topic_prefix/restricted'을 구독할 수 있습니다. 하지만 주제 'topic_prefix/topic1'에서는 메시지만 수신하고 주제 'topic_prefix/restricted'에서는 메시지를 수신하지 않습니다.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:client/clientId1", "arn:aws:iot:us-east-1:123456789012:client/clientId2", "arn:aws:iot:us-east-1:123456789012:client/clientId3" ] }, { "Effect": "Allow", "Action": "iot:Subscribe", "Resource": "arn:aws:iot:us-east-1:123456789012:topicfilter/topic_prefix/*" }, { "Effect": "Allow", "Action": "iot:Receive", "NotResource": "arn:aws:iot:us-east-1:123456789012:topic/topic_prefix/restricted/*" } ] }

AWS IoT Core 레지스트리에 등록된 디바이스의 경우 다음 정책은 디바이스가 레지스트리의 사물 이름과 일치하는 clientId에 연결하도록 허용합니다. 이 정책은 디바이스가 'topic_prefix' 접두사가 붙은 모든 주제를 구독할 수 있도록 허용합니다. iot:Receive 명령문에서 NotResource를 사용하면 'topic_prefix/restricted' 접두사가 붙은 주제를 제외하고 디바이스가 구독한 모든 주제에서 메시지를 수신할 수 있습니다. 예를 들어, 이 정책에 따라 디바이스는 'topic_prefix/topic1' 및 'topic_prefix/restricted'를 구독할 수 있지만 'topic_prefix/topic1' 주제의 메시지만 수신하고 'topic_prefix/restricted' 주제의 메시지는 수신하지 않습니다.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:client/${iot:Connection.Thing.ThingName}" ], "Condition": { "Bool": { "iot:Connection.Thing.IsAttached": "true" } } }, { "Effect": "Allow", "Action": "iot:Subscribe", "Resource": "arn:aws:iot:us-east-1:123456789012:topicfilter/topic_prefix/*" }, { "Effect": "Allow", "Action": "iot:Receive", "NotResource": "arn:aws:iot:us-east-1:123456789012:topic/topic_prefix/restricted/*" } ] }

MQTT 와일드카드 문자를 사용하여 주제를 구독하는 정책

MQTT 와일드카드 문자 + 및 #은 리터럴 문자열로 처리되지만 AWS IoT Core 정책에서 사용할 때는 와일드카드로 처리되지 않습니다. MQTT에서 + 및 #은 주제 필터를 구독할 때만 와일드카드로 취급되고 다른 모든 컨텍스트에서는 리터럴 문자열로 취급됩니다. 신중한 고려 후 AWS IoT Core 정책의 일부로만 이러한 MQTT 와일드카드를 사용하는 것이 좋습니다.

다음은 AWS IoT Core 정책에서 MQTT 와일드카드를 사용하는 등록된 사물과 등록되지 않은 사물의 예를 보여줍니다. 이러한 와일드카드는 리터럴 문자열로 취급됩니다.

Registered devices

AWS IoT Core 레지스트리에 등록된 디바이스의 경우 다음 정책은 디바이스가 레지스트리의 사물 이름과 일치하는 clientId에 연결하도록 허용합니다. 이 정책은 디바이스가 'department/+/employees' 및 'location/#' 주제를 구독할 수 있도록 허용합니다. + 및 #은 AWS IoT Core 정책에서 리터럴 문자열로 취급되기 때문에 디바이스가 'department/+/employees' 주제를 구독할 수 있지만 'department/engineering/employees' 주제는 구독할 수 없습니다. 마찬가지로, 디바이스는 'location/#' 주제를 구독할 수 있지만 'location/Seattle' 주제는 구독할 수 없습니다. 그러나 디바이스가 'department/+/employees' 주제를 구독하면 정책에 따라 'department/engineering/employees' 주제에서 메시지를 수신할 수 있습니다. 마찬가지로, 디바이스가 'location/#' 주제를 구독하면 'location/Seattle' 주제에서도 메시지를 수신하게 됩니다.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:client/${iot:Connection.Thing.ThingName}" ], "Condition": { "Bool": { "iot:Connection.Thing.IsAttached": "true" } } }, { "Effect": "Allow", "Action": "iot:Subscribe", "Resource": "arn:aws:iot:us-east-1:123456789012:topicfilter/department/+/employees" }, { "Effect": "Allow", "Action": "iot:Subscribe", "Resource": "arn:aws:iot:us-east-1:123456789012:topicfilter/location/#" }, { "Effect": "Allow", "Action": "iot:Receive", "Resource": "arn:aws:iot:us-east-1:123456789012:topic/*" } ] }
Unregistered devices

AWS IoT Core 레지스트리에 등록되지 않은 디바이스의 경우 다음 정책은 디바이스가 clientId1, clientId2 또는 clientId3를 사용하여 연결되도록 허용합니다. 이 정책은 디바이스가 'department/+/employees' 및 'location/#' 주제를 구독할 수 있도록 허용합니다. + 및 #은 AWS IoT Core 정책에서 리터럴 문자열로 취급되기 때문에 디바이스가 'department/+/employees' 주제를 구독할 수 있지만 'department/engineering/employees' 주제는 구독할 수 없습니다. 마찬가지로, 디바이스는 'location/#' 주제를 구독할 수 있지만 'location/Seattle' 주제는 구독할 수 없습니다. 그러나 디바이스가 'department/+/employees' 주제를 구독하면 정책에 따라 'department/engineering/employees' 주제에서 메시지를 수신할 수 있습니다. 마찬가지로, 디바이스가 'location/#' 주제를 구독하면 'location/Seattle' 주제에서도 메시지를 수신하게 됩니다.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:client/clientId1", "arn:aws:iot:us-east-1:123456789012:client/clientId2", "arn:aws:iot:us-east-1:123456789012:client/clientId3" ] }, { "Effect": "Allow", "Action": "iot:Subscribe", "Resource": "arn:aws:iot:us-east-1:123456789012:topicfilter/department/+/employees" }, { "Effect": "Allow", "Action": "iot:Subscribe", "Resource": "arn:aws:iot:us-east-1:123456789012:topicfilter/location/#" }, { "Effect": "Allow", "Action": "iot:Receive", "Resource": "arn:aws:iot:us-east-1:123456789012:topic/*" } ] }

AWS IoT Core 레지스트리에 등록된 디바이스의 경우 다음 정책은 디바이스가 레지스트리의 사물 이름과 일치하는 clientId에 연결하도록 허용합니다. 이 정책은 디바이스가 'department/+/employees' 및 'location/#' 주제를 구독할 수 있도록 허용합니다. + 및 #은 AWS IoT Core 정책에서 리터럴 문자열로 취급되기 때문에 디바이스가 'department/+/employees' 주제를 구독할 수 있지만 'department/engineering/employees' 주제는 구독할 수 없습니다. 마찬가지로, 디바이스는 'location/#' 주제를 구독할 수 있지만 'location/Seattle' 주제는 구독할 수 없습니다. 그러나 디바이스가 'department/+/employees' 주제를 구독하면 정책에 따라 'department/engineering/employees' 주제에서 메시지를 수신할 수 있습니다. 마찬가지로, 디바이스가 'location/#' 주제를 구독하면 'location/Seattle' 주제에서도 메시지를 수신하게 됩니다.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:client/${iot:Connection.Thing.ThingName}" ], "Condition": { "Bool": { "iot:Connection.Thing.IsAttached": "true" } } }, { "Effect": "Allow", "Action": "iot:Subscribe", "Resource": "arn:aws:iot:us-east-1:123456789012:topicfilter/department/+/employees" }, { "Effect": "Allow", "Action": "iot:Subscribe", "Resource": "arn:aws:iot:us-east-1:123456789012:topicfilter/location/#" }, { "Effect": "Allow", "Action": "iot:Receive", "Resource": "arn:aws:iot:us-east-1:123456789012:topic/*" } ] }

HTTP 및 WebSocket 클라이언트용 정책

HTTP 또는 WebSocket 프로토콜을 통해 연결하는 경우 서명 버전 4 및 Amazon Cognito를 사용하여 인증합니다. Amazon Cognito 자격 증명은 인증되거나 인증되지 않을 수 있습니다. 인증된 자격 증명은 지원되는 자격 증명 공급자가 인증한 사용자를 위한 것이고, 인증되지 않은 자격 증명은 대개 자격 증명 공급자를 통해 인증하지 않는 게스트 사용자에 속합니다. Amazon Cognito는 인증되지 않은 자격 증명을 지원하는 고유 식별자 및 AWS 자격 증명을 제공합니다. 자세한 내용은 Amazon Cognito 자격 증명으로 권한 부여 단원을 참조하십시오.

다음 작업의 경우 AttachPolicy API를 통해 Amazon Cognito 자격 증명에 연결된 AWS IoT Core 정책을 AWS IoT Core 사용합니다. 이렇게 하면 인증된 자격 증명이 있는 Amazon Cognito ID 풀에 연결된 권한의 범위가 줄어듭니다.

  • iot:Connect

  • iot:Publish

  • iot:Subscribe

  • iot:Receive

  • iot:GetThingShadow

  • iot:UpdateThingShadow

  • iot:DeleteThingShadow

즉, Amazon Cognito 자격 증명에는 IAM 역할 정책 및 AWS IoT Core 정책의 권한이 필요합니다. AttachPolicy API를 통해 풀에 IAM 역할 정책을 연결하고 Amazon Cognito 자격 증명에 AWS IoT Core AWS IoT Core 정책을 연결합니다.

인증된 사용자와 인증되지 않은 사용자의 자격 증명 유형은 서로 다릅니다. Amazon Cognito 자격 증명에 AWS IoT 정책을 연결하지 않으면 인증된 사용자가에서 권한 부여에 실패 AWS IoT 하고 AWS IoT 리소스 및 작업에 액세스할 수 없습니다.

참고

다른 AWS IoT Core 작업 또는 인증되지 않은 자격 증명의 경우 AWS IoT Core 는 Amazon Cognito 자격 증명 풀 역할에 연결된 권한의 범위를 좁히지 않습니다. 인증된 자격 증명과 인증되지 않은 자격 증명 모두에 대해 이 정책은 Amazon Cognito 풀 역할에 연결하도록 권장되는 가장 허용적인 정책입니다.

HTTP

인증되지 않은 Amazon Cognito 자격 증명이 Amazon Cognito 자격 증명별 주제에 HTTP를 통해 메시지를 게시하도록 허용하려면 Amazon Cognito 자격 증명 풀 역할에 다음 IAM 정책을 연결합니다.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Publish", ], "Resource": ["arn:aws:iot:us-east-1:123456789012:topic/${cognito-identity.amazonaws.com:sub}"] } ] }

인증된 사용자를 허용하려면 이전 정책을 Amazon Cognito 자격 증명 풀 역할과 AWS IoT Core AttachPolicy API를 사용하여 Amazon Cognito 자격 증명에 연결합니다.

참고

Amazon Cognito 자격 증명을 승인할 때는 정책을 모두 AWS IoT Core 고려하고 지정된 최소 권한을 부여합니다. 두 정책이 모두 요청된 작업을 허용하는 경우에만 작업이 허용됩니다. 어느 한 정책이 작업을 허용하지 않을 경우 해당 작업은 승인되지 않습니다.

MQTT

인증되지 않은 Amazon Cognito 자격 증명이 사용자 계정의 Amazon Cognito 자격 증명별 주제에 WebSocket를 통해 MQTT 메시지를 게시하도록 허용하려면 Amazon Cognito 자격 증명 풀 역할에 다음 IAM 정책을 연결합니다.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Publish" ], "Resource": ["arn:aws:iot:us-east-1:123456789012:topic/${cognito-identity.amazonaws.com:sub}"] }, { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": ["arn:aws:iot:us-east-1:123456789012:client/${cognito-identity.amazonaws.com:sub}"] } ] }

인증된 사용자를 허용하려면 이전 정책을 Amazon Cognito 자격 증명 풀 역할과 AWS IoT Core AttachPolicy API를 사용하여 Amazon Cognito 자격 증명에 연결합니다.

참고

Amazon Cognito 자격 증명을 승인할 때는 지정된 최소 권한을 모두 AWS IoT Core 고려하고 부여합니다. 두 정책이 모두 요청된 작업을 허용하는 경우에만 작업이 허용됩니다. 어느 한 정책이 작업을 허용하지 않을 경우 해당 작업은 승인되지 않습니다.

프라이버시사이트 이용 약관쿠키 기본 설정
© 2025, Amazon Web Services, Inc. 또는 계열사. All rights reserved.