Reputation: 1853
I'm trying to create a resource group with Terraform.io with this example.tf file:
# Configure Azure provider
provider "azurerm" {
subscription_id = "${var.azure_subscription_id}"
client_id = "${var.azure_client_id}"
client_secret = "${var.azure_client_secret}"
tenant_id = "${var.azure_tenant_id}"
}
# Create a resource group
resource "azurerm_resource_group" "terraform-rg" {
name = "terraform-rg"
location = "ukwest"
}
All goes well it seems, but I'm slightly worried about this message at the end:
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
The state of your infrastructure has been saved to the path
below. This state is required to modify and destroy your
infrastructure, so keep it safe. To inspect the complete state
use the `terraform show` command.
State path:
So "Stage path" is empty and it seems important. Is there an argument I should pass to "terraform apply" or put somewhere else in the tf file so that I get a state path?
Upvotes: 0
Views: 2021
Reputation: 4832
state path:
is empty because you didn't configure the backend in your config above. In this case terraform will keep the state file called terraform.tfstate
in same location as the rest of .tf
file
That said, if you want the state path:
to have the full path to your terraform.tfstate file after running terraform apply
then configure the local backend as follow:
terraform {
backend "local" {
path = "/path_to_statefile_location/terraform.tfstate"
}
}
https://www.terraform.io/docs/backends/types/local.html
Upvotes: 1
Reputation: 3769
Most likely you have initialized your project with a remote state backend. In that case tf does not store your state on a local path, which results in an empty state path message at the end.
Upvotes: 0