New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auto generate backend key based on component name for azurerm #95
Auto generate backend key based on component name for azurerm #95
Conversation
@lukeorellana thanks for the PR, and thanks for trying out
so other people would see the example on how to use it. thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lukeorellana thanks you, please see comments
@aknysh Thanks! Pushed commit with backend example . Let me know if you would like me to add anything else. |
|
||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -478,6 +479,28 @@ func ProcessConfig( | |||
} | |||
} | |||
|
|||
// Check if component `backend` section has `key` for `azurerm` backend type | |||
// If it does not, use the component name instead and format it with the global backend key name to auto generate a unique tf state key | |||
// The backend state file will be formated like so: {global key name}/{component name}.terraform.tfstate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// The backend state file will be formated like so: {global key name}/{component name}.terraform.tfstate | |
// The backend state file will be formatted like so: {global key name}/{component name}.terraform.tfstate |
thanks @lukeorellana |
what
When using the AzureRM backend type, automatically generate backend key based on component name if the backend key is not specified at the component level:
{Global Backend Key value}/{component name}.terraform.tfstate
format. Places all component states in a storage account folder with the name of the global backend key value.Before:
After:
backend.tf:
why
The (azure backend) does not currently have a prefix option for workspaces. When using Atmos with Azure, users are forced to specify each backend key for every component.
references
hashicorp/terraform#28985