webhook2lambda2sqs.config module

class webhook2lambda2sqs.config.Config(path)[source]

Bases: object

_allowed_methods = ['POST', 'GET']
_example = {'terraform_remote_state': {'config': {'option_name': 'option_value'}, 'backend': 'backend_name'}, 'api_gateway_method_settings': {'throttlingRateLimit': None, 'metricsEnabled': False, 'throttlingBurstLimit': None, 'dataTraceEnabled': False, 'loggingLevel': 'OFF'}, 'name_suffix': 'something', 'deployment_stage_name': 'something', 'endpoints': {'other_resource_path': {'queues': ['queueName2', 'queueName3'], 'method': 'GET'}, 'some_resource_path': {'queues': ['queueName1', 'queueName2'], 'method': 'POST'}}, 'logging_level': 'INFO'}
_example_docs = '\n Configuration description:\n\n api_gateway_method_settings - (optional) Dictionary of API Gateway Method\n settings to enable. See\n <https://docs.aws.amazon.com/apigateway/api-reference/resource/stage/#methodSettings>\n for upstream documentation. Due to a limitation\n in Terraform (https://github.com/hashicorp/terraform/issues/6612), these\n settings are applied by this program via the AWS API after Terraform has\n run; if you use this program to generate Terraform configurations and\n apply them yourself, these settings will have no effect. The following\n keys and values are supported:\n\n - \'metricsEnabled\' - (boolean, default False) whether or not to enable\n CloudWatch metrics for the API.\n - \'loggingLevel\' - (string, default "OFF") logging level to use for\n pushing API Gateway logs to CloudWatch Logs. Valid values are "OFF",\n "ERROR" or "INFO".\n - \'dataTraceEnabled\' - (boolean, default False) whether to enable data\n trace logging to CloudWatch Logs for the API Gateway.\n - \'throttlingBurstLimit\' - (integer, default None) API Gateway throttling\n burst limit - see:\n <http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-request-throttling.html?icmpid=docs_apigateway_console>\n Omit to not set this option.\n - \'throttlingRateLimit\' - (double, default None) API Gateway throttling\n rate limit (requests per second). See:\n http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-request-throttling.html?icmpid=docs_apigateway_console\n Omit to not set this option.\n\n deployment_stage_name - (optional) String used as the name for the API\n Gateway Deployment Stage, which will be the beginning component of the\n URL path for the API Gateway\n (i.e. https://<api id>.execute-api.us-east-1.amazonaws.com/STAGE_NAME/).\n Defaults to "webhook2lambda2sqs".\n\n endpoints - dict describing each webhook endpoint to setup in API Gateway.\n - key is the API Gateway resource name (final component of the URL)\n - value is a dict with the following keys:\n - \'method\' - HTTP method for API Gateway resource\n - \'queues\' - list of SQS queue names to push request content to\n\n logging_level - the Python logging level (constant name) to set for the\n lambda function. Defaults to INFO. Currently the function only logs at\n ERROR and DEBUG levels.\n\n name_suffix - (optional) by default, all AWS resources will be named\n "webhook2lambda2sqs"; specify a suffix to add to that name here.\n\n terraform_remote_state - (optional) dict of Terraform remote state options.\n If specified, will call \'terraform remote config\' before every terraform\n command to setup remote state storage. See:\n https://www.terraform.io/docs/state/remote/index.html\n\n Dict keys:\n - \'backend\' - name of the terraform remote state backend to configure\n - \'config\' - dict of backend configuration option name/value pairs\n '

Load configuration from JSON

Parameters:path (str) – path to the JSON config file
Returns:config dictionary
Return type:dict

Validate configuration file. :raises: RuntimeError

static example_config()[source]

Return a 2-tuple of example configuration file as a pretty-printed JSON string and documentation about it as a string.

Return type:tuple
Returns:2-tuple of (example config file as pretty-printed JSON string, documentation about it (str))

Return what we will name our lambda function.

Returns:lambda function name
Return type:str

Get the value of the specified configuration key. Return None if the key does not exist in the configuration.

Parameters:key (str) – name of config key
Returns:configuration value at specified key
Return type:object

Return the string name of the logging module level constant to set in the lambda function.

Returns:logging level constant name
Return type:str

Return the string to use for our API Gateway Deployment Stage name.

Returns:API Gateway Deployment Stage name
Return type:str
exception webhook2lambda2sqs.config.InvalidConfigError(message)[source]

Bases: exceptions.Exception

Raised for configuration errors