0
0
mirror of https://github.com/thegeeklab/wp-opentofu.git synced 2024-06-02 18:39:41 +02:00

Merge pull request #43 from jmccann/multi_backend_config

Multiple backend-config options
This commit is contained in:
Jacob McCann 2017-05-12 11:05:28 -05:00 committed by GitHub
commit 48763d4874
2 changed files with 34 additions and 31 deletions

55
DOCS.md
View File

@ -54,19 +54,20 @@ pipeline:
+ sensitive: true
```
Example configuration with state tracked via remote:
Example configuration with state tracked via remote. You will need a
[backend configuration](https://www.terraform.io/docs/backends/config.html)
specified in a `.tf` file. You can then pass additional options via the `.drone.yml`.
```diff
pipeline:
terraform:
image: jmccann/drone-terraform:1
plan: false
+ remote:
+ backend: S3
+ config:
+ bucket: my-terraform-config-bucket
+ key: tf-states/my-project
+ region: us-east-1
+ init_options:
+ backend-config:
+ - "bucket=my-terraform-config-bucket"
+ - "key=tf-states/my-project"
+ - "region=us-east-1"
```
You may want to run terraform against internal resources, like an internal
@ -145,12 +146,11 @@ pipeline:
dev_terraform:
image: jmccann/drone-terraform:1
plan: false
remote:
backend: S3
config:
bucket: my-terraform-config-bucket
key: tf-states/my-project
region: us-east-1
init_options:
backend_config:
- "bucket=my-terraform-config-bucket"
- "key=tf-states/my-project"
- "region=us-east-1"
+ secrets:
+ AWS_ACCESS_KEY_ID: DEV_AWS_ACCESS_KEY_ID
+ AWS_SECRET_ACCESS_KEY: DEV_AWS_SECRET_ACCESS_KEY
@ -158,12 +158,11 @@ pipeline:
prod_terraform:
image: jmccann/drone-terraform:1
plan: false
remote:
backend: S3
config:
bucket: my-terraform-config-bucket
key: tf-states/my-project
region: us-east-1
init_options:
backend_config:
- "bucket=my-terraform-config-bucket"
- "key=tf-states/my-project"
- "region=us-east-1"
+ secrets:
+ AWS_ACCESS_KEY_ID: PROD_AWS_ACCESS_KEY_ID
+ AWS_SECRET_ACCESS_KEY: PROD_AWS_SECRET_ACCESS_KEY
@ -174,15 +173,19 @@ pipeline:
plan
: if true, calculates a plan but does __NOT__ apply it.
remote
: contains the configuration for the Terraform remote state tracking.
init_options
: contains the configuration for the Terraform backend.
remote.backend
: the Terraform remote state backend to use.
init_options.backend-config
: This specifies additional configuration to merge for the backend. This can be
specified multiple times. Flags specified later in the line override those
specified earlier if they conflict.
remote.config
: a map of configuration parameters for the remote state backend.
Each value is passed as a `-backend-config=<key>=<value>` option.
init_options.lock
: Lock the state file when locking is supported.
init_options.lock-timeout
: Duration to retry a state lock.
vars
: a map of variables to pass to the Terraform `plan` and `apply` commands.

View File

@ -31,9 +31,9 @@ type (
}
InitOptions struct {
BackendConfig string `json:"backend-config"`
Lock *bool `json:"lock"`
LockTimeout string `json:"lock-timeout"`
BackendConfig []string `json:"backend-config"`
Lock *bool `json:"lock"`
LockTimeout string `json:"lock-timeout"`
}
Plugin struct {
@ -122,8 +122,8 @@ func initCommand(config InitOptions) *exec.Cmd {
"init",
}
if config.BackendConfig != "" {
args = append(args, fmt.Sprintf("-backend-config=%s", config.BackendConfig))
for _, v := range config.BackendConfig {
args = append(args, fmt.Sprintf("-backend-config=%s", v))
}
// True is default in TF