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

feat(lb): add support for http_filter_option #1229

Merged
merged 5 commits into from
Apr 22, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
18 changes: 10 additions & 8 deletions scaleway/helpers_lb.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,11 @@ func expandLbACLAction(raw interface{}) *lbSDK.ACLAction {
func flattenLbACLMatch(match *lbSDK.ACLMatch) interface{} {
return []map[string]interface{}{
{
"ip_subnet": flattenSliceStringPtr(match.IPSubnet),
"http_filter": match.HTTPFilter.String(),
"http_filter_value": flattenSliceStringPtr(match.HTTPFilterValue),
"invert": match.Invert,
"ip_subnet": flattenSliceStringPtr(match.IPSubnet),
"http_filter": match.HTTPFilter.String(),
"http_filter_value": flattenSliceStringPtr(match.HTTPFilterValue),
"http_filter_option": match.HTTPFilterOption,
"invert": match.Invert,
},
}
}
Expand All @@ -232,10 +233,11 @@ func expandLbACLMatch(raw interface{}) *lbSDK.ACLMatch {
}

return &lbSDK.ACLMatch{
IPSubnet: ipSubnet,
HTTPFilter: lbSDK.ACLHTTPFilter(rawMap["http_filter"].(string)),
HTTPFilterValue: expandSliceStringPtr(rawMap["http_filter_value"].([]interface{})),
Invert: rawMap["invert"].(bool),
IPSubnet: ipSubnet,
HTTPFilter: lbSDK.ACLHTTPFilter(rawMap["http_filter"].(string)),
HTTPFilterValue: expandSliceStringPtr(rawMap["http_filter_value"].([]interface{})),
HTTPFilterOption: expandStringPtr(rawMap["http_filter_option"].(string)),
Invert: rawMap["invert"].(bool),
}
}

Expand Down
22 changes: 22 additions & 0 deletions scaleway/resource_lb_acl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,19 @@ func TestAccScalewayLbAcl_Basic(t *testing.T) {
type = "deny"
}
}

acl {
match {
ip_subnet = ["0.0.0.0/0"]
http_filter = "http_header_match"
http_filter_value = ["example.com"]
http_filter_option = "host"
}

action {
type = "allow"
}
}
}
`,
Check: resource.ComposeTestCheckFunc(
Expand Down Expand Up @@ -139,6 +152,15 @@ func TestAccScalewayLbAcl_Basic(t *testing.T) {
},
Action: &lbSDK.ACLAction{Type: lbSDK.ACLActionTypeDeny},
},
{
Match: &lbSDK.ACLMatch{
IPSubnet: scw.StringSlicePtr([]string{"0.0.0.0/0"}),
HTTPFilter: lbSDK.ACLHTTPFilterHTTPHeaderMatch,
HTTPFilterValue: scw.StringSlicePtr([]string{"example.com"}),
HTTPFilterOption: scw.StringPtr("host"),
},
Action: &lbSDK.ACLAction{Type: lbSDK.ACLActionTypeAllow},
},
}),
),
},
Expand Down
6 changes: 6 additions & 0 deletions scaleway/resource_lb_frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ func resourceScalewayLbFrontend() *schema.Resource {
lbSDK.ACLHTTPFilterPathBegin.String(),
lbSDK.ACLHTTPFilterPathEnd.String(),
lbSDK.ACLHTTPFilterRegex.String(),
lbSDK.ACLHTTPFilterHTTPHeaderMatch.String(),
}, false),
Description: "The HTTP filter to match",
},
Expand All @@ -146,6 +147,11 @@ func resourceScalewayLbFrontend() *schema.Resource {
Type: schema.TypeString,
},
},
"http_filter_option": {
Type: schema.TypeString,
Optional: true,
Description: "You can use this field with http_header_match acl type to set the header name to filter",
},
"invert": {
Type: schema.TypeBool,
Optional: true,
Expand Down
Loading