A developer uses AWS SAM to deploy a serverless application. The template defines an `AWS::Serverless::Function` triggered by an API Gateway HTTP API event source, and a custom `AWS::IAM::Role` for the execution role. The deployment completes successfully. However, when the API is invoked, the client receives a ` Bad Gateway` error. The CloudWatch logs show that the Lambda service is unable to assume the configured execution role, and the function is not executed.
Here is a portion of the template:
yaml
Resources:
ProcessOrderFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: src/
Handler: index.handler
Runtime: nodejs18.x
Role: !GetAtt ExecutionRole.Arn
Events:
CreateOrder:
Type: Api
Properties:
Path: /orders
Method: post
ExecutionRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service: apigateway.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName: WriteLogs
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:PutLogEvents
Resource: '*'
The handler code in `src/index.js` is defined as:
javascript
exports.handler = async (event) => {
return "Order successfully processed!";
};
Which TWO modifications are required to resolve both the execution role assumption issue and the ` Bad Gateway` error? (Select TWO.)
- Change the service principal in the AssumeRolePolicyDocument of ExecutionRole to lambda.amazonaws.comCevap
- Modify the handler code in src/index.js to return a JSON object containing statusCode and body keysCevap
- CChange the service principal in the AssumeRolePolicyDocument of ExecutionRole to sts.amazonaws.com
- DConfigure an API Gateway integration mapping template in the SAM template to parse the raw string return value
- EIncrease the Timeout property of the Lambda function in the template to seconds to bypass proxy response validation