Skip to content

Latest commit

 

History

History
60 lines (41 loc) · 2.5 KB

terracanary_apply.md

File metadata and controls

60 lines (41 loc) · 2.5 KB

terracanary apply

Apply changes to a stack

Synopsis

Initialize the selected stack and perform 'terraform apply' on it. You may specify other stacks from which to provide the location of the state files as inputs, allowing coordination between specified versions of different stacks. This works by automatically supplying the configuration for terraform_remote_state resources that reference other stacks. For instance, the terraform definition for a stack with inputs of a versioned "code" stack and an unversioned "database" stack would look like:

variable "code_stack_version" {}

variable "code_stack_state" {
  type        = "map"
}

data "terraform_remote_state" "code" {
  backend = "s3"
  config  = "${var.code_stack_state}"
}

variable "database_stack_state" {
  type        = "map"
}

data "terraform_remote_state" "database" {
  backend = "s3"
  config  = "${var.database_stack_state}"
}

Note that two input variables are provided for each input stack -- a _stack_state variable that can be passed directly to terraform_remote_state as the config, and a _stack_version variable (for versioned stacks only), that's just the integer version number for that stack. The stack version inputs are mostly useful to provide as outputs to allow interrogating the deployed state.

For versioned stacks, you may also supply an alias, which will be used as the prefix for the input variables instead of the stack name. This allows passing different versions of the same stack in with different names (e.g. "stable" and "testing" stack versions during a canary deployment).

terracanary apply (-s <stack>:<version> | -S <stack>) [<flags>...] [-- <terraform-args>...]

Examples

terracanary apply -S database
terracanary apply -s code:$CODE_VERSION
terracanary apply -s main:$MAIN_VERSION -I database -i code:$CODE_VERSION

Options

  -h, --help                              help for apply
  -I, --input-stack stringArray           Name of unversioned stack to provide state from as input; may repeat for multiple input stacks
  -i, --input-stack-version stringArray   Stack version (as <stack>:<version>[:<alias>]) to provide state from as input; may repeat for multiple input stacks
  -S, --stack string                      Name of unversioned stack to operate on
  -s, --stack-version string              Stack version to operate on as <stack>:<version>

SEE ALSO

  • terracanary - Deployment orchestration using terraform
Auto generated by spf13/cobra on 12-Apr-2018