Serverless-application-model: Add x-ray enable flag to API gateway

Created on 13 Sep 2018  路  11Comments  路  Source: aws/serverless-application-model

Description:

Hi, a recent announcement of x-ray support for API gateway --https://aws.amazon.com/blogs/aws/apigateway-xray/

Will that be added to SAM soon?

typfeature

Most helpful comment

Released!

All 11 comments

I was trying to enable it through SAM too.

The unfortunate part is that even in CloudFormation AWS::ApiGateway::Stage I couldn't find any config to enable it.

Also in the docs, no CloudFormation.

Enabling X-Ray tracing in the API Gateway console
Enabling AWS X-Ray tracing in the API Gateway CLI
Enabling AWS X-Ray tracing using the API Gateway REST API

The good part is that once it is enabled in console, it won't change when you redeploy the SAM template (at least for now).

As a temporary workaround, I built a custom resource to toggle the setting:

  ApiGatewayStage:
    Properties:
      RestApiId: !Ref ServerlessRestApi
      ServiceToken: !GetAtt CustomResourceFunction.Arn
      Stage: !Ref ServerlessRestApiProdStage
      TracingEnabled: true
    Type: Custom::ApiGatewayStage

From https://github.com/nzoschke/gofaas/blob/master/template.yml#L197-L203

With the Lambda implementation handler here:

https://github.com/nzoschke/gofaas/blob/master/cfresource.go

This would be a great first PR if anyone wanted to give it a shot.

Any idea when this will be released? I'm hoping to avoid a post deployment script if possible.

Thanks!

@terodox Thanks for asking. We're not able to share internal dates so the best I can say is "soon".

Weird, the spec mentions TracingEnabled is included in AWS::Serverless::Api however it fails when deploying:

Embedded stack arn:aws:cloudformation:us-east-1:xxxxxx:stack/xxxxxx was not successfully updated. Currently in UPDATE_ROLLBACK_IN_PROGRESS with reason: Transform AWS::Serverless-2016-10-31 failed with: Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [apigatewaySlack] is invalid. property TracingEnabled not defined for resource of type AWS::Serverless::Api

And the CFN reference is:

    apigatewaySlack:
        Type: AWS::Serverless::Api
        Properties:
            StageName: !Ref stage
            DefinitionUri: ../../sam/api/swagger.yaml
            TracingEnabled: true
            AccessLogSetting:
                DestinationArn: cwlaccesslogs.Arn
            MethodSettings: 
                DataTraceEnabled: true
                HttpMethod: '*'
                LoggingLevel: INFO
                MetricsEnabled: true
                ResourcePath: /

@alanwill The spec in the master branch doesn't mention TracingEnabled. It got merged into the develop branch so far, but hasn't been released yet. Therefore it's not available for use yet.

ETA for the release ? I still got "property TracingEnabled not defined for resource of type AWS::Serverless::Api"

Unfortunately we can't comment on any specific date, but we are actively working towards a release - this is a top priority for our team.

I'm also looking forward to this release..

Released!

Was this page helpful?
0 / 5 - 0 ratings