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

[Dependency:] azurerm_cdn_frontdoor_* - update dependencies to use 2024-02-01 API #28233

Merged
merged 7 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion internal/clients/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,9 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error
if client.Bot, err = bot.NewClient(o); err != nil {
return fmt.Errorf("building clients for Bot: %+v", err)
}
client.Cdn = cdn.NewClient(o)
if client.Cdn, err = cdn.NewClient(o); err != nil {
return fmt.Errorf("building clients for Cdn: %+v", err)
}
if client.CodeSigning, err = codesigning.NewClient(o); err != nil {
return fmt.Errorf("building clients for Code Signing: %+v", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,10 @@ func resourceCdnFrontDoorCustomDomain() *pluginsdk.Resource {

if !features.FivePointOhBeta() {
resource.Schema["tls"].Elem.(*pluginsdk.Resource).Schema["minimum_tls_version"] = &pluginsdk.Schema{
Type: pluginsdk.TypeString,
Optional: true,
Default: string(cdn.AfdMinimumTLSVersionTLS12),
Type: pluginsdk.TypeString,
Optional: true,
Default: string(cdn.AfdMinimumTLSVersionTLS12),
Deprecated: "As of March 1, 2025, support for 'TLS10' will be retired from Azure Front Door, therefore the 'TLS10' property value will be removed in v5.0 of the provider.",
ValidateFunc: validation.StringInSlice([]string{
string(cdn.AfdMinimumTLSVersionTLS12),
string(cdn.AfdMinimumTLSVersionTLS10),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import (
"fmt"
"time"

"github.com/Azure/azure-sdk-for-go/services/frontdoor/mgmt/2020-11-01/frontdoor" // nolint: staticcheck
"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
waf "github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/cdn/parse"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/cdn/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/timeouts"
"github.com/hashicorp/terraform-provider-azurerm/utils"
)

func dataSourceCdnFrontDoorFirewallPolicy() *pluginsdk.Resource {
Expand Down Expand Up @@ -66,41 +66,44 @@ func dataSourceCdnFrontDoorFirewallPolicy() *pluginsdk.Resource {
}

func dataSourceCdnFrontDoorFirewallPolicyRead(d *pluginsdk.ResourceData, meta interface{}) error {
client := meta.(*clients.Client).Cdn.FrontDoorLegacyFirewallPoliciesClient
client := meta.(*clients.Client).Cdn.FrontDoorFirewallPoliciesClient
subscriptionId := meta.(*clients.Client).Account.SubscriptionId
ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d)
defer cancel()

id := parse.NewFrontDoorFirewallPolicyID(subscriptionId, d.Get("resource_group_name").(string), d.Get("name").(string))
name := d.Get("name").(string)
resourceGroup := d.Get("resource_group_name").(string)

resp, err := client.Get(ctx, id.ResourceGroup, id.FrontDoorWebApplicationFirewallPolicyName)
id := waf.NewFrontDoorWebApplicationFirewallPolicyID(subscriptionId, resourceGroup, name)

result, err := client.PoliciesGet(ctx, id)
if err != nil {
if utils.ResponseWasNotFound(resp.Response) {
if !response.WasNotFound(result.HttpResponse) {
return fmt.Errorf("%s was not found", id)
}

return fmt.Errorf("retrieving %s: %+v", id, err)
}

skuName := ""
if sku := resp.Sku; sku != nil {
skuName = string(sku.Name)
}

d.SetId(id.ID())
d.Set("name", id.FrontDoorWebApplicationFirewallPolicyName)
d.Set("resource_group_name", id.ResourceGroup)
d.Set("sku_name", skuName)
if model := result.Model; model != nil {
d.SetId(id.ID())
jackofallops marked this conversation as resolved.
Show resolved Hide resolved

if properties := resp.WebApplicationFirewallPolicyProperties; properties != nil {
if policy := properties.PolicySettings; policy != nil {
d.Set("enabled", policy.EnabledState == frontdoor.PolicyEnabledStateEnabled)
d.Set("mode", string(policy.Mode))
d.Set("redirect_url", policy.RedirectURL)
d.Set("name", id.FrontDoorWebApplicationFirewallPolicyName)
d.Set("resource_group_name", id.ResourceGroupName)
if sku := model.Sku; sku != nil {
d.Set("sku_name", string(pointer.From(sku.Name)))
}

if err := d.Set("frontend_endpoint_ids", flattenFrontendEndpointLinkSlice(properties.FrontendEndpointLinks)); err != nil {
return fmt.Errorf("flattening 'frontend_endpoint_ids': %+v", err)
if props := model.Properties; props != nil {
if err := d.Set("frontend_endpoint_ids", flattenFrontendEndpointLinkSlice(props.FrontendEndpointLinks)); err != nil {
return fmt.Errorf("flattening 'frontend_endpoint_ids': %+v", err)
}

if policy := props.PolicySettings; policy != nil {
d.Set("enabled", pointer.From(policy.EnabledState) == waf.PolicyEnabledStateEnabled)
d.Set("mode", pointer.From(policy.Mode))
d.Set("redirect_url", policy.RedirectURL)
}
}
}

Expand Down
Loading
Loading