DVA-C02 · Question #689
A developer is testing an AWS Lambda function by using the AWS SAM local CLI. The application that is implemented by the Lambda function makes several AWS API calls by using the AWS SDK. The developer
The correct answer is B. Add a test profile by using the aws configure command with the --profile option. Run AWS SAM. Configuring a named AWS CLI profile with credentials (aws configure --profile) and then running sam local invoke with the --profile option directs the AWS SDK calls from the local Lambda function to use those credentials for API access in the test account. This is the recommended
Question
A developer is testing an AWS Lambda function by using the AWS SAM local CLI. The application that is implemented by the Lambda function makes several AWS API calls by using the AWS 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?
Options
- AEdit the template.yml file. Add the AWS_ACCESS_KEY_ID property and the
- BAdd a test profile by using the aws configure command with the --profile option. Run AWS SAM
- CEdit the template.yml file. For the AWS::Serverless::Function resource, set the role to an IAM role
- DRun the function by using the sam local invoke command. Override the AWS_ACCESS_KEY_ID
How the community answered
(54 responses)- A2% (1)
- B93% (50)
- C2% (1)
- D4% (2)
Explanation
Configuring a named AWS CLI profile with credentials (aws configure --profile) and then running sam local invoke with the --profile option directs the AWS SDK calls from the local Lambda function to use those credentials for API access in the test account. This is the recommended way to authenticate AWS SDK calls during local testing.
Community Discussion
No community discussion yet for this question.