Code Monkey home page Code Monkey logo

united's Introduction

United: A multitenant Terraform HTTP backend server

Designed to be run alongside Atlantis, United offers a simple to configure HTTP backend with locking, encryption, and flexible pass though authentication.

You would want to use this in situations where you have many teams with many statefiles and and consistent management of them across the platform/org/agency has become a burden.

Requirements

  • S3 Bucket
  • KMS Key
  • Redis
  • Something to run this server
  • Ideally a set of creds per team that can be stored separately

Server Config

Config is done though environment variables

######
# Required
######

# S3 Bucket to store into
export BUCKET="myorg-bucket-of-states"

# KMS Key Arn to use for encrypting
export KEY_ARN="arn:aws:kms:us-whoop-9:11111111111:key/dork-4242-9999-be3p-c0ffeec0ffee"

######
# Optional
######

# Port to listen on, defaults to 8080
export PORT="4242"

# Key prefix for S3.  This has security implications, see warning in code before changing this, defaults to "united"
export BUCKET_PREFIX="yas"

# Redis connection string for lock storage, defaults to redis://localhost:6379
export REDIS_CONN="redis://meept:woah@the_elasticache_cluster:6379"

# Enable passthough auth to AuthURL via POST, defaults to true
export VALIDATE_AUTH="true"

# URL to POST to, should return 200 for success.  Defaults to http://localhost:8090/api/collections/united/auth-with-password
export AUTH_URL="https://inside-api/api/united-states-postage"

Terrafrom Config

Config is done via the Terrafrom http backend. United uses the /state path and binds /state/:group/:name which you should provide.

An example is below:

terraform {
  backend "http" {
    address        = "https://united.my.org/state/my-group/this-state"
    lock_address   = "https://united.my.org/state/my-group/this-state"
    unlock_address = "https://united.my.org/state/my-group/this-state"
  }
  required_providers {
    random = {
      source = "hashicorp/random"
      version = "3.6.0"
    }
  }
}

Then run by setting the username and password via env vars:

export TF_HTTP_USERNAME="daryl"
export TF_HTTP_PASSWORD="Ih0p3Th1$w0rKz"
terraform init
terraform plan

Note that Atlantis can populate env vars via script, which is the ideal tool to either fetch creds from a secret store, or decrypt on the fly from a encrypted blob in the repo.

Runtime Notes

  • Protect s3 bucket as with anything. Data is encrypted vis AWS S3-CSE but care should still be taken to prevent leakage. Same this with the KMS key.

  • Do network isolation. This service is meant to be interfaced by terrafrom, not the entire internet. Ideally run this next to Atlantis and only allow network traffic from it.

  • Use the auth validation. This was designed to auth against the PocketBase API but the format is simple enough to write a shim in front of another source if needed. The alternative method is basically just a hackaround for testing purposes

  • Enable TlS on fronting proxies, redis, auth url, etc...

F.A.Q.

  • Why united?
    • Because it's the United States for Atlantis.

Copyright

Copyright (C) 2024 Platform OnDemand, Inc - All Rights Reserved

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.

united's People

Contributors

nathanhruby avatar renovate[bot] avatar

united's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/golang-ci.yml
  • actions/checkout v4
  • actions/setup-go v5
  • golangci/golangci-lint-action v4.0.0
.github/workflows/goreleaser.yml
  • actions/checkout v4
  • actions/setup-go v5
  • docker/login-action v3
  • goreleaser/goreleaser-action v5
.github/workflows/pr-title.yml
  • amannn/action-semantic-pull-request v5.4.0
.github/workflows/pre-commit.yml
  • actions/checkout v4
  • actions/setup-python v5
  • pre-commit/action v3.0.1
gomod
go.mod
  • go 1.22.0
  • github.com/aws/amazon-s3-encryption-client-go/v3 v3.0.0
  • github.com/aws/aws-sdk-go-v2 v1.25.3
  • github.com/aws/aws-sdk-go-v2/config v1.27.7
  • github.com/aws/aws-sdk-go-v2/service/kms v1.29.2
  • github.com/aws/aws-sdk-go-v2/service/s3 v1.51.4
  • github.com/aws/smithy-go v1.20.1
  • github.com/bsm/redislock v0.9.4
  • github.com/gin-gonic/gin v1.9.1
  • github.com/redis/go-redis/v9 v9.5.1
  • github.com/sethvargo/go-envconfig v1.0.1
terraform-version
.terraform-version
  • hashicorp/terraform 1.7.4

  • Check this box to trigger a request for Renovate to run again on this repository

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.