amazon-web-serviceslambdax-ray

How to integrate X-Ray with AWS Lambda function on Command line


From the console, it is possible to activate lambda integration with x-ray through the following steps: From your function in the console > Configuration tab > Advanced dropdown/section > check Enable Active Tracing checkbox > Save.

I couldn't find documentation on how to get the above result in command line so I can easily apply that to all my lambdas instead of going to the individual ones in the console.


Solution

  • You can use the following flag via create-function or update-function-configuration.

    --tracing-config '{ "Mode": "Active" }'
    

    From the man page:

    --tracing-config (structure)
    
    Shorthand Syntax:
    
       Mode=string
    
    JSON Syntax:
    
       {
         "Mode": "Active"|"PassThrough"
       }
    

    All flags for a given command can be found using

    aws <service> <command> help
    

    I've opened an item with the Lambda team to include it on the X-Ray integration page found here:

    http://docs.aws.amazon.com/lambda/latest/dg/lambda-x-ray.html