Closed devblackops closed 3 years ago
Please also see:
https://github.com/terraform-providers/terraform-provider-azurerm/issues/9318#issuecomment-740751924
The link above also has an issue re being unable to set the weekly backups back to zero when desired.
Looks like there are two issues that are closely related.
In a similar vein to this, I am unable to specify PT0S
as a value due to the regex check:
yearly_retention = "PT0S"
Error: "long_term_retention_policy.0.yearly_retention" did not match regex "^P[0-9]*[YMWD]"
on main.tf line 528, in resource "azurerm_mssql_database" "app_db":
528: resource "azurerm_mssql_database" "app_db" {
Error: "long_term_retention_policy.0.yearly_retention" has to be a valid Duration format, starting with "P" and ending with either of the letters "YMWD"
on main.tf line 528, in resource "azurerm_mssql_database" "app_db":
528: resource "azurerm_mssql_database" "app_db" {
plans wanting to reapply existing settings each run is really infuriating, this has been open quite a while now - any idea when it will be looked at?
~ long_term_retention_policy {
monthly_retention = "P1Y"
~ week_of_year = 0 -> 1
weekly_retention = "P8W"
~ yearly_retention = "PT0S" -> "P0Y"
}
Not sure if this'll help anyone, but one thing that's worked well for us with the backup retention block is to set yearly_retention
and week_of_year
to null
.
Not sure if this'll help anyone, but one thing that's worked well for us with the backup retention block is to set
yearly_retention
andweek_of_year
tonull
.
Setting week_of_year to 'null' in updates works, but if you create a new database with week_of_year as null then it throws an error
Error: Error issuing create/update request for Sql Server "<sql-server-name>" (Database "<database-name>") Long Term Retention Policies (Resource Group "<resource-group-name>"): sql.BackupLongTermRetentionPoliciesClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: Code="LongTermRetentionMissingWeekOfYear" Message="WeekOfYear is required to be set between 1 and 52 in order to set yearly retention."
terraform 0.14.9 azurerm 2.53.0
attempted to set this today:
short_term_retention_policy {
retention_days = 1
}
received this error:
Error: expected short_term_retention_policy.0.retention_days to be in the range (7 - 35), got 1
microsoft documentation (and portal) suggest valid values for PITR are 1-35.
plans wanting to reapply existing settings each run is really infuriating, this has been open quite a while now - any idea when it will be looked at?
~ long_term_retention_policy { monthly_retention = "P1Y" ~ week_of_year = 0 -> 1 weekly_retention = "P8W" ~ yearly_retention = "PT0S" -> "P0Y" }
terraform 0.14.9 azurerm 2.53.0
seeing the same issue as @catt231 where by the long_term_retention
is not being stored in the state file and thus every terraform plan
shows that the configuration needs to be applied, here's the output:
~ long_term_retention_policy {
~ monthly_retention = "PT0S" -> "P0M"
~ week_of_year = 0 -> 1
~ weekly_retention = "PT0S" -> "P0D"
~ yearly_retention = "PT0S" -> "P0Y"
}
and the terraform state file shows these settings:
"long_term_retention_policy": [
{
"monthly_retention": "PT0S",
"week_of_year": 0,
"weekly_retention": "PT0S",
"yearly_retention": "PT0S"
}
]
is there an ENVAR to skip the regex or something?
another similar issue, i had this
long_term_retention_policy {
weekly_retention = "P45D"
}
and during apply got the error
Error: Error issuing create/update request for Sql Server "example" (Database "example") Long Term Retention Policies (Resource Group "example"): sql.BackupLongTermRetentionPoliciesClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: Code="LongTermRetentionMissingWeekOfYear" Message="WeekOfYear is required to be set between 1 and 52 in order to set yearly retention."
but this setting is supposed to be optional...?
I can't believe this isn't more of an issue, it's been open for a good while now
There is no way to set a default value week_of_year = 0 or week_of_year = null it is possible to define by default in parent module long_term_retention_policy { weekly_retention = null monthly_retention = null yearly_retention = null week_of_year = 1 } Unfortunately, week_of_year = null raises an error, but this expression week_of_year = 1 always tries to update 0 to 1
Taking a look through here the original issue appears to have been fixed by #12198 - closing this. For any new issues please open a new issue to track those specifically.
This functionality has been released in v2.72.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.
For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!
anyone who thumbs upped this or subscribed, i reopened as #13035 since it doesnt' seem initial issue was resolved in that we require week_in_year still and it always comes back as a change in plan
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Community Note
Terraform (and AzureRM Provider) Version
Affected Resource(s)
azurerm_mssql_database
Terraform Configuration Files
Debug Output
Panic Output
Expected Behavior
The SQL database is provisioned with the expected settings and subsequent plans show zero changes.
Actual Behavior
threat_detection_policy.use_server_default
is never set toEnabled
andlong_term_retention_policy.week_of_year
andlong_term_retention_policy.yearly_retention
are never set toP0Y
and1
respectively. Terraform apply will say it's updating the resources but that is never reflected in the state.Steps to Reproduce
terraform apply
Important Factoids
References
0000