Skip to content

csautter/terragrunt-blueprint

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terragrunt blueprint

This repository contains a Terragrunt blueprint with a common project structure. The repo includes some example modules for AWS, Azure and STACKIT cloud. It's intended to be used as a starting point for new projects. Over the time it will be extended with more modules, features and best practices.

Features

Generic

  • local backend
  • gitlab remote backend
  • override variables in env_local.hcl file
  • helm provider
  • kubernetes provider
  • helm chart module

AWS

  • AWS provider
  • AWS dummy module

Azure

  • Azure provider
  • Azure benchmark module

StackIT

  • STACKIT cloud dummy module
  • STACKIT cloud s3 remote backend
  • STACKIT ske kubernetes module
  • STACKIT benchmark module
  • add some

Apply aws dummy

export AWS_PROFILE=aws_dummy
export AWS_ACCOUNT_ID=123456789

# required if you want to use the gitlab backend
export TF_HTTP_PASSWORD=your_gitlab_token
export TF_HTTP_USERNAME=your_gitlab_user_name

cd deployments/terraform/env/dev/aws_dummy
terragrunt apply

Apply stackit cloud dummy

configure authorization

Reference: https://registry.terraform.io/providers/stackitcloud/stackit/latest/docs#authentication

Use the recommended "key flow" authentication. You should end up with two files in your home directory:

  • ~/.stackit/credentials.json

    {
         "STACKIT_SERVICE_ACCOUNT_KEY_PATH": "/Users/<username>/.stackit/key.json"
    }

    Note: relative paths like ~/.stackit/key.json where not working for me.

  • ~/.stackit/key.json

    {
        "id": "uuid",
        "publicKey": "public key",
        "createdAt": "2023-08-24T14:15:22Z",
        "validUntil": "2023-08-24T14:15:22Z",
        "keyType": "USER_MANAGED",
        "keyOrigin": "USER_PROVIDED",
        "keyAlgorithm": "RSA_2048",
        "active": true,
        "credentials": {
            "kid": "string",
            "iss": "my-sa@sa.stackit.cloud",
            "sub": "uuid",
            "aud": "string",
            (optional) "privateKey": "private key when generated by the SA service"
        }
    }

    you can generate and download this file in the stackit cloud web console

s3 state backend

If you like to use the s3 state backend you need to set the bucket credentials as environment variables:

export AWS_ACCESS_KEY_ID=AAAAAAAAAAAAAAAAAAAA
export AWS_SECRET_ACCESS_KEY=BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB

run terragrunt

cd deployments/terraform/env/stackit_dev/stackit_dummy
terragrunt apply

# cleanup
terragrunt plan -destroy -out=destroy.tfplan
terragrunt apply destroy.tfplan

Status

This repository is a work in progress.

Contributing

Feel free to contribute by creating a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details. Do whatever you want with it.

About

Blueprint for a Terragrunt project structure

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages