Coder Social home page Coder Social logo

ansible-role-cfn-lambda's Introduction

ansible-role-cfn-lambda

Role Parameters

Variable Required Default Description
lambda_function_name yes The name to use with the lambda function.
lambda_description yes A brief description of the lambda function.
lambda_region yes Region to deploy the lambda function into.
lambda_stack_name yes Name of the CloudFormation stack.
lambda_runtime yes Runtime for the lambda function. Only python runtimes are currently supported.
lambda_role_policies yes List of policies to apply to the lambda execution role.
lambda_tags yes List of tags to apply to the CloudFormation stack
lambda_create_bundle conditional If the lambda function has external dependencies, yes instructs role to package them in a virtual environment. Required if lambda_source_code and lambda_source_code_file are not defined.
lambda_handler_name conditional Name of the handler for the lambda function to use (i.e. lambda_function.handler, assuming python file is named lambda_function.py). If lambda_create_bundle is defined then a handler name is required.
lambda_source_code conditional Inline source code for lambda function. Required if lambda_source_code_file and lambda_create_bundle are not defined.
lambda_source_code_file conditional File containing the source code to use with the lambda function. Required if lambda_source_code and lambda_create_bundle are not defined.
lambda_code_s3_bucket conditional If deploying a packaged bundle to s3, use the this bucket. Required if creating bundle.
lambda_code_zipfile conditional Name of the zip file to build / upload. Required if creating bundle.
lambda_code_s3_key no lambda_code_zipfile S3 key for bundled zipfile. Used for creating a bundle.
lambda_build_dir no "build" Name of directory to place build related files.
lambda_template_dir no lambda_build_dir Name of directory to place rendered templates.
lambda_virtualenv_dir no "venv" Name of virtual environment into which to build function package.
lambda_security_token no If a security token is used for the deployment, define it here.
lamdda_code_s3_object_version no Version of s3 object for lambda function bundle to use.
lambda_iam_role_arn yes ARN of the role to use with the lambda function.
lambda_dependencies no If deploying a packaged bundle to s3, list of files that need to be included in the bundle
lambda_requirements_file no Name of pip requirements file
lambda_test_code no Yes specifies that a testing script should be run
lambda_testing_script conditional A script to test the lambda function prior to deployment (i.e. python-lambda-local). If lambda_test_code is set to yes this must be defined.
lambda_cloudwatch_rules no A list of CloudWatch Event Rules to execute the lambda.

lambda_role_policies Fields

Variable Required Default Description
name yes Name of the execution role policy.
actions yes Actions granted / denied to the execution role.
resource yes Resource to grant access to.
effect yes Whether to Allow or Deny access to the role.

lambda_cloudwatch_rules Fields

Variable Required Default Description
name yes A basic name for the rule.
description yes A description for the rule.
schedule yes Schedule to use with the rule.
state no ENABLED State of the rule.

Example Playbooks

Source Code in File

- hosts: localhost
  vars:
    lambda_security_token: "{{ lookup('env','AWS_SESSION_TOKEN') }}"
    lambda_function_name: "{{ lambda_stack_name }}"
    lambda_description: "test-lambda"
    lambda_region: us-west-2
    lambda_stack_name: lambda-role-file-test
    lambda_runtime: "python2.7"
    lambda_source_code_file_contents: "{{ lookup('file', lambda_source_code_file) }}"
    lambda_role_policies:
      - name: test-policy
        actions:
          - "es:*"
        effect: "Allow"
        resource: "*"
    lambda_source_code_file: "test_function.py"
    lambda_tags:
      test: "test"
  roles:
    - lambda

Inline Source Code

- hosts: localhost
  gather_facts: False
  vars:
    lambda_security_token: "{{ lookup('env','AWS_SESSION_TOKEN') }}"
    lambda_function_name: "{{ lambda_stack_name }}"
    lambda_description: "test-lambda"
    lambda_region: us-west-2
    lambda_stack_name: lambda-role-inline-test
    lambda_runtime: "python2.7"
    lambda_role_policies:
      - name: test-policy
        actions:
          - "es:*"
        effect: "Allow"
        resource: "*"
    lambda_source_code:
      - "def handler(event, context):"
      - " print(\"Hello World!\")"
    lambda_tags:
      test: "test"
    lambda_cloudwatch_rules:
      - name: "BasicRule"
        description: "BasicRule"
        schedule: "rate(10 minutes)"
        state: "ENABLED"
  roles:
    - lambda

S3 Bundle

- hosts: localhost
  gather_facts: False
  vars:
    lambda_create_bundle: "yes"
    lambda_virtualenv_dir: "testing"
    lambda_security_token: "{{ lookup('env','AWS_SESSION_TOKEN') }}"
    lambda_function_name: "{{ lambda_stack_name }}"
    lambda_description: "test-lambda-bundle"
    lambda_code_s3_bucket: "role-testing-bucket"
    lambda_code_zipfile: "test.zip"
    lambda_code_s3_object_version: "QDScRvyhIEdFM0i.AZLF8OANt.U6_vGy"
    lambda_region: us-west-2
    lambda_role_path: "/test/"
    lambda_requirements:
      - "{{ lambda_requirements_file }}"
    lambda_stack_name: lambda-role-bundle-test
    lambda_runtime: "python2.7"
    lambda_requirements_file: "test_requirements.pip"
    lambda_role_policies:
      - name: test-policy
        actions:
          - "es:*"
        effect: "Allow"
        resource: "*"
    lambda_tags:
      test: "test"
  roles:
    - lambda

ansible-role-cfn-lambda's People

Contributors

notyost avatar sapiensantiquus avatar simplyadrian avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.