Git Product home page Git Product logo

terraform-aws-accounts-reference's Introduction

Terraform AWS Accounts Reference

Requirements

Introduction

Read the introductory post for this repository on Medium

This repo contains a simple Terraform reference configuration for managing multiple AWS accounts as part of an AWS Organization.

You can either use this Terraform to create a new AWS environment or apply it to an existing environment by importing resources (Organization, accounts, etc.) into the Terraform state.

This code isn't intended to be run as-is, but should instead serve as a reference which you can build on and adapt to your own needs. In particular, you would need to update any S3 bucket names before being able to run this code.

There are multiple parts to this Terraform, designed to be applied seperately.

Bootstrap

The Terraform in the bootstrap directory creates the required resources for running Terraform:

  • S3 bucket for storing Terraform state for the other directories
  • DynamoDB table for Terraform state locking
  • IAM group for admin users (optional)
  • IAM users for admins (optional)

The IAM group and users are optional but recommened if you're starting with a fresh account. In that case you should create an IAM group and user for yourself and run the remaining Terraform as that user.

You should apply this Terraform to your root account.

The bootstrap Terraform state is stored locally. This is fine, you'll only be running it once. After applying the Terraform you should commit this state file to source control but note that this is the only part of the Terraform which will store state locally.

Account creation

The Terraform in the accounts/-creation directory should also be applied to the root account.

This will create an AWS organization and your AWS accounts. An account will be created for each directory with the accounts directory which doesn't start with a hyphen. You can specify additional account names with the account_names variable.

After creating accounts it will create IAM permissions to allow the Admin group (created as part of the bootstrap process) to assume a role in the child accounts.

The bucket policy for the Terraform state bucket is also updated to allow the Admin role in child-accounts to write to a state file for that account.

Account specific Terraform

The accounts/-root, accounts/production, and accounts/staging directories contain account specific resources. These configurations should be applied against their respective accounts.

For the production and staging accounts an example S3 bucket is created.

For the root account there's an example of creating a Route53 hosted zone and delegating a subdomain to a child account.

terraform-aws-accounts-reference's People

Contributors

robbytaylor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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