Skip to content

Commit

Permalink
Improvements and new features (#40)
Browse files Browse the repository at this point in the history
* Updates

* Updates

* Auto Format

Co-authored-by: cloudpossebot <11232728+cloudpossebot@users.noreply.github.com>
  • Loading branch information
aknysh and cloudpossebot authored Oct 31, 2021
1 parent 0900bb4 commit 46de8a0
Show file tree
Hide file tree
Showing 22 changed files with 59 additions and 21 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,13 +346,13 @@ Available targets:
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.0 |
| <a name="requirement_external"></a> [external](#requirement\_external) | >= 2.0 |
| <a name="requirement_local"></a> [local](#requirement\_local) | >= 1.3 |
| <a name="requirement_utils"></a> [utils](#requirement\_utils) | >= 0.16.0 |
| <a name="requirement_utils"></a> [utils](#requirement\_utils) | >= 0.17.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_utils"></a> [utils](#provider\_utils) | >= 0.16.0 |
| <a name="provider_utils"></a> [utils](#provider\_utils) | >= 0.17.0 |

## Modules

Expand Down
4 changes: 2 additions & 2 deletions docs/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.0 |
| <a name="requirement_external"></a> [external](#requirement\_external) | >= 2.0 |
| <a name="requirement_local"></a> [local](#requirement\_local) | >= 1.3 |
| <a name="requirement_utils"></a> [utils](#requirement\_utils) | >= 0.16.0 |
| <a name="requirement_utils"></a> [utils](#requirement\_utils) | >= 0.17.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_utils"></a> [utils](#provider\_utils) | >= 0.16.0 |
| <a name="provider_utils"></a> [utils](#provider\_utils) | >= 0.17.0 |

## Modules

Expand Down
2 changes: 1 addition & 1 deletion examples/complete/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ terraform {
}
utils = {
source = "cloudposse/utils"
version = ">= 0.16.0"
version = ">= 0.17.0"
}
}
}
2 changes: 2 additions & 0 deletions examples/remote-state/atmos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ components:
apply_auto_approve: false
# Can also be set using `ATMOS_COMPONENTS_TERRAFORM_DEPLOY_RUN_INIT` ENV var, or `--deploy-run-init` command-line argument
deploy_run_init: true
# Can also be set using `ATMOS_COMPONENTS_TERRAFORM_AUTO_GENERATE_BACKEND_FILE` ENV var, or `--auto-generate-backend-file` command-line argument
auto_generate_backend_file: false
helmfile:
# Can also be set using `ATMOS_COMPONENTS_HELMFILE_BASE_PATH` ENV var, or `--helmfile-dir` command-line argument
# Supports both absolute and relative paths
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ components:
component: "test/test-component"
# Other variables can be overridden here
vars: { }
# Override backend for this component
backend_type: static # s3, remote, vault, static, etc.
backend:
static:
Expand All @@ -24,3 +25,12 @@ components:
val3: true
val4: ""
val5: null
# Override remote state backend for this component
remote_state_backend_type: static # s3, remote, vault, static, etc.
remote_state_backend:
static:
val1: 1
val2: "2"
val3: true
val4: ""
val5: 5
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ components:
backend:
s3:
workspace_key_prefix: test-test-component
remote_state_backend:
s3:
workspace_key_prefix: test-test-component
settings:
spacelift:
workspace_enabled: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ components:
backend:
s3:
workspace_key_prefix: top-level-component1
remote_state_backend:
s3:
workspace_key_prefix: top-level-component1
settings:
spacelift:
workspace_enabled: true
Expand Down
3 changes: 3 additions & 0 deletions examples/remote-state/stacks/catalog/terraform/vpc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ components:
backend:
s3:
workspace_key_prefix: infra-vpc
remote_state_backend:
s3:
workspace_key_prefix: infra-vpc
settings:
spacelift:
workspace_enabled: true
Expand Down
12 changes: 12 additions & 0 deletions examples/remote-state/stacks/globals/globals.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ vars:

terraform:
vars: {}

backend_type: s3 # s3, remote, vault, etc.
backend:
s3:
Expand All @@ -16,6 +17,17 @@ terraform:
remote:
vault:

remote_state_backend_type: s3 # s3, remote, vault, static, etc.
remote_state_backend:
s3:
encrypt: true
bucket: "eg-ue2-root-tfstate"
key: "terraform.tfstate"
dynamodb_table: "eg-ue2-root-tfstate-lock"
profile: "eg-gbl-root-terraform"
acl: "bucket-owner-full-control"
region: "us-east-2"

helmfile:
vars: {}

Expand Down
2 changes: 1 addition & 1 deletion examples/remote-state/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ terraform {
}
utils = {
source = "cloudposse/utils"
version = ">= 0.16.0"
version = ">= 0.17.0"
}
}
}
2 changes: 1 addition & 1 deletion examples/spacelift/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ terraform {
}
utils = {
source = "cloudposse/utils"
version = ">= 0.16.0"
version = ">= 0.17.0"
}
}
}
2 changes: 1 addition & 1 deletion examples/stack/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ terraform {
}
utils = {
source = "cloudposse/utils"
version = ">= 0.16.0"
version = ">= 0.17.0"
}
}
}
2 changes: 1 addition & 1 deletion examples/stacks/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ terraform {
}
utils = {
source = "cloudposse/utils"
version = ">= 0.16.0"
version = ">= 0.17.0"
}
}
}
2 changes: 1 addition & 1 deletion modules/backend/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ terraform {
}
utils = {
source = "cloudposse/utils"
version = ">= 0.16.0"
version = ">= 0.17.0"
}
}
}
2 changes: 1 addition & 1 deletion modules/env/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ terraform {
}
utils = {
source = "cloudposse/utils"
version = ">= 0.16.0"
version = ">= 0.17.0"
}
}
}
11 changes: 8 additions & 3 deletions modules/remote-state/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ data "utils_component_config" "config" {
}

locals {
config = yamldecode(data.utils_component_config.config.output)
backend_type = local.config.backend_type
backend = local.config.backend
config = yamldecode(data.utils_component_config.config.output)

remote_state_backend_type = try(local.config.remote_state_backend_type, "")
backend_type = coalesce(local.remote_state_backend_type, local.config.backend_type)

remote_state_backend = try(local.config.remote_state_backend, null) != null ? local.config.remote_state_backend : null
backend = local.remote_state_backend != null ? local.remote_state_backend : local.config.backend

workspace = local.config.workspace
workspace_key_prefix = lookup(local.backend, "workspace_key_prefix", null)

Expand Down
2 changes: 1 addition & 1 deletion modules/remote-state/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ terraform {
}
utils = {
source = "cloudposse/utils"
version = ">= 0.16.0"
version = ">= 0.17.0"
}
}
}
2 changes: 1 addition & 1 deletion modules/settings/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ terraform {
}
utils = {
source = "cloudposse/utils"
version = ">= 0.16.0"
version = ">= 0.17.0"
}
}
}
2 changes: 1 addition & 1 deletion modules/spacelift/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ terraform {
}
utils = {
source = "cloudposse/utils"
version = ">= 0.16.0"
version = ">= 0.17.0"
}
}
}
2 changes: 1 addition & 1 deletion modules/vars/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ terraform {
}
utils = {
source = "cloudposse/utils"
version = ">= 0.16.0"
version = ">= 0.17.0"
}
}
}
4 changes: 2 additions & 2 deletions test/src/examples_remote_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestExamplesRemoteState(t *testing.T) {
assert.Equal(t, "2", remoteStateUsingStack["val2"])
assert.Equal(t, true, remoteStateUsingStack["val3"])
assert.Equal(t, "", remoteStateUsingStack["val4"])
assert.Equal(t, nil, remoteStateUsingStack["val5"])
assert.Equal(t, float64(5), remoteStateUsingStack["val5"])

terraform.OutputStruct(t, terraformOptions, "remote_state_using_context", &output)
remoteStateUsingContext := output.(map[string]interface{})
Expand All @@ -47,5 +47,5 @@ func TestExamplesRemoteState(t *testing.T) {
assert.Equal(t, "2", remoteStateUsingContext["val2"])
assert.Equal(t, true, remoteStateUsingContext["val3"])
assert.Equal(t, "", remoteStateUsingContext["val4"])
assert.Equal(t, nil, remoteStateUsingContext["val5"])
assert.Equal(t, float64(5), remoteStateUsingContext["val5"])
}
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ terraform {
}
utils = {
source = "cloudposse/utils"
version = ">= 0.16.0"
version = ">= 0.17.0"
}
}
}

0 comments on commit 46de8a0

Please sign in to comment.