Setting up API Gateway
In this section, we will start with extending our CloudFormation template.
First of all, we should start with some boilerplate. In the previous chapter, we had mentioned CloudWatch Logs, the service that AWS provides to store logs in a central place. API Gateway also uses CloudWatch to store HTTP logs and, like all services that try to access to other services, needs anIAM role. In this IAM role, we should give access to the apigateway.amazonaws.com service to access the CloudWatch logs and deliver this role to API Gateway as theAWS::ApiGateway::Account
resource. Now let's open our CloudFormation template and just prepend these lines to the Resources
section:
"ApiGatewayCloudwatchRole": { "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": [ ...