From 61b162fb94fbdfc207cc7d33c0c7eba9288368fb Mon Sep 17 00:00:00 2001 From: Hugo Bollon Date: Thu, 24 Jun 2021 14:47:07 +0200 Subject: [PATCH] docs: update readme with multiple buckets/providers config advices --- README.md | 45 +++++++++++++++++-- config/yaml.go | 2 +- example.yml | 4 +- test/.gitignore | 3 +- test/config.yml | 2 +- .../terraform_1.0.0_bucket2.tfstate | 37 +++++++++++++++ 6 files changed, 85 insertions(+), 8 deletions(-) create mode 100644 test/data/test-bucket2/terraform_1.0.0_bucket2.tfstate diff --git a/README.md b/README.md index 52846c7e..956032ac 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ - [AWS S3 (state) + DynamoDB (lock)](#aws-s3-state--dynamodb-lock) - [Terraform Cloud](#terraform-cloud) - [Configuration](#configuration) + - [Multiple buckets/providers](#multiple-bucketsproviders) - [Available parameters](#available-parameters) - [Application Options](#application-options) - [General Provider Options](#general-provider-options) @@ -89,6 +90,9 @@ It currently supports several remote state backend providers: - [Terraform Cloud (remote)](https://www.terraform.io/docs/backends/types/remote.html) - [GitLab](https://docs.gitlab.com/ee/user/infrastructure/terraform_state.html) +With the upcoming **v1.2.0** update, Terraboard will be now able to handle multiple buckets/providers configuration! 🥳 +Check *configuration* section for more details. + ### Overview The overview presents all the state files in the S3 bucket, by most recent @@ -142,12 +146,47 @@ Data resiliency is not paramount though as this dataset can be rebuilt upon your Terraboard currently supports configuration in three different ways: -1. Environment variables -2. CLI parameters -3. Configuration file (YAML). A configuration file example can be found in the root directory of this repository. +1. Environment variables **(only usable for mono provider configuration)** +2. CLI parameters **(only usable for mono provider configuration)** +3. Configuration file (YAML). A configuration file example can be found in the root directory of this repository and in the `test/` subdirectory. + +**Important: all flags/environment variables related to the providers settings aren't compatible with multi-provider configuration! For that, you must use the Yaml config file to be able to configure multiples buckets/providers.** The precedence of configurations is as described below. +### Multiple buckets/providers + +In order to be able to link to Terraboard multiples buckets or even providers, you must use the Yaml configuration method. + +- Set the environment variable **CONFIG_FILE** or the flag **-c** / **--config-file** to a valid Yaml config file. + +- In the Yaml file, specify your desired providers configuration. For example with two S3 buckets: + +```yaml +aws: + - endpoint: http://minio:9000/ + region: eu-west-1 + s3: + bucket: test-bucket + force-path-style: true + file-extension: + - .tfstate + + - endpoint: http://minio:9000/ + region: eu-west-1 + s3: + bucket: test-bucket2 + force-path-style: true + file-extension: + - .tfstate + +``` + +In the case of AWS, don't forget to set **AWS_ACCESS_KEY_ID** and **AWS_SECRET_ACCESS_KEY** environment variables. + +That's it! Terraboard will now fetch these two buckets on DB refresh. You can also mix providers like AWS and Gitlab or anything else. +You can find a ready-to-use docker example with two *MinIO* buckets in the `test/` sub-folder (just swipe the two terraboard services in the docker-compose file). + ### Available parameters #### Application Options diff --git a/config/yaml.go b/config/yaml.go index f5e8cc3a..8e6f453f 100644 --- a/config/yaml.go +++ b/config/yaml.go @@ -21,7 +21,7 @@ func (s *S3BucketConfig) UnmarshalYAML(unmarshal func(interface{}) error) error func (s *GitlabConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { type rawGitlabConfig GitlabConfig - raw := GitlabConfig{ + raw := rawGitlabConfig{ Address: "https://gitlab.com", } if err := unmarshal(&raw); err != nil { diff --git a/example.yml b/example.yml index 75bbca38..d7d7d5fb 100644 --- a/example.yml +++ b/example.yml @@ -12,8 +12,8 @@ database: sync-interval: 5 provider: - no-locks: "true" - no-versioning: "false" + no-locks: true + no-versioning: false aws: dynamodb-table: terraboard diff --git a/test/.gitignore b/test/.gitignore index 24b61d13..acb9efef 100755 --- a/test/.gitignore +++ b/test/.gitignore @@ -1,2 +1,3 @@ data/* -!data/test-bucket \ No newline at end of file +!data/test-bucket +!data/test-bucket2 \ No newline at end of file diff --git a/test/config.yml b/test/config.yml index 0c4656de..5999c435 100644 --- a/test/config.yml +++ b/test/config.yml @@ -20,7 +20,7 @@ aws: - endpoint: http://minio:9000/ region: eu-west-1 s3: - bucket: test + bucket: test-bucket2 force-path-style: true file-extension: - .tfstate diff --git a/test/data/test-bucket2/terraform_1.0.0_bucket2.tfstate b/test/data/test-bucket2/terraform_1.0.0_bucket2.tfstate new file mode 100644 index 00000000..a3835bd3 --- /dev/null +++ b/test/data/test-bucket2/terraform_1.0.0_bucket2.tfstate @@ -0,0 +1,37 @@ +{ + "version": 4, + "terraform_version": "1.0.0", + "serial": 3, + "lineage": "b7d2aa5a-812a-2d1f-e5e6-835215928e00", + "outputs": { + "content": { + "value": "foo!", + "type": "string" + } + }, + "resources": [ + { + "mode": "managed", + "type": "local_file", + "name": "foo", + "provider": "provider[\"registry.terraform.io/hashicorp/local\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "content": "foo!", + "content_base64": null, + "directory_permission": "0777", + "file_permission": "0777", + "filename": "./foo.bar", + "id": "4bf3e335199107182c6f7638efaad377acc7f452", + "sensitive_content": null, + "source": null + }, + "sensitive_attributes": [], + "private": "bnVsbA==" + } + ] + } + ] +}