API Gateway & CloudWatch Logs

If you like to have detailed logs, when using XRay or need additional API Gateway metrics in CloudWatch. Add the following lines to your RailsApi under Properties.

MethodSettings:
  - ResourcePath: '/*'
    HttpMethod: '*'
    LoggingLevel: INFO
    MetricsEnabled: true
    DataTraceEnabled: true

Also, add this line to your RailsFunction under Properties. This allows XRay to trace your Lambda function.

Tracing: Active

When using CloudFront logs with Api Gateway, you may get this error when deploying you SAM stack.

CloudWatch Logs role ARN must be set in account settings to enable logging
Service: AmazonApiGateway; Status Code: 400; Error Code: BadRequestException;

There are other AWS documented ways to deal with this I recommend doing the following ClickOps™ steps for each region. Credit to Kenn Brodhagen's article How to enable CloudWatch logs for API Gateway on this topic..

Once created click on the new Role and copy the "Role ARN" to your clipboard. It's a long string of the form arn:aws:iam::<account id>:role/<role name>. This is the value you're going to paste into the API Gateway configuration.

As the article above states, you will need to have one API Gateway installed. I used the "Get Started" button and used their "Create Example API" introduction which is the PetStore app. Once that is done, you will be able to:

Lamby 🆕 Application Load Balancer ALB Support     GitHub