A developer is implementing security for a new Amazon API Gateway REST API. The API has two specific endpoints:
1. `POST /orders`: Used by a mobile application where users authenticate via Amazon Cognito User Pools.
2. `GET /dashboard/metrics`: Used by an administrative reporting service running on Amazon ECS tasks.
Which TWO actions should the developer take to configure authorization for these endpoints with the least operational overhead?
- Configure the `POST /orders` method to use an Amazon Cognito User Pools authorizer to validate incoming tokens.Cevap
- Configure the `GET /dashboard/metrics` method to use `AWS_IAM` authorization, and grant the ECS task role permission to invoke the API.Cevap
- CConfigure the `POST /orders` method to use an Amazon Cognito Identity Pool authorizer to validate user identity.
- DCreate a custom Lambda authorizer for the `POST /orders` method that parses and manually validates the JSON Web Tokens (JWTs) from the mobile clients.
- EConfigure a Lambda custom integration for `GET /dashboard/metrics` that manually decodes and extracts IAM credentials from the raw request payload.
Cevap
Configure the POST /orders method to use an Amazon Cognito User Pools authorizer, and configure the GET /dashboard/metrics method to use AWS_IAM authorization while granting the ECS task role permission to invoke the API.
For the POST /orders endpoint, using a built-in Amazon Cognito User Pools authorizer is the recommended path because it requires zero custom code to validate Cognito-issued tokens. For the GET /dashboard/metrics endpoint, AWS_IAM authorization allows the administrative service running on ECS to leverage its IAM task role to sign requests with Signature Version 4, offering a secure, native method to control access without API keys or token exchange.
Adım Adım Çözüm
Anahtar Kavram
API Gateway Security and Authorization using built-in Cognito and IAM authorizers