Code Monkey home page Code Monkey logo

terraform-serverless's Introduction

Adventures in Serverless Framework & Terraform Pt 1.

Exercise in building out a simple architecture in Serverless & Terraform

Architecture

  • Private API Gateway
  • Lambdas
  • EventBridge
    • Scheduled
    • Pattern Based Rule
  • X-Ray tracing
  • SQS Dead letter Queue
  • VPC with Private Subnets only
  • VPC endpoints to support API Gateway, EventBridge, SSM
  • IAM,Security groups,etc to support the design

Results

  • To pass variables between Terraform and Serverless you can use the Systems Manager Parameter store, by defining your output in a tf variable
resource "aws_ssm_parameter" "subnets2" {
  name        = "/serverless/subnets2"
  description = "Subnet2 for serverless"
  type        = "String"
  value       =  module.vpc.private_subnets[1]
}

then using the saved parameter in serverless.yml as follows

  vpc:
    subnetIds: 
      - ${ssm:/serverless/subnets1}
  • All of the architecture building blocks and interactions were acheivable using both frameworks with the exception of applying the DLQ to the Lambdas, which was'nt possible in version 2.3 due to a race condition. Can probably find another was of doing this or replace with the new Lambda Desinations capability
  • X-Ray results where somewhat unexpected as the tracing did not show end to end traces through the eventbridge, could be additional instrumentation required.

X-Ray

Getting Started

Both Terraform and Serverless need configuring for AWS

Serverless needs the serverless-python-requirements plugin installed npm install --save serverless-python-requirements for packaging

Prerequisites

  • Terraform .014
  • Serverless Framework 2.3
  • Python 3.8

Installing

Deployment

Build out the terraform first

Terraform

terraform init
terraform plan
terraform apply

Serverless

serverless deploy

References

terraform-serverless's People

Contributors

barbaroja2000 avatar

Watchers

James Cloos 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.