I am writing deployment scripts in Python using boto3 for an API Gateway. The script will create the API, resources, methods, and deployment. When I look in the AWS Management Console there is a checkbox for Enable CloudWatch Logs
Is there a way to enable this via boto3 or the REST API? I haven't seen any options in the documentation for this.
The cloudwatch log setting you are looking for is associated with a stage resource. In your case, you need to use the update_stage
method in boto3 to apply a patch operation to set the correct log level.
From the boto docs:
loggingLevel (string) --
Specifies the logging level for this method, which effects the log entries pushed to Amazon CloudWatch Logs. The PATCH path for this setting is /{method_setting_key}/logging/loglevel , and the available levels are OFF , ERROR , and INFO .
Here is the link to the update stage REST API reference.
This is available in update_stage in boto3 ( http://boto3.readthedocs.io/en/latest/reference/services/apigateway.html#APIGateway.Client.update_stage )
The patch paths are documented here https://docs.aws.amazon.com/apigateway/api-reference/link-relation/stage-update/
You can use a patch operation like below to set log level on all resources/methods
{ "patchOperations" : [
{
"op" : "replace",
"path" : "/*/*/logging/loglevel",
"value" : "INFO"
},
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.