Skip to content

Commit

Permalink
fix: maintain frontdoor tags (#62)
Browse files Browse the repository at this point in the history
* fix: preserve azure frontdoor waf policy tags between updates

* feat: add example tags to test preservation
  • Loading branch information
pyrxm committed Jan 10, 2023
1 parent ce400e5 commit 6fb4e68
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,13 @@ func (fd *AzureFrontDoor) update() int {

azfd := frontdoor.NewPoliciesClient(fd.SubscriptionId)
azfd.Authorizer, _ = a.authorize()

// Read current state of azure frontdoor
azfdget, _ := azfd.Get(context.Background(), fd.ResourceGroup, fd.PolicyName)

_, err := azfd.CreateOrUpdate(context.Background(), fd.ResourceGroup, fd.PolicyName, frontdoor.WebApplicationFirewallPolicy{
Location: to.StringPtr("Global"),
Tags: azfdget.Tags, // Preserve tags for existing policies.
WebApplicationFirewallPolicyProperties: &frontdoor.WebApplicationFirewallPolicyProperties{
PolicySettings: &frontdoor.PolicySettings{
EnabledState: frontdoor.PolicyEnabledStateEnabled,
Expand Down
5 changes: 5 additions & 0 deletions terraform/frontdoor.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ resource "azurerm_frontdoor_firewall_policy" "this" {
https://xyz.com/ip-whitelister
*/
lifecycle { ignore_changes = [custom_rule, managed_rule] }

tags = {
name = var.name
created-by = "terraform"
}
}

output "azure_frontdoor_policy" {
Expand Down

0 comments on commit 6fb4e68

Please sign in to comment.