A developer is designing service-to-service communication between a microservice running on Amazon ECS in AWS Account A and a private REST API hosted on Amazon API Gateway in AWS Account B. The API Gateway endpoint must restrict access to only allow requests originating from the ECS microservice in Account A. The security architecture must adhere to the principle of least privilege and minimize custom code development. Which of the following configurations should the developer implement to meet these requirements?
- Configure the API Gateway method to use AWS_IAM authorization. Apply a resource policy to the API Gateway REST API in Account B that grants execute-api:Invoke permission to the specific ECS task IAM role in Account A. Configure the ECS microservice code to sign HTTP requests with Signature Version 4 (SigV4).Answer
- BCreate a custom Lambda authorizer in Account B. Configure the ECS task in Account A to obtain temporary security credentials from AWS Security Token Service (STS) in Account B, and pass the credentials in the Authorization header to the custom authorizer for manual signature verification.
- CConfigure a Cognito User Pool authorizer on the API Gateway in Account B. Configure the ECS task in Account A to authenticate directly with an Amazon Cognito identity pool in Account B to obtain an ID token, and pass this token in the Authorization header.
- DConfigure the API Gateway method to use Lambda Proxy integration with no authorizer. In the backend Lambda function, extract the caller's ECS task execution IAM role from the request context headers and return a 403 Forbidden response if the role does not match.
Answer
Configure the API Gateway method to use AWS_IAM authorization. Apply a resource policy to the API Gateway REST API in Account B that grants execute-api:Invoke permission to the specific ECS task IAM role in Account A. Configure the ECS microservice code to sign HTTP requests with Signature Version 4 (SigV4).
The correct configuration provides the most secure and operationally efficient mechanism by using API Gateway's native AWS_IAM authorization. By configuring an API Gateway resource policy, the developer can explicitly grant access to the IAM role associated with the ECS task in the external account. Since the client request must be signed, Signature Version 4 (SigV4) protocol ensures authentication and integrity of the request payload without requiring custom token management or custom Lambda authorizer code.
Step-by-Step Solution
Key Concept
Cross-account service-to-service authentication using API Gateway AWS_IAM authorization and Resource Policies.
Estimated Time:1m 30s