AWS Certified Developer – Associate — Question 392

A developer is testing an AWS Lambda function by using the AWS Serverless Application Model (AWS SAM) local CLI. The application that is implemented by the
Lambda function makes several AWS API calls by using the AWS software development kit (SDK). The developer wants to allow the function to make AWS API calls in a test AWS account from the developer's laptop.
What should the developer do to meet these requirements?

Answer options

Correct answer: B

Explanation

When executing a Lambda function locally with the AWS SAM CLI, the AWS SDK retrieves credentials from the local environment using the standard AWS toolchain. By defining a named profile with 'aws configure --profile' and passing it to 'sam local invoke --profile', the local container uses those specific credentials for AWS API calls. Storing credentials directly in template.yml or setting an IAM role in the template does not authenticate local API requests.