Skip to content

Commit

Permalink
docs: update readme with multiple buckets/providers config advices
Browse files Browse the repository at this point in the history
  • Loading branch information
hbollon committed Jun 24, 2021
1 parent 68e8291 commit 61b162f
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 8 deletions.
45 changes: 42 additions & 3 deletions README.md
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion config/yaml.go
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions example.yml
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion test/.gitignore
@@ -1,2 +1,3 @@
data/*
!data/test-bucket
!data/test-bucket
!data/test-bucket2
2 changes: 1 addition & 1 deletion test/config.yml
Expand Up @@ -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
37 changes: 37 additions & 0 deletions 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=="
}
]
}
]
}

0 comments on commit 61b162f

Please sign in to comment.