A backend service uses API Gateway (HTTP API) to invoke a Lambda function. The Lambda writes to DynamoDB and occasionally needs to read additional details from S3. To meet least-privilege and avoid hardcoding credentials, which combination of AWS features is most appropriate?
Answer
Use an IAM role for the Lambda execution with least-privilege DynamoDB and S3 permissions; grant API Gateway permission to invoke Lambda via resource-based policy
Explanation
Lambda must use an execution role to access AWS resources securely, and API Gateway requires an explicit invoke permission on the Lambda resource. This avoids static credentials and enforces least-privilege at the identity boundary.
Last reviewed: October 2026
Reviewed by FirstInTest Editorial Team
Related questions
A Node.js Lambda updates an item in DynamoDB using UpdateExpression and expects the update to fail if the record has changed since the client last read it. The client provides a version attribute. What DynamoDB strategy best ensures correct concurrency control?
View question →
You’re designing an AWS SDK-based .NET application that uploads objects to S3. The application must support resumable uploads and should minimize unnecessary retries and connection setup. What approach best fits the requirement?
View question →
In a serverless app, developers want to standardize how Lambda functions call external services with caching to reduce latency. They also want the cache to be shared across multiple concurrent function instances. The team proposes using an in-memory cache inside the Lambda handler, and also suggests storing tokens in environment variables for convenience. They need a robust approach that works across cold starts, supports token refresh, and avoids leaking secrets into logs or deployments.
View question →
A Lambda function reads multiple items from DynamoDB using BatchGetItem. The function should return a consistent view for a specific request, but the application does not require full transaction semantics across multiple tables. How can you best achieve request-level consistency?
View question →
A Lambda function is behind API Gateway and receives requests with an Authorization header. You must validate JWTs and route to different DynamoDB tables based on the tenant claim. Which approach is most secure and maintainable?
View question →
You need to ensure idempotency for an order-processing Lambda triggered by SQS messages. Messages might be delivered more than once, and processing must not double-charge. Which design is most appropriate?
View question →