GithubHelp home page GithubHelp logo

apadigal / openapi-tf-example Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rpstreef/openapi-tf-example

0.0 0.0 0.0 184 KB

Example of how you can use OpenAPI with AWS API Gateway, Also includes integrations with AWSLambda, AWS Cognito, AWS SNS and CloudWatch logs

Home Page: https://dev.to/rolfstreefkerk/openapi-with-terraform-on-aws-api-gateway-17je

License: Apache License 2.0

JavaScript 15.33% HCL 84.67%

openapi-tf-example's Introduction

OpenAPI with AWS API Gateway, Lambda, Cognito, SNS and CloudWatch logs

This repo only deploys the infrastructure via Terraform. The source code, this repo, will be deployed automatically via AWS CodePipeline. By default, it's configured to automatically deploy at every push to the master branch.

Check the companion articles series 'OpenAPI' on dev.to.

Get started

The essentials

  • Download Terraform v0.12.x here
  • You will need Node v12.x from here
  • Git, to clone this Repo, from here
  • Create a free AWS account (requires credit card) here
  • Finally, download the AWS CLI tool
  • Setup your AWS local profile, see this guide how it's done.
  • Manually setup an AWS S3 Bucket for Terraform state storage.

To get the API running

If you meet all the pre-requisites, do the following

  • In your AWS development account create the S3 bucket for your Terraform state files.
    • Optionally, encrypt the S3 bucket and enable versioning such that you can do a rollback.
  • git clone this repo.
  • Change your AWS credentials profile name in these files:
    • ./env/dev/remote-backend.tf
    • ./env/dev/dev.tfvars
  • Run npm install and then execute npm run dev-init, this will:
    • Initialize the Terraform project for the 'dev' environment, and synchronize the state with the cloud stored .tfstate file.
    • If you run it a second time, it will fail on the workspace creation, this is not an issue (the workspace already exists)
  • Run npm run dev-infra to prepare the deployment to your AWS account.
    • Note: this repo contains the node source code that the CodePipeline will deploy to the AWS Lambda and Lambda-layer.
    • Confirm with yes to deploy, anything else will cancel the deployment

See my full guide on dev.to for more information about this project

ps. I'm aware the gulp file doesn't exit nicely, i'm not an expert. Any pull requests or issue reports with pointers is definitely appreciated.

VS Code plugins used

Running costs

There are no costs associated with deploying any of this on AWS, there is Free Tier coverage for limited free use.

The following services are deployed with Terraform;

  • AWS Cognito
  • AWS API Gateway
  • AWS Lambda & Lambda Layer
  • AWS IAM
  • (Added) CloudWatch Alarms, costs will be incurred for enabling Detailed Monitoring for API Gateway (!)
  • (Added) AWS CodePipeline, and CodeBuild with Github as source repository. There's a free tier for:

openapi-tf-example's People

Contributors

dependabot[bot] avatar rpstreef 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.