A developer is building a command-line interface (CLI) tool that internal engineers will use to upload software builds directly to a private Amazon S3 bucket. The engineers authenticate with the company's external OpenID Connect (OIDC) identity provider. The CLI tool needs to obtain temporary AWS credentials to write to the S3 bucket directly.
Which solution meets these requirements with the least operational overhead?
- Configure an Amazon Cognito Identity Pool, register the OIDC identity provider, and link it to an IAM role that grants write access to the S3 bucket.Answer
- BConfigure an Amazon Cognito User Pool with OIDC federation, and use the user's ID token returned by the User Pool to authenticate directly to Amazon S3.
- CConfigure an Amazon API Gateway REST API with a Cognito User Pool Authorizer, and route the upload traffic through API Gateway to write to the S3 bucket.
- DConfigure an Amazon Cognito User Pool with OIDC federation, and write a custom AWS Lambda trigger to generate temporary AWS credentials using AWS Security Token Service (STS) when a user logs in.
Answer
Configure an Amazon Cognito Identity Pool, register the OIDC identity provider, and link it to an IAM role that grants write access to the S3 bucket.
The correct configuration uses an Amazon Cognito Identity Pool to federate with the OIDC identity provider. This pool directly exchanges OIDC tokens for temporary AWS IAM credentials, allowing the CLI tool to call the Amazon S3 PutObject API directly using an associated IAM role with minimum operational overhead and no custom code.
Step-by-Step Solution
Key Concept
Amazon Cognito Identity Pools (Federated Identities) are used to exchange credentials from external identity providers (such as OIDC, SAML, or social IdPs) for temporary, limited-privilege AWS credentials to directly access AWS resources like Amazon S3.