연결 정책 예제 - AWS IoT Core

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

연결 정책 예제

다음 정책은 클라이언트 ID에 대한 권한 client1client2 연결 권한을 AWS IoT Core거부하지만 클라이언트 ID를 사용하여 장치를 연결할 수 있도록 허용합니다. 클라이언트 ID는 AWS IoT Core 레지스트리에 등록되고 연결에 사용되는 보안 주체에 연결된 사물의 이름과 일치합니다.

참고

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

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Deny", "Action": [ "iot:Connect" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:client/client1", "arn:aws:iot:us-east-1:123456789012:client/client2" ] }, { "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" } } } ] }

다음 정책은 클라이언트 AWS IoT Core ID로 연결할 수 있는 권한을 client1 부여합니다. 이 정책 예시는 등록되지 않은 디바이스를 위한 것입니다.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:client/client1" ] } ] }

MQTT 영구 세션 정책 예

connectAttributes을(를) 사용하면 IAM 정책의 연결 메시지에 사용할 속성(예: PersistentConnect 또는 LastWill)을 지정할 수 있습니다. 자세한 정보는 connectAttributes 사용을 참조하세요.

다음 정책은 PersistentConnect 기능이 있는 연결을 허용합니다.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": "arn:aws:iot:us-east-1:123456789012:client/client1", "Condition": { "ForAllValues:StringEquals": { "iot:ConnectAttributes": [ "PersistentConnect" ] } } } ] }

다음 정책에서는 PersistentConnect을(를) 허용하지 않고 다른 기능은 허용됩니다.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": "arn:aws:iot:us-east-1:123456789012:client/client1", "Condition": { "ForAllValues:StringNotEquals": { "iot:ConnectAttributes": [ "PersistentConnect" ] } } } ] }

위의 정책은 StringEquals을(를) 사용하여 표현할 수도 있습니다. 새 기능을 포함한 다른 모든 기능이 허용됩니다.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": "arn:aws:iot:us-east-1:123456789012:client/client1", }, { "Effect": "Deny", "Action": [ "iot:Connect" ], "Resource": "*", "Condition": { "ForAnyValue:StringEquals": { "iot:ConnectAttributes": [ "PersistentConnect" ] } } } ] }

다음 정책은 PersistentConnectLastWill 둘 다에 의한 연결을 허용합니다. 다른 새로운 기능은 허용되지 않습니다.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": "arn:aws:iot:us-east-1:123456789012:client/client1", "Condition": { "ForAllValues:StringEquals": { "iot:ConnectAttributes": [ "PersistentConnect", "LastWill" ] } } } ] }

다음 정책은 LastWill이(가) 있거나 없는 클라이언트에 의한 클린 연결을 허용합니다. 다른 기능은 허용되지 않습니다.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": "arn:aws:iot:us-east-1:123456789012:client/client1", "Condition": { "ForAllValues:StringEquals": { "iot:ConnectAttributes": [ "LastWill" ] } } } ] }

다음 정책은 기본 기능을 사용하는 연결만 허용합니다.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": "arn:aws:iot:us-east-1:123456789012:client/client1", "Condition": { "ForAllValues:StringEquals": { "iot:ConnectAttributes": [] } } } ] }

다음 정책은 PersistentConnect이 있어야만 연결을 허용합니다. 연결에 PersistentConnect을(를) 사용하는 한 새로운 기능이 허용됩니다.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": "arn:aws:iot:us-east-1:123456789012:client/client1", "Condition": { "ForAnyValue:StringEquals": { "iot:ConnectAttributes": [ "PersistentConnect" ] } } } ] }

다음 정책은 연결에 PersistentConnectLastWill 두 가지가 모두 있어야 함을 나타냅니다. 새로운 기능은 허용되지 않습니다.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": "arn:aws:iot:us-east-1:123456789012:client/client1", "Condition": { "ForAllValues:StringEquals": { "iot:ConnectAttributes": [ "PersistentConnect", "LastWill" ] } } }, { "Effect": "Deny", "Action": [ "iot:Connect" ], "Resource": "*", "Condition": { "ForAllValues:StringEquals": { "iot:ConnectAttributes": [ "PersistentConnect" ] } } }, { "Effect": "Deny", "Action": [ "iot:Connect" ], "Resource": "*", "Condition": { "ForAllValues:StringEquals": { "iot:ConnectAttributes": [ "LastWill" ] } } }, { "Effect": "Deny", "Action": [ "iot:Connect" ], "Resource": "*", "Condition": { "ForAllValues:StringEquals": { "iot:ConnectAttributes": [] } } } ] }

다음 정책에는 PersistentConnect이(가) 없어야 하지만 LastWill은(는) 있을 수 있습니다. 다른 새로운 기능은 허용되지 않습니다.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Deny", "Action": [ "iot:Connect" ], "Resource": "*", "Condition": { "ForAnyValue:StringEquals": { "iot:ConnectAttributes": [ "PersistentConnect" ] } } }, { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": "arn:aws:iot:us-east-1:123456789012:client/client1", "Condition": { "ForAllValues:StringEquals": { "iot:ConnectAttributes": [ "LastWill" ] } } } ] }

다음 정책은 "my/lastwill/topicName" 주제와 관련된 LastWill이 있는 클라이언트에 의해서만 연결을 허용합니다. LastWill 주제를 사용하는 한 모든 기능이 허용됩니다.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": "arn:aws:iot:us-east-1:123456789012:client/client1", "Condition": { "ArnEquals": { "iot:LastWillTopic": "arn:aws:iot:region:account-id:topic/my/lastwill/topicName" } } } ] }

다음 정책은 특정 LastWillTopic을(를) 사용하는 클린 연결만 허용합니다. LastWillTopic을(를) 사용하는 한 모든 기능이 허용됩니다.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": "arn:aws:iot:us-east-1:123456789012:client/client1", "Condition": { "ArnEquals": { "iot:LastWillTopic": "arn:aws:iot:region:account-id:topic/my/lastwill/topicName" } } }, { "Effect": "Deny", "Action": [ "iot:Connect" ], "Resource": "*", "Condition": { "ForAnyValue:StringEquals": { "iot:ConnectAttributes": [ "PersistentConnect" ] } } } ] }