Autoload only .auto.tfvars files
This commit is contained in:
parent
006744bfe0
commit
8d98fdecac
|
@ -296,8 +296,8 @@ Options:
|
||||||
flag can be set multiple times.
|
flag can be set multiple times.
|
||||||
|
|
||||||
-var-file=foo Set variables in the Terraform configuration from
|
-var-file=foo Set variables in the Terraform configuration from
|
||||||
a file. If "terraform.tfvars" is present, it will be
|
a file. If "terraform.tfvars" or any ".auto.tfvars"
|
||||||
automatically loaded if this flag is not specified.
|
files are present, they will be automatically loaded.
|
||||||
|
|
||||||
|
|
||||||
`
|
`
|
||||||
|
@ -345,8 +345,8 @@ Options:
|
||||||
flag can be set multiple times.
|
flag can be set multiple times.
|
||||||
|
|
||||||
-var-file=foo Set variables in the Terraform configuration from
|
-var-file=foo Set variables in the Terraform configuration from
|
||||||
a file. If "terraform.tfvars" is present, it will be
|
a file. If "terraform.tfvars" or any ".auto.tfvars"
|
||||||
automatically loaded if this flag is not specified.
|
files are present, they will be automatically loaded.
|
||||||
|
|
||||||
|
|
||||||
`
|
`
|
||||||
|
|
|
@ -146,8 +146,8 @@ Options:
|
||||||
flag can be set multiple times.
|
flag can be set multiple times.
|
||||||
|
|
||||||
-var-file=foo Set variables in the Terraform configuration from
|
-var-file=foo Set variables in the Terraform configuration from
|
||||||
a file. If "terraform.tfvars" is present, it will be
|
a file. If "terraform.tfvars" or any ".auto.tfvars"
|
||||||
automatically loaded if this flag is not specified.
|
files are present, they will be automatically loaded.
|
||||||
|
|
||||||
|
|
||||||
`
|
`
|
||||||
|
|
|
@ -243,8 +243,8 @@ Options:
|
||||||
with the "-config" flag.
|
with the "-config" flag.
|
||||||
|
|
||||||
-var-file=foo Set variables in the Terraform configuration from
|
-var-file=foo Set variables in the Terraform configuration from
|
||||||
a file. If "terraform.tfvars" is present, it will be
|
a file. If "terraform.tfvars" or any ".auto.tfvars"
|
||||||
automatically loaded if this flag is not specified.
|
files are present, they will be automatically loaded.
|
||||||
|
|
||||||
|
|
||||||
`
|
`
|
||||||
|
|
|
@ -400,8 +400,19 @@ func (m *Meta) process(args []string, vars bool) ([]string, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = nil
|
|
||||||
var preArgs []string
|
var preArgs []string
|
||||||
|
|
||||||
|
if _, err = os.Stat(DefaultVarsFilename); err == nil {
|
||||||
|
m.autoKey = "var-file-default"
|
||||||
|
preArgs = append(preArgs, "-"+m.autoKey, DefaultVarsFilename)
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err = os.Stat(DefaultVarsFilename + ".json"); err == nil {
|
||||||
|
m.autoKey = "var-file-default"
|
||||||
|
preArgs = append(preArgs, "-"+m.autoKey, DefaultVarsFilename+".json")
|
||||||
|
}
|
||||||
|
|
||||||
|
err = nil
|
||||||
for err != io.EOF {
|
for err != io.EOF {
|
||||||
var fis []os.FileInfo
|
var fis []os.FileInfo
|
||||||
fis, err = f.Readdir(128)
|
fis, err = f.Readdir(128)
|
||||||
|
@ -412,7 +423,7 @@ func (m *Meta) process(args []string, vars bool) ([]string, error) {
|
||||||
for _, fi := range fis {
|
for _, fi := range fis {
|
||||||
name := fi.Name()
|
name := fi.Name()
|
||||||
// Ignore directories, non-var-files, and ignored files
|
// Ignore directories, non-var-files, and ignored files
|
||||||
if fi.IsDir() || !isVarFile(name) || config.IsIgnoredFile(name) {
|
if fi.IsDir() || !isAutoVarFile(name) || config.IsIgnoredFile(name) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -570,8 +581,8 @@ func (m *Meta) SetWorkspace(name string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// isVarFile determines if the file ends with .tfvars or .tfvars.json
|
// isAutoVarFile determines if the file ends with .auto.tfvars or .auto.tfvars.json
|
||||||
func isVarFile(path string) bool {
|
func isAutoVarFile(path string) bool {
|
||||||
return strings.HasSuffix(path, ".tfvars") ||
|
return strings.HasSuffix(path, ".auto.tfvars") ||
|
||||||
strings.HasSuffix(path, ".tfvars.json")
|
strings.HasSuffix(path, ".auto.tfvars.json")
|
||||||
}
|
}
|
||||||
|
|
|
@ -339,17 +339,25 @@ func TestMeta_process(t *testing.T) {
|
||||||
defer os.Chdir(cwd)
|
defer os.Chdir(cwd)
|
||||||
|
|
||||||
// Create two vars files
|
// Create two vars files
|
||||||
file1 := "file1.tfvars"
|
defaultVarsfile := "terraform.tfvars"
|
||||||
err = ioutil.WriteFile(
|
err = ioutil.WriteFile(
|
||||||
filepath.Join(d, file1),
|
filepath.Join(d, defaultVarsfile),
|
||||||
[]byte(""),
|
[]byte(""),
|
||||||
0644)
|
0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
}
|
}
|
||||||
file2 := "file2.tfvars"
|
fileFirstAlphabetical := "a-file.auto.tfvars"
|
||||||
err = ioutil.WriteFile(
|
err = ioutil.WriteFile(
|
||||||
filepath.Join(d, file2),
|
filepath.Join(d, fileFirstAlphabetical),
|
||||||
|
[]byte(""),
|
||||||
|
0644)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("err: %s", err)
|
||||||
|
}
|
||||||
|
fileLastAlphabetical := "z-file.auto.tfvars"
|
||||||
|
err = ioutil.WriteFile(
|
||||||
|
filepath.Join(d, fileLastAlphabetical),
|
||||||
[]byte(""),
|
[]byte(""),
|
||||||
0644)
|
0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -366,13 +374,19 @@ func TestMeta_process(t *testing.T) {
|
||||||
if args[0] != "-var-file-default" {
|
if args[0] != "-var-file-default" {
|
||||||
t.Fatalf("expected %q, got %q", "-var-file-default", args[0])
|
t.Fatalf("expected %q, got %q", "-var-file-default", args[0])
|
||||||
}
|
}
|
||||||
if args[1] != file1 {
|
if args[1] != defaultVarsfile {
|
||||||
t.Fatalf("expected %q, got %q", file1, args[1])
|
t.Fatalf("expected %q, got %q", defaultVarsfile, args[3])
|
||||||
}
|
}
|
||||||
if args[2] != "-var-file-default" {
|
if args[2] != "-var-file-default" {
|
||||||
t.Fatalf("expected %q, got %q", "-var-file-default", args[0])
|
t.Fatalf("expected %q, got %q", "-var-file-default", args[0])
|
||||||
}
|
}
|
||||||
if args[3] != file2 {
|
if args[3] != fileFirstAlphabetical {
|
||||||
t.Fatalf("expected %q, got %q", file2, args[3])
|
t.Fatalf("expected %q, got %q", fileFirstAlphabetical, args[1])
|
||||||
|
}
|
||||||
|
if args[4] != "-var-file-default" {
|
||||||
|
t.Fatalf("expected %q, got %q", "-var-file-default", args[0])
|
||||||
|
}
|
||||||
|
if args[5] != fileLastAlphabetical {
|
||||||
|
t.Fatalf("expected %q, got %q", fileLastAlphabetical, args[3])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,8 +186,8 @@ Options:
|
||||||
flag can be set multiple times.
|
flag can be set multiple times.
|
||||||
|
|
||||||
-var-file=foo Set variables in the Terraform configuration from
|
-var-file=foo Set variables in the Terraform configuration from
|
||||||
a file. If "terraform.tfvars" is present, it will be
|
a file. If "terraform.tfvars" or any ".auto.tfvars"
|
||||||
automatically loaded if this flag is not specified.
|
files are present, they will be automatically loaded.
|
||||||
`
|
`
|
||||||
return strings.TrimSpace(helpText)
|
return strings.TrimSpace(helpText)
|
||||||
}
|
}
|
||||||
|
|
|
@ -381,8 +381,8 @@ Options:
|
||||||
flag can be set multiple times.
|
flag can be set multiple times.
|
||||||
|
|
||||||
-var-file=foo Set variables in the Terraform configuration from
|
-var-file=foo Set variables in the Terraform configuration from
|
||||||
a file. If "terraform.tfvars" is present, it will be
|
a file. If "terraform.tfvars" or any ".auto.tfvars"
|
||||||
automatically loaded if this flag is not specified.
|
files are present, they will be automatically loaded.
|
||||||
|
|
||||||
-vcs=true If true (default), push will upload only files
|
-vcs=true If true (default), push will upload only files
|
||||||
committed to your VCS, if detected.
|
committed to your VCS, if detected.
|
||||||
|
|
|
@ -133,8 +133,8 @@ Options:
|
||||||
flag can be set multiple times.
|
flag can be set multiple times.
|
||||||
|
|
||||||
-var-file=foo Set variables in the Terraform configuration from
|
-var-file=foo Set variables in the Terraform configuration from
|
||||||
a file. If "terraform.tfvars" is present, it will be
|
a file. If "terraform.tfvars" or any ".auto.tfvars"
|
||||||
automatically loaded if this flag is not specified.
|
files are present, they will be automatically loaded.
|
||||||
|
|
||||||
`
|
`
|
||||||
return strings.TrimSpace(helpText)
|
return strings.TrimSpace(helpText)
|
||||||
|
|
|
@ -27,7 +27,7 @@ __apply() {
|
||||||
'-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]' \
|
'-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]' \
|
||||||
'-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]' \
|
'-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]' \
|
||||||
'-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
|
'-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
|
||||||
'-var-file=[(path) Set variables in the Terraform configuration from a file. If "terraform.tfvars" is present, it will be automatically loaded if this flag is not specified.]'
|
'-var-file=[(path) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]'
|
||||||
}
|
}
|
||||||
|
|
||||||
__destroy() {
|
__destroy() {
|
||||||
|
@ -39,7 +39,7 @@ __destroy() {
|
||||||
'-state=[Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]' \
|
'-state=[Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]' \
|
||||||
'-state-out=[Path to write state to that is different than "-state". This can be used to preserve the old state.]' \
|
'-state-out=[Path to write state to that is different than "-state". This can be used to preserve the old state.]' \
|
||||||
'-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
|
'-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
|
||||||
'-var-file=[(path) Set variables in the Terraform configuration from a file. If "terraform.tfvars" is present, it will be automatically loaded if this flag is not specified.]'
|
'-var-file=[(path) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]'
|
||||||
}
|
}
|
||||||
|
|
||||||
__get() {
|
__get() {
|
||||||
|
@ -77,7 +77,7 @@ __plan() {
|
||||||
'-refresh=[(true) Update state prior to checking for differences.]' \
|
'-refresh=[(true) Update state prior to checking for differences.]' \
|
||||||
'-state=[(statefile) Path to a Terraform state file to use to look up Terraform-managed resources. By default it will use the state "terraform.tfstate" if it exists.]' \
|
'-state=[(statefile) Path to a Terraform state file to use to look up Terraform-managed resources. By default it will use the state "terraform.tfstate" if it exists.]' \
|
||||||
'-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
|
'-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
|
||||||
'-var-file=[(path) Set variables in the Terraform configuration from a file. If "terraform.tfvars" is present, it will be automatically loaded if this flag is not specified.]'
|
'-var-file=[(path) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]'
|
||||||
}
|
}
|
||||||
|
|
||||||
__push() {
|
__push() {
|
||||||
|
@ -93,7 +93,7 @@ __refresh() {
|
||||||
'-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]' \
|
'-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]' \
|
||||||
'-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]' \
|
'-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]' \
|
||||||
'-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
|
'-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
|
||||||
'-var-file=[(path) Set variables in the Terraform configuration from a file. If "terraform.tfvars" is present, it will be automatically loaded if this flag is not specified.]'
|
'-var-file=[(path) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]'
|
||||||
}
|
}
|
||||||
|
|
||||||
__taint() {
|
__taint() {
|
||||||
|
|
|
@ -14,7 +14,7 @@ This data is outputted when `terraform apply` is called, and can be queried usin
|
||||||
Azure requires that an application is added to Azure Active Directory to generate the `client_id`, `client_secret`, and `tenant_id` needed by Terraform (`subscription_id` can be recovered from your Azure account details). Please go [here](https://www.terraform.io/docs/providers/azurerm/) for full instructions on how to create this to populate your `provider.tf` file.
|
Azure requires that an application is added to Azure Active Directory to generate the `client_id`, `client_secret`, and `tenant_id` needed by Terraform (`subscription_id` can be recovered from your Azure account details). Please go [here](https://www.terraform.io/docs/providers/azurerm/) for full instructions on how to create this to populate your `provider.tf` file.
|
||||||
|
|
||||||
## terraform.tfvars
|
## terraform.tfvars
|
||||||
If a `terraform.tfvars` file is present in the current directory, Terraform automatically loads it to populate variables. We don't recommend saving usernames and password to version control, but you can create a local secret variables file and use `-var-file` to load it.
|
If a `terraform.tfvars` or any `.auto.tfvars` files are present in the current directory, Terraform automatically loads them to populate variables. We don't recommend saving usernames and password to version control, but you can create a local secret variables file and use the `-var-file` flag or the `.auto.tfvars` extension to load it.
|
||||||
|
|
||||||
If you are committing this template to source control, please insure that you add this file to your .gitignore file.
|
If you are committing this template to source control, please insure that you add this file to your .gitignore file.
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ This data is outputted when `terraform apply` is called, and can be queried usin
|
||||||
Azure requires that an application is added to Azure Active Directory to generate the `client_id`, `client_secret`, and `tenant_id` needed by Terraform (`subscription_id` can be recovered from your Azure account details). Please go [here](https://www.terraform.io/docs/providers/azurerm/) for full instructions on how to create this to populate your `provider.tf` file.
|
Azure requires that an application is added to Azure Active Directory to generate the `client_id`, `client_secret`, and `tenant_id` needed by Terraform (`subscription_id` can be recovered from your Azure account details). Please go [here](https://www.terraform.io/docs/providers/azurerm/) for full instructions on how to create this to populate your `provider.tf` file.
|
||||||
|
|
||||||
## terraform.tfvars
|
## terraform.tfvars
|
||||||
If a `terraform.tfvars` file is present in the current directory, Terraform automatically loads it to populate variables. We don't recommend saving usernames and password to version control, but you can create a local secret variables file and use `-var-file` to load it.
|
If a `terraform.tfvars` or any `.auto.tfvars` files are present in the current directory, Terraform automatically loads them to populate variables. We don't recommend saving usernames and password to version control, but you can create a local secret variables file and use the `-var-file` flag or the `.auto.tfvars` extension to load it.
|
||||||
|
|
||||||
If you are committing this template to source control, please insure that you add this file to your `.gitignore` file.
|
If you are committing this template to source control, please insure that you add this file to your `.gitignore` file.
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ You may leave the provider block in the `main.tf`, as it is in this template, or
|
||||||
Azure requires that an application is added to Azure Active Directory to generate the `client_id`, `client_secret`, and `tenant_id` needed by Terraform (`subscription_id` can be recovered from your Azure account details). Please go [here](https://www.terraform.io/docs/providers/azurerm/) for full instructions on how to create this to populate your `provider.tf` file.
|
Azure requires that an application is added to Azure Active Directory to generate the `client_id`, `client_secret`, and `tenant_id` needed by Terraform (`subscription_id` can be recovered from your Azure account details). Please go [here](https://www.terraform.io/docs/providers/azurerm/) for full instructions on how to create this to populate your `provider.tf` file.
|
||||||
|
|
||||||
## terraform.tfvars
|
## terraform.tfvars
|
||||||
If a `terraform.tfvars` file is present in the current directory, Terraform automatically loads it to populate variables. We don't recommend saving usernames and password to version control, but you can create a local secret variables file and use `-var-file` to load it.
|
If a `terraform.tfvars` or any `.auto.tfvars` files are present in the current directory, Terraform automatically loads them to populate variables. We don't recommend saving usernames and password to version control, but you can create a local secret variables file and use the `-var-file` flag or the `.auto.tfvars` extension to load it.
|
||||||
|
|
||||||
If you are committing this template to source control, please insure that you add this file to your .gitignore file.
|
If you are committing this template to source control, please insure that you add this file to your .gitignore file.
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ You may leave the provider block in the `main.tf`, as it is in this template, or
|
||||||
Azure requires that an application is added to Azure Active Directory to generate the `client_id`, `client_secret`, and `tenant_id` needed by Terraform (`subscription_id` can be recovered from your Azure account details). Please go [here](https://www.terraform.io/docs/providers/azurerm/) for full instructions on how to create this to populate your `provider.tf` file.
|
Azure requires that an application is added to Azure Active Directory to generate the `client_id`, `client_secret`, and `tenant_id` needed by Terraform (`subscription_id` can be recovered from your Azure account details). Please go [here](https://www.terraform.io/docs/providers/azurerm/) for full instructions on how to create this to populate your `provider.tf` file.
|
||||||
|
|
||||||
## terraform.tfvars
|
## terraform.tfvars
|
||||||
If a `terraform.tfvars` file is present in the current directory, Terraform automatically loads it to populate variables. We don't recommend saving usernames and password to version control, but you can create a local secret variables file and use `-var-file` to load it.
|
If a `terraform.tfvars` or any `.auto.tfvars` files are present in the current directory, Terraform automatically loads them to populate variables. We don't recommend saving usernames and password to version control, but you can create a local secret variables file and use the `-var-file` flag or the `.auto.tfvars` extension to load it.
|
||||||
|
|
||||||
If you are committing this template to source control, please insure that you add this file to your `.gitignore` file.
|
If you are committing this template to source control, please insure that you add this file to your `.gitignore` file.
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ This data is outputted when `terraform apply` is called, and can be queried usin
|
||||||
Azure requires that an application is added to Azure Active Directory to generate the `client_id`, `client_secret`, and `tenant_id` needed by Terraform (`subscription_id` can be recovered from your Azure account details). Please go [here](https://www.terraform.io/docs/providers/azurerm/) for full instructions on how to create this to populate your `provider.tf` file.
|
Azure requires that an application is added to Azure Active Directory to generate the `client_id`, `client_secret`, and `tenant_id` needed by Terraform (`subscription_id` can be recovered from your Azure account details). Please go [here](https://www.terraform.io/docs/providers/azurerm/) for full instructions on how to create this to populate your `provider.tf` file.
|
||||||
|
|
||||||
## terraform.tfvars
|
## terraform.tfvars
|
||||||
If a `terraform.tfvars` file is present in the current directory, Terraform automatically loads it to populate variables. We don't recommend saving usernames and password to version control, but you can create a local secret variables file and use `-var-file` to load it.
|
If a `terraform.tfvars` or any `.auto.tfvars` files are present in the current directory, Terraform automatically loads them to populate variables. We don't recommend saving usernames and password to version control, but you can create a local secret variables file and use the `-var-file` flag or the `.auto.tfvars` extension to load it.
|
||||||
|
|
||||||
If you are committing this template to source control, please insure that you add this file to your `.gitignore` file.
|
If you are committing this template to source control, please insure that you add this file to your `.gitignore` file.
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ This data is outputted when `terraform apply` is called, and can be queried usin
|
||||||
Azure requires that an application is added to Azure Active Directory to generate the `client_id`, `client_secret`, and `tenant_id` needed by Terraform (`subscription_id` can be recovered from your Azure account details). Please go [here](https://www.terraform.io/docs/providers/azurerm/) for full instructions on how to create this to populate your `provider.tf` file.
|
Azure requires that an application is added to Azure Active Directory to generate the `client_id`, `client_secret`, and `tenant_id` needed by Terraform (`subscription_id` can be recovered from your Azure account details). Please go [here](https://www.terraform.io/docs/providers/azurerm/) for full instructions on how to create this to populate your `provider.tf` file.
|
||||||
|
|
||||||
## terraform.tfvars
|
## terraform.tfvars
|
||||||
If a `terraform.tfvars` file is present in the current directory, Terraform automatically loads it to populate variables. We don't recommend saving usernames and password to version control, but you can create a local secret variables file and use `-var-file` to load it.
|
If a `terraform.tfvars` or any `.auto.tfvars` files are present in the current directory, Terraform automatically loads them to populate variables. We don't recommend saving usernames and password to version control, but you can create a local secret variables file and use the `-var-file` flag or the `.auto.tfvars` extension to load it.
|
||||||
|
|
||||||
If you are committing this template to source control, please insure that you add this file to your `.gitignore` file.
|
If you are committing this template to source control, please insure that you add this file to your `.gitignore` file.
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ This data is outputted when `terraform apply` is called, and can be queried usin
|
||||||
Azure requires that an application is added to Azure Active Directory to generate the `client_id`, `client_secret`, and `tenant_id` needed by Terraform (`subscription_id` can be recovered from your Azure account details). Please go [here](https://www.terraform.io/docs/providers/azurerm/) for full instructions on how to create this to populate your `provider.tf` file.
|
Azure requires that an application is added to Azure Active Directory to generate the `client_id`, `client_secret`, and `tenant_id` needed by Terraform (`subscription_id` can be recovered from your Azure account details). Please go [here](https://www.terraform.io/docs/providers/azurerm/) for full instructions on how to create this to populate your `provider.tf` file.
|
||||||
|
|
||||||
## terraform.tfvars
|
## terraform.tfvars
|
||||||
If a `terraform.tfvars` file is present in the current directory, Terraform automatically loads it to populate variables. We don't recommend saving usernames and password to version control, but you can create a local secret variables file and use `-var-file` to load it.
|
If a `terraform.tfvars` or any `.auto.tfvars` files are present in the current directory, Terraform automatically loads them to populate variables. We don't recommend saving usernames and password to version control, but you can create a local secret variables file and use the `-var-file` flag or the `.auto.tfvars` extension to load it.
|
||||||
|
|
||||||
## variables.tf
|
## variables.tf
|
||||||
The `variables.tf` file contains all of the input parameters that the user can specify when deploying this Terraform template.
|
The `variables.tf` file contains all of the input parameters that the user can specify when deploying this Terraform template.
|
||||||
|
|
|
@ -19,7 +19,7 @@ This data is outputted when `terraform apply` is called, and can be queried usin
|
||||||
Azure requires that an application is added to Azure Active Directory to generate the `client_id`, `client_secret`, and `tenant_id` needed by Terraform (`subscription_id` can be recovered from your Azure account details). Please go [here](https://www.terraform.io/docs/providers/azurerm/) for full instructions on how to create this to populate your `provider.tf` file.
|
Azure requires that an application is added to Azure Active Directory to generate the `client_id`, `client_secret`, and `tenant_id` needed by Terraform (`subscription_id` can be recovered from your Azure account details). Please go [here](https://www.terraform.io/docs/providers/azurerm/) for full instructions on how to create this to populate your `provider.tf` file.
|
||||||
|
|
||||||
## terraform.tfvars
|
## terraform.tfvars
|
||||||
If a `terraform.tfvars` file is present in the current directory, Terraform automatically loads it to populate variables. We don't recommend saving usernames and password to version control, but you can create a local secret variables file and use `-var-file` to load it.
|
If a `terraform.tfvars` or any `.auto.tfvars` files are present in the current directory, Terraform automatically loads them to populate variables. We don't recommend saving usernames and password to version control, but you can create a local secret variables file and use the `-var-file` flag or the `.auto.tfvars` extension to load it.
|
||||||
|
|
||||||
If you are committing this template to source control, please insure that you add this file to your `.gitignore` file.
|
If you are committing this template to source control, please insure that you add this file to your `.gitignore` file.
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ This data is outputted when `terraform apply` is called, and can be queried usin
|
||||||
Azure requires that an application is added to Azure Active Directory to generate the `client_id`, `client_secret`, and `tenant_id` needed by Terraform (`subscription_id` can be recovered from your Azure account details). Please go [here](https://www.terraform.io/docs/providers/azurerm/) for full instructions on how to create this to populate your `provider.tf` file.
|
Azure requires that an application is added to Azure Active Directory to generate the `client_id`, `client_secret`, and `tenant_id` needed by Terraform (`subscription_id` can be recovered from your Azure account details). Please go [here](https://www.terraform.io/docs/providers/azurerm/) for full instructions on how to create this to populate your `provider.tf` file.
|
||||||
|
|
||||||
## terraform.tfvars
|
## terraform.tfvars
|
||||||
If a `terraform.tfvars` file is present in the current directory, Terraform automatically loads it to populate variables. We don't recommend saving usernames and password to version control, but you can create a local secret variables file and use `-var-file` to load it.
|
If a `terraform.tfvars` or any `.auto.tfvars` files are present in the current directory, Terraform automatically loads them to populate variables. We don't recommend saving usernames and password to version control, but you can create a local secret variables file and use the `-var-file` flag or the `.auto.tfvars` extension to load it.
|
||||||
|
|
||||||
If you are committing this template to source control, please insure that you add this file to your `.gitignore` file.
|
If you are committing this template to source control, please insure that you add this file to your `.gitignore` file.
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ This data is outputted when `terraform apply` is called, and can be queried usin
|
||||||
Azure requires that an application is added to Azure Active Directory to generate the `client_id`, `client_secret`, and `tenant_id` needed by Terraform (`subscription_id` can be recovered from your Azure account details). Please go [here](https://www.terraform.io/docs/providers/azurerm/) for full instructions on how to create this to populate your `provider.tf` file.
|
Azure requires that an application is added to Azure Active Directory to generate the `client_id`, `client_secret`, and `tenant_id` needed by Terraform (`subscription_id` can be recovered from your Azure account details). Please go [here](https://www.terraform.io/docs/providers/azurerm/) for full instructions on how to create this to populate your `provider.tf` file.
|
||||||
|
|
||||||
## terraform.tfvars
|
## terraform.tfvars
|
||||||
If a `terraform.tfvars` file is present in the current directory, Terraform automatically loads it to populate variables. We don't recommend saving usernames and password to version control, but you can create a local secret variables file and use `-var-file` to load it.
|
If a `terraform.tfvars` or any `.auto.tfvars` files are present in the current directory, Terraform automatically loads them to populate variables. We don't recommend saving usernames and password to version control, but you can create a local secret variables file and use the `-var-file` flag or the `.auto.tfvars` extension to load it.
|
||||||
|
|
||||||
## variables.tf
|
## variables.tf
|
||||||
The `variables.tf` file contains all of the input parameters that the user can specify when deploying this Terraform template.
|
The `variables.tf` file contains all of the input parameters that the user can specify when deploying this Terraform template.
|
||||||
|
|
|
@ -27,7 +27,7 @@ This data is outputted when `terraform apply` is called, and can be queried usin
|
||||||
Azure requires that an application is added to Azure Active Directory to generate the `client_id`, `client_secret`, and `tenant_id` needed by Terraform (`subscription_id` can be recovered from your Azure account details). Please go [here](https://www.terraform.io/docs/providers/azurerm/) for full instructions on how to create this to populate your `provider.tf` file.
|
Azure requires that an application is added to Azure Active Directory to generate the `client_id`, `client_secret`, and `tenant_id` needed by Terraform (`subscription_id` can be recovered from your Azure account details). Please go [here](https://www.terraform.io/docs/providers/azurerm/) for full instructions on how to create this to populate your `provider.tf` file.
|
||||||
|
|
||||||
## terraform.tfvars
|
## terraform.tfvars
|
||||||
If a `terraform.tfvars` file is present in the current directory, Terraform automatically loads it to populate variables. We don't recommend saving usernames and password to version control, but you can create a local secret variables file and use `-var-file` to load it.
|
If a `terraform.tfvars` or any `.auto.tfvars` files are present in the current directory, Terraform automatically loads them to populate variables. We don't recommend saving usernames and password to version control, but you can create a local secret variables file and use the `-var-file` flag or the `.auto.tfvars` extension to load it.
|
||||||
|
|
||||||
## variables.tf
|
## variables.tf
|
||||||
The `variables.tf` file contains all of the input parameters that the user can specify when deploying this Terraform template.
|
The `variables.tf` file contains all of the input parameters that the user can specify when deploying this Terraform template.
|
||||||
|
|
|
@ -14,7 +14,7 @@ You may leave the provider block in the `main.tf`, as it is in this template, or
|
||||||
Azure requires that an application is added to Azure Active Directory to generate the `client_id`, `client_secret`, and `tenant_id` needed by Terraform (`subscription_id` can be recovered from your Azure account details). Please go [here](https://www.terraform.io/docs/providers/azurerm/) for full instructions on how to create this to populate your `provider.tf` file.
|
Azure requires that an application is added to Azure Active Directory to generate the `client_id`, `client_secret`, and `tenant_id` needed by Terraform (`subscription_id` can be recovered from your Azure account details). Please go [here](https://www.terraform.io/docs/providers/azurerm/) for full instructions on how to create this to populate your `provider.tf` file.
|
||||||
|
|
||||||
## terraform.tfvars
|
## terraform.tfvars
|
||||||
If a `terraform.tfvars` file is present in the current directory, Terraform automatically loads it to populate variables. We don't recommend saving usernames and password to version control, but you can create a local secret variables file and use `-var-file` to load it.
|
If a `terraform.tfvars` or any `.auto.tfvars` files are present in the current directory, Terraform automatically loads them to populate variables. We don't recommend saving usernames and password to version control, but you can create a local secret variables file and use the `-var-file` flag or the `.auto.tfvars` extension to load it.
|
||||||
|
|
||||||
## variables.tf
|
## variables.tf
|
||||||
The `variables.tf` file contains all of the input parameters that the user can specify when deploying this Terraform template.
|
The `variables.tf` file contains all of the input parameters that the user can specify when deploying this Terraform template.
|
||||||
|
|
|
@ -14,7 +14,7 @@ You may leave the provider block in the `main.tf`, as it is in this template, or
|
||||||
Azure requires that an application is added to Azure Active Directory to generate the `client_id`, `client_secret`, and `tenant_id` needed by Terraform (`subscription_id` can be recovered from your Azure account details). Please go [here](https://www.terraform.io/docs/providers/azurerm/) for full instructions on how to create this to populate your `provider.tf` file.
|
Azure requires that an application is added to Azure Active Directory to generate the `client_id`, `client_secret`, and `tenant_id` needed by Terraform (`subscription_id` can be recovered from your Azure account details). Please go [here](https://www.terraform.io/docs/providers/azurerm/) for full instructions on how to create this to populate your `provider.tf` file.
|
||||||
|
|
||||||
## terraform.tfvars
|
## terraform.tfvars
|
||||||
If a `terraform.tfvars` file is present in the current directory, Terraform automatically loads it to populate variables. We don't recommend saving usernames and password to version control, but you can create a local secret variables file and use `-var-file` to load it.
|
If a `terraform.tfvars` or any `.auto.tfvars` files are present in the current directory, Terraform automatically loads them to populate variables. We don't recommend saving usernames and password to version control, but you can create a local secret variables file and use the `-var-file` flag or the `.auto.tfvars` extension to load it.
|
||||||
|
|
||||||
If you are committing this template to source control, please insure that you add this file to your `.gitignore` file.
|
If you are committing this template to source control, please insure that you add this file to your `.gitignore` file.
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ This data is outputted when `terraform apply` is called, and can be queried usin
|
||||||
Azure requires that an application is added to Azure Active Directory to generate the `client_id`, `client_secret`, and `tenant_id` needed by Terraform (`subscription_id` can be recovered from your Azure account details). Please go [here](https://www.terraform.io/docs/providers/azurerm/) for full instructions on how to create this to populate your `provider.tf` file.
|
Azure requires that an application is added to Azure Active Directory to generate the `client_id`, `client_secret`, and `tenant_id` needed by Terraform (`subscription_id` can be recovered from your Azure account details). Please go [here](https://www.terraform.io/docs/providers/azurerm/) for full instructions on how to create this to populate your `provider.tf` file.
|
||||||
|
|
||||||
## terraform.tfvars
|
## terraform.tfvars
|
||||||
If a `terraform.tfvars` file is present in the current directory, Terraform automatically loads it to populate variables. We don't recommend saving usernames and password to version control, but you can create a local secret variables file and use `-var-file` to load it.
|
If a `terraform.tfvars` or any `.auto.tfvars` files are present in the current directory, Terraform automatically loads them to populate variables. We don't recommend saving usernames and password to version control, but you can create a local secret variables file and use the `-var-file` flag or the `.auto.tfvars` extension to load it.
|
||||||
|
|
||||||
## variables.tf
|
## variables.tf
|
||||||
The `variables.tf` file contains all of the input parameters that the user can specify when deploying this Terraform template.
|
The `variables.tf` file contains all of the input parameters that the user can specify when deploying this Terraform template.
|
||||||
|
|
|
@ -33,7 +33,7 @@ You may leave the provider block in the `main.tf`, as it is in this template, or
|
||||||
Azure requires that an application is added to Azure Active Directory to generate the `client_id`, `client_secret`, and `tenant_id` needed by Terraform (`subscription_id` can be recovered from your Azure account details). Please go [here](https://www.terraform.io/docs/providers/azurerm/) for full instructions on how to create this to populate your `provider.tf` file.
|
Azure requires that an application is added to Azure Active Directory to generate the `client_id`, `client_secret`, and `tenant_id` needed by Terraform (`subscription_id` can be recovered from your Azure account details). Please go [here](https://www.terraform.io/docs/providers/azurerm/) for full instructions on how to create this to populate your `provider.tf` file.
|
||||||
|
|
||||||
## terraform.tfvars
|
## terraform.tfvars
|
||||||
If a `terraform.tfvars` file is present in the current directory, Terraform automatically loads it to populate variables. We don't recommend saving usernames and password to version control, but you can create a local secret variables file and use `-var-file` to load it.
|
If a `terraform.tfvars` or any `.auto.tfvars` files are present in the current directory, Terraform automatically loads them to populate variables. We don't recommend saving usernames and password to version control, but you can create a local secret variables file and use the `-var-file` flag or the `.auto.tfvars` extension to load it.
|
||||||
|
|
||||||
If you are committing this template to source control, please insure that you add this file to your `.gitignore` file.
|
If you are committing this template to source control, please insure that you add this file to your `.gitignore` file.
|
||||||
|
|
||||||
|
|
|
@ -67,8 +67,9 @@ The command-line flags are all optional. The list of available flags are:
|
||||||
specified via this flag.
|
specified via this flag.
|
||||||
|
|
||||||
* `-var-file=foo` - Set variables in the Terraform configuration from
|
* `-var-file=foo` - Set variables in the Terraform configuration from
|
||||||
a [variable file](/docs/configuration/variables.html#variable-files). If
|
a [variable file](/docs/configuration/variables.html#variable-files). If
|
||||||
any files matching "*.tfvars" are present, they will be automatically loaded
|
a `terraform.tfvars` or any `.auto.tfvars` files are present in the current
|
||||||
in alphabetical order. Any files specified by `-var-file` override any values
|
directory, they will be automatically loaded. `terraform.tfvars` is loaded
|
||||||
set automatically from files in the working directory. This flag can be used
|
first and the `.auto.tfvars` files after in alphabetical order. Any files
|
||||||
multiple times.
|
specified by `-var-file` override any values set automatically from files in
|
||||||
|
the working directory. This flag can be used multiple times.
|
||||||
|
|
|
@ -66,11 +66,13 @@ The command-line flags are all optional. The list of available flags are:
|
||||||
specified via this flag. This is only useful with the `-config` flag.
|
specified via this flag. This is only useful with the `-config` flag.
|
||||||
|
|
||||||
* `-var-file=foo` - Set variables in the Terraform configuration from
|
* `-var-file=foo` - Set variables in the Terraform configuration from
|
||||||
a [variable file](/docs/configuration/variables.html#variable-files). If
|
a [variable file](/docs/configuration/variables.html#variable-files). If
|
||||||
any file matching "*.tfvars" are present, they will be automatically loaded
|
a `terraform.tfvars` or any `.auto.tfvars` files are present in the current
|
||||||
in alphabetical order. Any files specified by `-var-file` override any values
|
directory, they will be automatically loaded. `terraform.tfvars` is loaded
|
||||||
set automatically from files in the working directory. This flag can be used
|
first and the `.auto.tfvars` files after in alphabetical order. Any files
|
||||||
multiple times. This is only useful with the `-config` flag.
|
specified by `-var-file` override any values set automatically from files in
|
||||||
|
the working directory. This flag can be used multiple times. This is only
|
||||||
|
useful with the `-config` flag.
|
||||||
|
|
||||||
## Provider Configuration
|
## Provider Configuration
|
||||||
|
|
||||||
|
|
|
@ -72,11 +72,12 @@ The command-line flags are all optional. The list of available flags are:
|
||||||
specified via this flag.
|
specified via this flag.
|
||||||
|
|
||||||
* `-var-file=foo` - Set variables in the Terraform configuration from
|
* `-var-file=foo` - Set variables in the Terraform configuration from
|
||||||
a [variable file](/docs/configuration/variables.html#variable-files). If
|
a [variable file](/docs/configuration/variables.html#variable-files). If
|
||||||
any files matching "*.tfvars" are present, they will be automatically loaded
|
a `terraform.tfvars` or any `.auto.tfvars` files are present in the current
|
||||||
in alphabetical order. Any files specified by `-var-file` override any values
|
directory, they will be automatically loaded. `terraform.tfvars` is loaded
|
||||||
set automatically from files in the working directory. This flag can be used
|
first and the `.auto.tfvars` files after in alphabetical order. Any files
|
||||||
multiple times.
|
specified by `-var-file` override any values set automatically from files in
|
||||||
|
the working directory. This flag can be used multiple times.
|
||||||
|
|
||||||
## Resource Targeting
|
## Resource Targeting
|
||||||
|
|
||||||
|
|
|
@ -55,8 +55,9 @@ The command-line flags are all optional. The list of available flags are:
|
||||||
specified via this flag.
|
specified via this flag.
|
||||||
|
|
||||||
* `-var-file=foo` - Set variables in the Terraform configuration from
|
* `-var-file=foo` - Set variables in the Terraform configuration from
|
||||||
a [variable file](/docs/configuration/variables.html#variable-files). If
|
a [variable file](/docs/configuration/variables.html#variable-files). If
|
||||||
any files matching "*.tfvars" are present, they will be automatically loaded
|
a `terraform.tfvars` or any `.auto.tfvars` files are present in the current
|
||||||
in alphabetical order. Any files specified by `-var-file` override any values
|
directory, they will be automatically loaded. `terraform.tfvars` is loaded
|
||||||
set automatically from files in the working directory. This flag can be used
|
first and the `.auto.tfvars` files after in alphabetical order. Any files
|
||||||
multiple times.
|
specified by `-var-file` override any values set automatically from files in
|
||||||
|
the working directory. This flag can be used multiple times.
|
||||||
|
|
|
@ -256,9 +256,10 @@ $ TF_VAR_somemap='{foo = "bar", baz = "qux"}' terraform plan
|
||||||
Variables can be collected in files and passed all at once using the
|
Variables can be collected in files and passed all at once using the
|
||||||
`-var-file=foo.tfvars` flag.
|
`-var-file=foo.tfvars` flag.
|
||||||
|
|
||||||
For all files which match `*.tfvars` present in the current directory,
|
For all files which match `terraform.tfvars` or `*.auto.tfvars` present in the
|
||||||
Terraform automatically loads it to populate variables. If the file is located
|
current directory, Terraform automatically loads them to populate variables. If
|
||||||
somewhere else, you can pass the path to the file using the `-var-file` flag.
|
the file is located somewhere else, you can pass the path to the file using the
|
||||||
|
`-var-file` flag.
|
||||||
|
|
||||||
Variables files use HCL or JSON to define variable values. Strings, lists or
|
Variables files use HCL or JSON to define variable values. Strings, lists or
|
||||||
maps may be set in the same manner as the default value in a `variable` block
|
maps may be set in the same manner as the default value in a `variable` block
|
||||||
|
@ -337,14 +338,10 @@ _bar.tfvars_
|
||||||
baz = "bar"
|
baz = "bar"
|
||||||
```
|
```
|
||||||
|
|
||||||
When they are read directly from the working directory, the files are evaluated
|
When they are passed in the following order:
|
||||||
in alphabetical order. The result will be that baz contains the value `foo`
|
|
||||||
because `foo.tfvars` has the last definition loaded.
|
|
||||||
|
|
||||||
When they are passed manually in the following order:
|
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
$ terraform apply -var-file=path/to/foo.tfvars -var-file=path/to/bar.tfvars
|
$ terraform apply -var-file=foo.tfvars -var-file=bar.tfvars
|
||||||
```
|
```
|
||||||
|
|
||||||
The result will be that `baz` will contain the value `bar` because `bar.tfvars`
|
The result will be that `baz` will contain the value `bar` because `bar.tfvars`
|
||||||
|
|
|
@ -86,9 +86,9 @@ access_key = "foo"
|
||||||
secret_key = "bar"
|
secret_key = "bar"
|
||||||
```
|
```
|
||||||
|
|
||||||
If a `terraform.tfvars` file is present in the current directory,
|
For all files which match `terraform.tfvars` or `*.auto.tfvars` present in the
|
||||||
Terraform automatically loads it to populate variables. If the file is
|
current directory, Terraform automatically loads them to populate variables. If
|
||||||
named something else, you can use the `-var-file` flag directly to
|
the file is named something else, you can use the `-var-file` flag directly to
|
||||||
specify a file. These files are the same syntax as Terraform
|
specify a file. These files are the same syntax as Terraform
|
||||||
configuration files. And like Terraform configuration files, these files
|
configuration files. And like Terraform configuration files, these files
|
||||||
can also be JSON.
|
can also be JSON.
|
||||||
|
|
|
@ -233,4 +233,4 @@ This will give the map the effective value:
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
It's also possible to override the values in a variables file, either in any `*.tfvars` file or specified using the `-var-file` flag.
|
It's also possible to override the values in a variables file, either in any `terraform.tfvars` file, an `.auto.tfvars` file, or specified using the `-var-file` flag.
|
||||||
|
|
Loading…
Reference in New Issue