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

azurerm_cdn_frontdoor_rule - documentation of transforms is wrong #18470

Closed
1 task done
evandeworp opened this issue Sep 21, 2022 · 4 comments · Fixed by #18231
Closed
1 task done

azurerm_cdn_frontdoor_rule - documentation of transforms is wrong #18470

evandeworp opened this issue Sep 21, 2022 · 4 comments · Fixed by #18231

Comments

@evandeworp
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

1.2.9

AzureRM Provider Version

3.23.0

Affected Resource(s)/Data Source(s)

azurerm_cdn_frontdoor_rule

Terraform Configuration Files

resource "azurerm_resource_group" "example" {
  name     = "example-cdn-frontdoor"
  location = "West Europe"
}

resource "azurerm_cdn_frontdoor_profile" "example" {
  name                = "example-profile"
  resource_group_name = azurerm_resource_group.example.name
}

resource "azurerm_cdn_frontdoor_endpoint" "example" {
  name                     = "example-endpoint"
  cdn_frontdoor_profile_id = azurerm_cdn_frontdoor_profile.example.id

  tags = {
    endpoint = "contoso.com"
  }
}

resource "azurerm_cdn_frontdoor_origin_group" "example" {
  name                     = "example-originGroup"
  cdn_frontdoor_profile_id = azurerm_cdn_frontdoor_profile.example.id
  session_affinity_enabled = true

  restore_traffic_time_to_healed_or_new_endpoint_in_minutes = 10

  health_probe {
    interval_in_seconds = 240
    path                = "/healthProbe"
    protocol            = "Https"
    request_type        = "GET"
  }

  load_balancing {
    additional_latency_in_milliseconds = 0
    sample_size                        = 16
    successful_samples_required        = 3
  }
}

resource "azurerm_cdn_frontdoor_origin" "example" {
  name                          = "example-origin"
  cdn_frontdoor_origin_group_id = azurerm_cdn_frontdoor_origin_group.example.id

  health_probes_enabled          = true
  certificate_name_check_enabled = false

  host_name          = azurerm_cdn_frontdoor_endpoint.example.host_name
  http_port          = 80
  https_port         = 443
  origin_host_header = "contoso.com"
  priority           = 1
  weight             = 500
}

resource "azurerm_cdn_frontdoor_rule_set" "example" {
  name                     = "exampleruleset"
  cdn_frontdoor_profile_id = azurerm_cdn_frontdoor_profile.example.id
}

resource "azurerm_cdn_frontdoor_rule" "example" {
  depends_on = [azurerm_cdn_frontdoor_origin_group.example, azurerm_cdn_frontdoor_origin.example]

  name                      = "examplerule"
  cdn_frontdoor_rule_set_id = azurerm_cdn_frontdoor_rule_set.example.id
  order                     = 1
  behavior_on_match         = "Continue"

  actions {
    route_configuration_override_action {
      cdn_frontdoor_origin_group_id = azurerm_cdn_frontdoor_origin_group.example.id
      forwarding_protocol           = "HttpsOnly"
      query_string_caching_behavior = "IncludeSpecifiedQueryStrings"
      query_string_parameters       = ["foo", "clientIp={client_ip}"]
      compression_enabled           = true
      cache_behavior                = "OverrideIfOriginMissing"
      cache_duration                = "365.23:59:59"
    }

    url_redirect_action {
      redirect_type        = "PermanentRedirect"
      redirect_protocol    = "MatchRequest"
      query_string         = "clientIp={client_ip}"
      destination_path     = "/exampleredirection"
      destination_hostname = "contoso.com"
      destination_fragment = "UrlRedirect"
    }
  }

  conditions {
    host_name_condition {
      operator         = "Equal"
      negate_condition = false
      match_values     = ["www.contoso.com", "images.contoso.com", "video.contoso.com"]
      transform        = ["Lowercase", "Trim"]
    }

    is_device_condition {
      operator         = "Equal"
      negate_condition = false
      match_values     = ["Mobile"]
    }

    post_args_condition {
      post_args_name = "customerName"
      operator       = "BeginsWith"
      match_values   = ["J", "K"]
      transform      = ["Uppercase"]
    }

    request_method_condition {
      operator         = "Equal"
      negate_condition = false
      match_values     = ["DELETE"]
    }

    url_filename_condition {
      operator         = "Equal"
      negate_condition = false
      match_values     = ["media.mp4"]
      transform        = ["Lowercase", "RemoveNulls", "Trim"]
    }
  }
}

Debug Output/Panic Output

Not applicable.

Expected Behaviour

Successful plan should be created since, according to documentation https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cdn_frontdoor_rule, the argument name in multiple places is "transform" but all these arguments in the documentation should be "transforms".

(Even the example of https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cdn_frontdoor_rule has "transforms" being used instead of "transform").

Actual Behaviour

PS C:> terraform plan

│ Error: Unsupported argument

│ on main.tf line 96, in resource "azurerm_cdn_frontdoor_rule" "example":
│ 96: transform = ["Lowercase", "Trim"]

│ An argument named "transform" is not expected here. Did you mean "transforms"?


│ Error: Unsupported argument

│ on main.tf line 109, in resource "azurerm_cdn_frontdoor_rule" "example":
│ 109: transform = ["Uppercase"]

│ An argument named "transform" is not expected here. Did you mean "transforms"?


│ Error: Unsupported argument

│ on main.tf line 122, in resource "azurerm_cdn_frontdoor_rule" "example":
│ 122: transform = ["Lowercase", "RemoveNulls", "Trim"]

│ An argument named "transform" is not expected here. Did you mean "transforms"?

Steps to Reproduce

terraform plan

Important Factoids

No response

References

No response

@WodansSon
Copy link
Collaborator

WodansSon commented Sep 21, 2022

@evandeworp, thank you for opening this issue. This issue will be fixed with my latest FrontDoor PR #18231. Fixed with this commit.

@evandeworp
Copy link
Author

Since the documentation is being fixed, might as well fix the example in the documentation as well. The example in https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cdn_frontdoor_rule fails with:

│ Error: Missing required argument

│ on main.tf line 6, in resource "azurerm_cdn_frontdoor_profile" "example":
│ 6: resource "azurerm_cdn_frontdoor_profile" "example" {

│ The argument "sku_name" is required, but no definition was found.

In the documented example, please change:

resource "azurerm_cdn_frontdoor_profile" "example" {
name = "example-profile"
resource_group_name = azurerm_resource_group.example.name
}

To:

resource "azurerm_cdn_frontdoor_profile" "example" {
name = "example-profile"
resource_group_name = azurerm_resource_group.example.name
sku_name = "Standard_AzureFrontDoor"
}

@WodansSon
Copy link
Collaborator

Since the documentation is being fixed, might as well fix the example in the documentation as well. The example in https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cdn_frontdoor_rule fails with:

│ Error: Missing required argument │ │ on main.tf line 6, in resource "azurerm_cdn_frontdoor_profile" "example": │ 6: resource "azurerm_cdn_frontdoor_profile" "example" { │ │ The argument "sku_name" is required, but no definition was found.

In the documented example, please change:

resource "azurerm_cdn_frontdoor_profile" "example" { name = "example-profile" resource_group_name = azurerm_resource_group.example.name }

To:

resource "azurerm_cdn_frontdoor_profile" "example" { name = "example-profile" resource_group_name = azurerm_resource_group.example.name sku_name = "Standard_AzureFrontDoor" }

@evandeworp, thanks for the comment, this is a known issue and will be fixed moving forward. As these resources are still currently under development these examples are not guaranteed to work but are only offered as a possible configuration once the resources have been fully released. This is my last task once everything has been finalized with the resources. I will add examples and fix all of the example configurations in the documentation. This is an incredibly complex and difficult resource to implement, so I appreciate your patience while we work this out. 🚀

WodansSon added a commit that referenced this issue Sep 29, 2022
…18551

* initial check-in

* still refactoring but should be functional

* Doc updates

* deprecate health_probes_enabled property

* Update website/docs/r/cdn_frontdoor_custom_domain_secret_validator.html.markdown

Co-authored-by: Sebastian <[email protected]>

* Update website/docs/r/cdn_frontdoor_custom_domain_txt_validator.html.markdown

Co-authored-by: Sebastian <[email protected]>

* refactor CIDR validation into validation packages

* fix naked return lint error in cidr overlap func

* Update code comments to add context

* Fix for 18249

* Remove txt and secret validators

* Remove validator ids, parse/validation packages

* Update rules doc for depends_on usage

* Doc updates

* Update test cases

* Correct skip txt for origin test

* More test and doc updates

* Update test and docs to use new subnet field

* Fix for 18370

* Update docs per PR comment

* Incremental fixed per PR review

* Initial additon of association and doc fix

* Custom domain assoc mostly working

* Additional progress...

* Fix lint errors

* Fix lint errors

* Last of the PR comments addressed...

* Fix for issue #18551

* Mostly working not done with the disable resource

* Done

Co-authored-by: Sebastian <[email protected]>
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants