Giter VIP home page Giter VIP logo

atlantis-terraform-test's Introduction

Terraform project using Atlantis

Simple terraform project that creates an array of AWS SSM parameters (because they are very fast to create) using Atlantis.

Atlantis is an application for automating Terraform via pull requests. Read more about it here.

Testing locally

You can run it locally for testing your terraform project. You will need to:

  • Generate GitHub Token
  • Install atlantis, terraform, ngrok
  • Run ngrok to get a publicly accessible hostname

ngrok

Leave it running like that and open a new window to continue:

  • Store ngrok URL in a variable:
URL=http://362f-174-91-254-230.ngrok.io
  • Create a local secret
SECRET=$(echo $RANDOM | md5sum | head -c 20; echo;)
echo $SECRET
  • Create a Github Webhook using ngrok URL/events and the secret:

webhook

Select the following individual events for the webhook: - Issue comments - Pull request reviews - Pull requests - Pushes

  • Start Atlantis
# expose provider configuration as environment variables:
# in the case of AWS:
export AWS_ACCESS_KEY_ID=...
export AWS_SECRET_ACCESS_KEY=...
export AWS_REGION=...

# expose your repo configuration
URL="http://362f-174-91-254-230.ngrok.io"
YOUR_USERNAME="felipempda"
YOUR_GIT_HOST="github.com"
YOUR_REPO="atlantis-terraform-test"
REPO_ALLOWLIST="$YOUR_GIT_HOST/$YOUR_USERNAME/$YOUR_REPO"
echo $REPO_ALLOWLIST
#ex :github.com/felipempda/atlantis-terraform-test

#run it
atlantis server \
--atlantis-url="$URL" \
--gh-user="$USERNAME" \
--gh-token="$TOKEN" \
--gh-webhook-secret="$SECRET" \
--repo-allowlist="$REPO_ALLOWLIST"

Atlantis will listen on port 4141 locally and wait for calls from your webhook:

atlantislocal

Pull Request

Now you can amuse yourself with Pull Requests. Create a new branch, change the code, create a Pull Request, etc. Example of a pull request.

Inside the PR you can type various atlantis commands that will trigger the Webhook > Ngork > Atlantis chain. For example:

You can type atlantis plan and a very nicely formatted plan will be generated:

altlantisplana

altlantisplanb

At this time you can take the time to review your plan, maybe even fix the Pull Request if things aren't as you expect.

This is a very nice feature for reviewers as well.

Once you are OK with your PR you can type atlantis apply to deploy your changes:

altlantisapply

Using in production

You can deploy it as a Kubernetes Application following several guides here.

atlantis-terraform-test's People

Contributors

felipempda avatar

Watchers

 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.