An organization is designing a microservice that will run on AWS Lambda within a private subnet to process messages. The microservice uses the AWS SDK to retrieve sensitive configuration data. During local testing on developer workstations, the application needs to use credentials from a local AWS CLI profile named `dev-profile`. When running on AWS, the microservice must run securely with minimal privilege and without hardcoded secrets.
Which two configuration steps should the developer perform to satisfy these requirements? (Select TWO.)
- Set the AWS_PROFILE environment variable to dev-profile on the developers' local workstations.Cevap
- Assign an IAM execution role with the required permissions to the Lambda function.Cevap
- CInitialize the AWS SDK clients by passing the AWS Access Key ID and Secret Access Key retrieved from the developer profile directly in the constructor.
- DConfigure the Lambda function's resource policy to trust the developer IAM user to allow access to AWS services.
- EDeploy a NAT Gateway in the private subnet where the Lambda function resides to allow it to retrieve secrets from AWS Secrets Manager.
Cevap
To satisfy the requirements, the developer should set the AWS_PROFILE environment variable to the named developer profile on local workstations, and assign an IAM execution role with the necessary permissions to the AWS Lambda function in the production environment.
The correct actions involve setting the environment variable to specify the local named profile and assigning an IAM execution role to the Lambda function. The default credential provider chain of the AWS SDK handles both scenarios seamlessly: locally it resolves the profile via the environment variable, and in Lambda it retrieves the temporary credentials from the execution role.
Adım Adım Çözüm
Anahtar Kavram
AWS SDK Default Credential Provider Chain