GithubHelp home page GithubHelp logo

umairdojki / appsync-terraform-go-example Goto Github PK

View Code? Open in Web Editor NEW

This project forked from liamross/appsync-terraform-go-example

0.0 0.0 0.0 9 KB

An example Terraform configuration to launch an AppSync service with a Go Lambda data source

HCL 84.31% Makefile 8.71% Go 6.98%

appsync-terraform-go-example's Introduction

AppSync Terraform Go example

An example Terraform configuration to launch an AWS AppSync service with a Go Lambda data source.

This repo is the complete code example from a blog post I wrote called Easy AWS AppSync with Terraform.

Note: the Makefile may only run on macOS/linux, if you are on Windows you may need to build the Go lambda function another way.

About the contents of this repo:

  • Lambda functions are in the /functions directory
  • Apache Velocity resolver templates are inside the /resolvers directory
  • The GraphQL schema is in schema.graphql
  • All Terraform config is within the following 3 files:
    • variables.tf has variables used throughout the rest of the config
    • iam.tf contains AWS IAM roles and policies
    • main.tf contains the code for generating all other required services

Before publishing:

  1. Download Terraform
  2. Have an existing local AWS credentials profile (this is required so Terraform has the permissions to publish your AWS service)
  3. Have Go installed (required to run commands to build the Go lambda function)
  4. Open variables.tf and set them to whatever you want

Note: if you want your state to persist, remove the line from .gitignore that says *.tfstate. This state is essential to keep track of your AWS resources in order to successfully update or destroy them.

To publish:

Warning: this will fall within the free tier for AWS, however if you have had your account for longer than 1 year you may be charged a small amount for executing AppSync queries since the free tier for AppSync is only 12 months. If you still want to deploy it, the cost should be minimal (cents, not dollars).

  1. Run terraform init to initialize terraform and fetch all the resources
  2. Run make build to build the Go lambda function binary
  3. Run terraform plan to view the diff and all the created resources
  4. Run terraform apply to publish (it will prompt you to type "yes" to confirm)

Once this is done you can view your AppSync console and run queries to test that the Lambda data source is working!

To destroy

  1. Run terraform destroy to remove all AWS services (it will prompt for "yes" again)

appsync-terraform-go-example's People

Contributors

liamross 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.