APIGatewayLambdaExecRole
and click Next Step.
Select the Role Type. Under AWS Service Roles, select AWS Lambda.
LogAndDynamoDBAccess
and add the following code as the policy document (be sure to first update the Amazon Resource Name (ARN) for your DynamoDB table). Click Apply Policy.
GetPetInfo
{}
) in the Execution Result section. The table is empty.
GetPetInfo
function, but use the following instead as the function code:
{}
).
Return to your GetPetInfo
Lambda function and click Test again. You should now see a single pet.
NoOp
. The function’s code will be as follows:
GET
pet information, and one will POST
pet information.
SecurePets
and click Create API.
Navigate to the Resources tab of the SecurePets
API and click the Create Resource action.
Name the resource Pets
and click Create Resource again.
In the left pane, select /pets
and then click the CreateMethod button.
In the drop-down, select GET and click the checkmark button. Provide the following configuration values for the GET
method:
POST
pet information is similar to creating the one used to GET
pet information.
In the left pane, select /pets
, and click CreateMethod.
In the drop-down, select POST, and click the checkmark button.
Select Lambda Function for Integration Type, select the region you are located in, and select UpdatePetInfo for the Lambda function.
Click Save and then OK when prompted in the popup to grant permissions to the Lambda function.
Test, and paste the following for the request body:
{}
).
Return to the GET method, and click Test again to see that the response body indicates there are two pets listed in the table:
OPTIONS
method on the API Gateway.
In the left pane, select /pets
, and click CreateMethod. In the drop down, select OPTIONS, and click the checkmark button. Select Mock for Integration Type. Click Save.
Leaving the Response Body blank, click Test. You should receive a Response Body indicating no data
.
At this point, the AWS Lambda functions and the Amazon API Gateway methods are defined with no security.