---
meta:
    description:
        AWS Lambda microservice

    parameters:
        has_dlq:
            description:
                Does the microservice Lambda have an associated dead letter queue?
            value:
                yes

        dlq_arn:
            description:
                The ARN of the dead letter queue.
            value:

        iam_actions:
            description:
                Additional IAM actions that the Lambdas will be allowed to perform
            value: []   # A list of dicts like {action: x, resource: y}

        dynamodb_capacity:
            description:
                The read and write capacity for the Lambda state table(s).
            value:
                read: 5
                write: 5

        rest_api_id:
            description:
                The ID of the REST API that will hold this microservice.
            value:

        parent_resource_id:
            description:
                The resource ID of the parent of all resources in this microservice.
            value:

        variables:
            description:
                The environment variables that will be injected in all the AWS
                Lambdas that back the API resources.
            value: {}

        memory_size:
            description:
                The memory size for the Lambda, in MB.
            value: 128

        runtime:
            description: The Python runtime
            value: python3.6

        timeout:
            description: The timeout for the Lambda, in seconds.
            value: 300

        lambda_environment:
            description:
                Deprecated. Use 'variables' instead.
            value: {}

        input_delivery_stream:
            value:
            description: Firehose delivery stream for service requests

        output_delivery_stream:
            description: Firehose delivery stream for service responses
            value:

        api_resources:
            priority: 100
            value:
                {% for resource in resources %}
                -
                  {% if resource.path %}
                  path: {{resource.path}}
                  {% endif %}
                  {% if resource.variables or resource.lambda_environment %}
                  lambda_environment: {{resource.variables or resource.lambda_environment}}
                  {% endif %}
                  lambda_function:
                    $lambda:
                        path: lambda_function
                        dependencies:
                            {% if lambda_dependencies %}
                            {% for dep in lambda_dependencies %}
                            - {{dep}}
                            {% endfor %}
                            {% endif %}
                            {% if resource.lambda_dependencies %}
                            {% for dep in resource.lambda_dependencies %}
                            - {{dep}}
                            {% endfor %}
                            {% endif %}
                        handler: {{resource.handler}}
                {% endfor %}
