Skip to content

Commit

Permalink
feat(remote-state): deploy state bucket + lock table to all AWS accounts
Browse files Browse the repository at this point in the history
Signed-off-by: kolvin <15124052+Kolvin@users.noreply.github.com>
  • Loading branch information
kolvin committed Jun 16, 2023
1 parent 61b092d commit e1f87ff
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .terraform-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.6
1.5.0
20 changes: 18 additions & 2 deletions common.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,22 @@ terraform {
commands = ["apply"]
arguments = ["${get_terragrunt_dir()}/tgplan.out"]
}

extra_arguments "retry_lock" {
commands = [
"init",
"apply",
"refresh",
"import",
"plan",
"taint",
"untaint"
]

arguments = [
"-lock-timeout=10m"
]
}
}

# Generate an AWS provider block
Expand Down Expand Up @@ -70,10 +86,10 @@ remote_state {

config = {
encrypt = true
bucket = "terragrunt-state-${local.aws_account_id}"
bucket = "terraform-state-${local.aws_account_id}"
key = "${join("/", compact([local.component, local.aws_region]))}/terraform.tfstate"
region = "eu-west-1" # one state bucket per account, multi region support via file path
dynamodb_table = "terragrunt-locks-${local.aws_account_id}"
dynamodb_table = "terraform-locks-${local.aws_account_id}"
}

generate = {
Expand Down
26 changes: 26 additions & 0 deletions remote-backend/kloud/global/terragrunt.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
include "root" {
path = find_in_parent_folders("common.hcl")
}

terraform {
source = "git::https://github.com/kloud-cnf/terraform-aws-remote-backend//?ref=v0.1.0"
}

inputs = {
state_config = {
state_bucket_name_suffix = "terraform-state"
lock_table_name_suffix = "terraform-state-lock"
state_bucket_allowed_roles = [
"OrgAccessRole",
"ci-role-provisioner",
"github-ci-infrastructure-provisoner"
]
state_bucket_allowed_users = [
"root"
]
enabled_org_units = [
"root/workloads",
"root/labs",
]
}
}

0 comments on commit e1f87ff

Please sign in to comment.