Skip to content

Excoriate/terraform-registry-aws-accounts-creator

Repository files navigation

logo
Terraform AWS ☁️ Account Creator

An easy to understand, opinionated terraform composable module for AWS ☁️.


Auto Release Terraform Check Run pre-commit Terratest

Table of Contents

  1. About The Module
  2. Module documentation
    1. Capabilities
    2. Getting Started
    3. Roadmap
    4. Module standard structure
  3. Developer Experience
    1. Configuring AWS credentials for local development
    2. Running common development actions
    3. Running tests
  4. Contributions
  5. License
  6. Contact

About The Module

This module encapsulate a set of modules that configure, and provision accounts-related resources on AWS.


Module documentation

The documentation is automatically generated by terraform-docs, and it's available in the module's README.md file.

Capabilities

Module Status Description
aws-accounts Stable βœ… Create or many AWS accounts, within AWS Organizations.
aws-iam-groups Stable βœ… Create AWS IAM groups
aws-iam-system-user Stable βœ… Create an non-human user, for automation/system purposes.
aws-iam-group-permissions Stable βœ… Create IAM Group policies, and required attachments
aws-iam-users Stable βœ… Create AWS IAM (human) users
aws-iam-role Stable βœ… Create an IAM role, with complex options like attached IAM policies, and others
aws-iam-policy Stable βœ… Create an IAM policy, with complex options and allow to export its json document, or the object if applicable.
aws-iam-policy-attacher Stable βœ… Module that wraps the attachment functionality. It's intended to be used in order to attach multiple IAM policies to several IAM roles.

Module: Default

  1. Allows to create one or many AWS accounts.
  2. Allows to set organizational units for these accounts, or attach them directly into the root AWS Org.

Module: IAM Groups

  1. Allow us to create one or many IAM groups
  2. Handle specific paths, with optional attributes.

Getting Started

Check the example recipes πŸ₯— here

Roadmap

  • Add support for SCP.

Module standard structure

The module's relevant components, structure and "skeleton" is described below:

β”œβ”€β”€ README.md
β”œβ”€β”€ TaskFile.yml
β”œβ”€β”€ docs
β”‚Β Β  └── contribution_guidelines.md
β”œβ”€β”€ examples
β”‚Β Β  β”œβ”€β”€ README.md
β”‚Β Β  β”œβ”€β”€ TaskFile.yml
β”‚Β Β  └── default
β”‚Β Β      └── basic
β”‚Β Β          β”œβ”€β”€ README.md
β”‚Β Β          β”œβ”€β”€ config
β”‚Β Β          β”‚Β Β  └── fixtures.tfvars
β”‚Β Β          β”œβ”€β”€ main.tf
β”‚Β Β          β”œβ”€β”€ providers.tf
β”‚Β Β          β”œβ”€β”€ variables.tf
β”‚Β Β          └── versions.tf
β”œβ”€β”€ modules
β”‚Β Β  β”œβ”€β”€ TaskFile.yml
β”‚Β Β  └── default
β”‚Β Β      β”œβ”€β”€ README.md
β”‚Β Β      β”œβ”€β”€ data.tf
β”‚Β Β      β”œβ”€β”€ locals.tf
β”‚Β Β      β”œβ”€β”€ main.tf
β”‚Β Β      β”œβ”€β”€ outputs.tf
β”‚Β Β      β”œβ”€β”€ variables.tf
β”‚Β Β      └── versions.tf
β”œβ”€β”€ pre-commit-config-githubactions.yaml
└── tests
    β”œβ”€β”€ README.md
    β”œβ”€β”€ TaskFile.yml
    └── default
        β”œβ”€β”€ integration
        β”‚Β Β  β”œβ”€β”€ default_basic_integration_test.go
        β”‚Β Β  β”œβ”€β”€ go.mod
        β”‚Β Β  β”œβ”€β”€ go.sum
        β”‚Β Β  └── target
        β”‚Β Β      └── basic
        β”‚Β Β          └── main.tf
        └── unit
            β”œβ”€β”€ default_basic_unit_test.go
            β”œβ”€β”€ go.mod
            β”œβ”€β”€ go.sum
            └── target
                └── basic
                    └── main.tf

Where:

  • ⚑️Modules: refers to the actual module's directory. Where the .tf files reside. Each subdirectory is a module.
  • ⚑️Examples: refers to the examples directory, where the examples recipes lives. These are also used for testing the infrastructure using Terratest. For its specific documentation, query this link
  • ⚑️Tests: refers to the tests directory, where the tests recipes lives. These are also used for testing the infrastructure using Terratest. For its specific documentation, query this link

Developer Experience

Some tools that this repo uses:

  • 🧰 Terraform β€” strongly recommended the latest versions
  • 🧰 Go β€” justified mostly for Terratest
  • 🧰 TaskFile β€” for the automation of the tasks.

NOTE: For automation during the development process, I use precommit, which is a framework for managing and maintaining multi-language pre-commit hooks. It's a great tool, and I highly recommend it. All the hooks required are installed by this script. It's recommended though to run it through the TaskFile task pre-commit-init.

To initialize your pre-commit configuration, and ensure all the hooks are installed, run the following command:

task pre-commit-init

To run these hooks against all the files, you can use the following Task command:

task pre-commit

Configuring AWS credentials for local development

For sure you've seen that in the main Taskfile, there's a task called gen-env-aws. That task aims to generate a proper .env.<env>.aws dotEnv file which is used by the TaskFile.yml tasks. If you have a proper AWS credentials file, you can run the following command:

task gen-env-aws

In simple terms, that tasks (which runs a shell script) scan your pre-existing AWS profiles, and generate the .env.<env>.aws file for you. When it's generated, running a task that wraps a terraform command, will use the generated .env.<env>.aws file to set the proper AWS credentials. For example:

# dev refers to the environment selected, which's how the file is also named. E.g.: env.dev.aws
ENV=dev task module-plan

Running common actions for local development

Run unit tests (wrapping Terratest):

# If you want to list the available tasks.
task list
# Run the unit tests.
task test-unit

Run integration tests β€” if exists (wrapping Terratest):

# If you want to list the available tasks.
task list
# Run the unit tests.
task test-integration

Run all the configured pre-commit hooks (forcing them to run on all files):

task pre-commit

Run a vanilla terraform plan over the example/basic (recipe) example:

# No arguments are required, since it's using its defaults: example as the module's name, and basic as its recipe's name.
task recipe-plan

Tests

See the detailed documentation here.


Module Versioning

This Module follows the principles of Semantic Versioning (SemVer).

Given a version number MAJOR.MINOR.PATCH, we increment the:

  1. MAJOR version when we make incompatible changes,
  2. MINOR version when we add functionality in a backwards compatible manner, and
  3. PATCH version when we make backwards compatible bug fixes.

Backwards compatibility in 0.0.z and 0.y.z version

  • Backwards compatibility in versions 0.0.z is not guaranteed when z is increased. (Initial development)
  • Backwards compatibility in versions 0.y.z is not guaranteed when y is increased. (Pre-release)

Contributing

Contributions are always encouraged and welcome! ❀️. For the process of accepting changes, please refer to the CONTRIBUTING.md file, and for a more detailed explanation, please refer to this guideline here.

License

license

This module is licensed under the Apache License Version 2.0, January 2004. Please see LICENSE for full details.

Contact

made/with ❀️ 🀟

About

Module that creates AWS organisations, and related accounts πŸ€–

Resources

License

Stars

Watchers

Forks

Packages

No packages published