A developer is implementing a smart home mobile application. The mobile client needs to authenticate users and obtain temporary, limited-privilege AWS credentials to publish telemetry data directly to Amazon IoT Core MQTT topics.
Which solution meets these requirements with the least operational overhead?
- AAuthenticate users using an Amazon Cognito User Pool. Use the Cognito User Pool ID token directly to authorize the mobile client to publish messages to AWS IoT Core.
- Authenticate users using an Amazon Cognito User Pool. Configure an Amazon Cognito Identity Pool to exchange the User Pool tokens for temporary AWS credentials associated with an IAM role that permits publishing to AWS IoT Core.Answer
- CAuthenticate users using an Amazon Cognito User Pool. Deploy an Amazon API Gateway endpoint with a custom Lambda Authorizer that validates the Cognito tokens and calls AWS STS to return temporary AWS credentials.
- DAuthenticate users using an Amazon Cognito User Pool. Embed a long-lived IAM User access key and secret access key in the mobile application configuration to perform AWS IoT Core publish operations.
Answer
Authenticate users using an Amazon Cognito User Pool. Configure an Amazon Cognito Identity Pool to exchange the User Pool tokens for temporary AWS credentials associated with an IAM role that permits publishing to AWS IoT Core.
Using an Amazon Cognito User Pool for user authentication combined with an Amazon Cognito Identity Pool to exchange tokens for temporary AWS credentials is the standard, built-in AWS pattern. The Identity Pool handles the generation of temporary credentials via an IAM role with minimum operational overhead.
Step-by-Step Solution
Key Concept
Amazon Cognito User Pools handle authentication (user directory and tokens), whereas Cognito Identity Pools handle authorization by exchanging those tokens for temporary AWS credentials.
Estimated Time:1m 30s