Skip to content
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

r/application_gateway: ensuring the casing on identity_ids within the identity block #10031

Merged
merged 5 commits into from
Jan 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 13 additions & 5 deletions azurerm/internal/services/network/application_gateway_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/msi/parse"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
Expand Down Expand Up @@ -1530,7 +1531,10 @@ func resourceArmApplicationGatewayRead(d *schema.ResourceData, meta interface{})
}
d.Set("zones", applicationGateway.Zones)

identity := flattenRmApplicationGatewayIdentity(applicationGateway.Identity)
identity, err := flattenRmApplicationGatewayIdentity(applicationGateway.Identity)
if err != nil {
return err
}
if err = d.Set("identity", identity); err != nil {
return err
}
Expand Down Expand Up @@ -1689,9 +1693,9 @@ func expandAzureRmApplicationGatewayIdentity(d *schema.ResourceData) *network.Ma
return &appGatewayIdentity
}

func flattenRmApplicationGatewayIdentity(identity *network.ManagedServiceIdentity) []interface{} {
func flattenRmApplicationGatewayIdentity(identity *network.ManagedServiceIdentity) ([]interface{}, error) {
if identity == nil {
return make([]interface{}, 0)
return make([]interface{}, 0), nil
}

result := make(map[string]interface{})
Expand All @@ -1703,12 +1707,16 @@ func flattenRmApplicationGatewayIdentity(identity *network.ManagedServiceIdentit
identityIds := make([]string, 0)
if identity.UserAssignedIdentities != nil {
for key := range identity.UserAssignedIdentities {
identityIds = append(identityIds, key)
parsedId, err := parse.UserAssignedIdentityID(key)
if err != nil {
return nil, err
}
identityIds = append(identityIds, parsedId.ID())
}
}
result["identity_ids"] = identityIds

return []interface{}{result}
return []interface{}{result}, nil
}

func expandApplicationGatewayAuthenticationCertificates(certs []interface{}) *[]network.ApplicationGatewayAuthenticationCertificate {
Expand Down