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_endpoint - delivery_rule condition optional match_values #8850

Merged
Show file tree
Hide file tree
Changes from all 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
194 changes: 194 additions & 0 deletions azurerm/internal/services/cdn/cdn_endpoint_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,21 @@ func TestAccCdnEndpoint_PremiumVerizon(t *testing.T) {
})
}

func TestAccCdnEndpoint_deliveryRuleOptionalMatchValue(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_cdn_endpoint", "test")
r := CdnEndpointResource{}

data.ResourceTest(t, r, []resource.TestStep{
{
Config: r.deliveryRuleOptionalMatchValue(data),
Check: resource.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

func (r CdnEndpointResource) Exists(ctx context.Context, client *clients.Client, state *terraform.InstanceState) (*bool, error) {
id, err := parse.EndpointID(state.ID)
if err != nil {
Expand Down Expand Up @@ -1129,3 +1144,182 @@ resource "azurerm_cdn_endpoint" "test" {
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger)
}

func (r CdnEndpointResource) deliveryRuleOptionalMatchValue(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}

resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "%s"
}

resource "azurerm_cdn_profile" "test" {
name = "acctestcdnprof%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
sku = "Standard_Microsoft"
}

resource "azurerm_cdn_endpoint" "test" {
name = "acctestcdnend%d"
profile_name = azurerm_cdn_profile.test.name
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name

origin_host_header = "www.contoso.com"

origin {
name = "acceptanceTestCdnOrigin1"
host_name = "www.contoso.com"
https_port = 443
http_port = 80
}

delivery_rule {
name = "cookieCondition"
order = 1

cookies_condition {
selector = "abc"
operator = "Any"
}

modify_response_header_action {
action = "Delete"
name = "Content-Language"
}
}

delivery_rule {
name = "postArg"
order = 2

post_arg_condition {
selector = "abc"
operator = "Any"
}

modify_response_header_action {
action = "Delete"
name = "Content-Language"
}
}

delivery_rule {
name = "queryString"
order = 3

query_string_condition {
operator = "Any"
}

modify_response_header_action {
action = "Delete"
name = "Content-Language"
}
}

delivery_rule {
name = "remoteAddress"
order = 4

remote_address_condition {
operator = "Any"
}

modify_response_header_action {
action = "Delete"
name = "Content-Language"
}
}

delivery_rule {
name = "requestBody"
order = 5

request_body_condition {
operator = "Any"
}

modify_response_header_action {
action = "Delete"
name = "Content-Language"
}
}

delivery_rule {
name = "requestHeader"
order = 6

request_header_condition {
selector = "abc"
operator = "Any"
}

modify_response_header_action {
action = "Delete"
name = "Content-Language"
}
}

delivery_rule {
name = "requestUri"
order = 7

request_uri_condition {
operator = "Any"
}

modify_response_header_action {
action = "Delete"
name = "Content-Language"
}
}

delivery_rule {
name = "uriFileExtension"
order = 8

url_file_extension_condition {
operator = "Any"
}

modify_response_header_action {
action = "Delete"
name = "Content-Language"
}
}

delivery_rule {
name = "uriFileName"
order = 9

url_file_name_condition {
operator = "Any"
}

modify_response_header_action {
action = "Delete"
name = "Content-Language"
}
}

delivery_rule {
name = "uriPath"
order = 10

url_path_condition {
operator = "Any"
}

modify_response_header_action {
action = "Delete"
name = "Content-Language"
}
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger)
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func Cookies() *schema.Resource {

"match_values": {
Type: schema.TypeSet,
Required: true,
Optional: true,
MinItems: 1,
Elem: &schema.Schema{
Type: schema.TypeString,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func PostArg() *schema.Resource {

"match_values": {
Type: schema.TypeSet,
Required: true,
Optional: true,
MinItems: 1,
Elem: &schema.Schema{
Type: schema.TypeString,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func QueryString() *schema.Resource {

"match_values": {
Type: schema.TypeSet,
Required: true,
Optional: true,
MinItems: 1,
Elem: &schema.Schema{
Type: schema.TypeString,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func RemoteAddress() *schema.Resource {

"match_values": {
Type: schema.TypeSet,
Required: true,
Optional: true,
MinItems: 1,
Elem: &schema.Schema{
Type: schema.TypeString,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func RequestBody() *schema.Resource {

"match_values": {
Type: schema.TypeSet,
Required: true,
Optional: true,
MinItems: 1,
Elem: &schema.Schema{
Type: schema.TypeString,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func RequestHeader() *schema.Resource {

"match_values": {
Type: schema.TypeSet,
Required: true,
Optional: true,
MinItems: 1,
Elem: &schema.Schema{
Type: schema.TypeString,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func RequestURI() *schema.Resource {

"match_values": {
Type: schema.TypeSet,
Required: true,
Optional: true,
MinItems: 1,
Elem: &schema.Schema{
Type: schema.TypeString,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func URLFileExtension() *schema.Resource {

"match_values": {
Type: schema.TypeSet,
Required: true,
Optional: true,
MinItems: 1,
Elem: &schema.Schema{
Type: schema.TypeString,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func URLFileName() *schema.Resource {

"match_values": {
Type: schema.TypeSet,
Required: true,
Optional: true,
MinItems: 1,
Elem: &schema.Schema{
Type: schema.TypeString,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func URLPath() *schema.Resource {

"match_values": {
Type: schema.TypeSet,
Required: true,
Optional: true,
MinItems: 1,
Elem: &schema.Schema{
Type: schema.TypeString,
Expand Down
22 changes: 12 additions & 10 deletions website/docs/r/cdn_endpoint.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ A `cookies_condition` block supports the following:

* `negate_condition` - (Optional) Defaults to `false`.

* `match_values` - (Required) List of values for the cookie.
* `match_values` - (Optional) List of values for the cookie. This is required if `operator` is not `Any`.



* `transforms` - (Optional) Valid values are `Lowercase` and `Uppercase`.

Expand Down Expand Up @@ -268,7 +270,7 @@ A `post_arg_condition` block supports the following:

* `negate_condition` - (Optional) Defaults to `false`.

* `match_values` - (Required) List of string values.
* `match_values` - (Optional) List of string values. This is required if `operator` is not `Any`.

* `transforms` - (Optional) Valid values are `Lowercase` and `Uppercase`.

Expand All @@ -280,7 +282,7 @@ A `query_string_condition` block supports the following:

* `negate_condition` - (Optional) Defaults to `false`.

* `match_values` - (Required) List of string values.
* `match_values` - (Optional) List of string values. This is required if `operator` is not `Any`.

* `transforms` - (Optional) Valid values are `Lowercase` and `Uppercase`.

Expand All @@ -292,7 +294,7 @@ A `remote_address_condition` block supports the following:

* `negate_condition` - (Optional) Defaults to `false`.

* `match_values` - (Required) List of string values. For `GeoMatch` `operator` this should be a list of country codes (e.g. `US` or `DE`). List of IP address if `operator` equals to `IPMatch`.
* `match_values` - (Optional) List of string values. For `GeoMatch` `operator` this should be a list of country codes (e.g. `US` or `DE`). List of IP address if `operator` equals to `IPMatch`. This is required if `operator` is not `Any`.

---

Expand All @@ -302,7 +304,7 @@ A `request_body_condition` block supports the following:

* `negate_condition` - (Optional) Defaults to `false`.

* `match_values` - (Required) List of string values.
* `match_values` - (Optional) List of string values. This is required if `operator` is not `Any`.

* `transforms` - (Optional) Valid values are `Lowercase` and `Uppercase`.

Expand All @@ -316,7 +318,7 @@ A `request_header_condition` block supports the following:

* `negate_condition` - (Optional) Defaults to `false`.

* `match_values` - (Required) List of header values.
* `match_values` - (Optional) List of header values. This is required if `operator` is not `Any`.

* `transforms` - (Optional) Valid values are `Lowercase` and `Uppercase`.

Expand Down Expand Up @@ -348,7 +350,7 @@ A `request_uri_condition` block supports the following:

* `negate_condition` - (Optional) Defaults to `false`.

* `match_values` - (Required) List of string values.
* `match_values` - (Optional) List of string values. This is required if `operator` is not `Any`.

* `transforms` - (Optional) Valid values are `Lowercase` and `Uppercase`.

Expand All @@ -360,7 +362,7 @@ A `url_file_extension_condition` block supports the following:

* `negate_condition` - (Optional) Defaults to `false`.

* `match_values` - (Required) List of string values.
* `match_values` - (Optional) List of string values. This is required if `operator` is not `Any`.

* `transforms` - (Optional) Valid values are `Lowercase` and `Uppercase`.

Expand All @@ -372,7 +374,7 @@ A `url_file_name_condition` block supports the following:

* `negate_condition` - (Optional) Defaults to `false`.

* `match_values` - (Required) List of string values.
* `match_values` - (Optional) List of string values. This is required if `operator` is not `Any`.

* `transforms` - (Optional) Valid values are `Lowercase` and `Uppercase`.

Expand All @@ -384,7 +386,7 @@ A `url_path_condition` block supports the following:

* `negate_condition` - (Optional) Defaults to `false`.

* `match_values` - (Required) List of string values.
* `match_values` - (Optional) List of string values. This is required if `operator` is not `Any`.

* `transforms` - (Optional) Valid values are `Lowercase` and `Uppercase`.

Expand Down