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

CDI-890: add WAAP option support #152

Merged
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
13 changes: 13 additions & 0 deletions docs/resources/cdn_resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ Optional:
- `use_default_le_chain` (Block List, Max: 1) The option allows choosing a Let's Encrypt certificate chain. The specified chain will be used during the next Let's Encrypt certificate issue or renewal. (see [below for nested schema](#nestedblock--options--use_default_le_chain))
- `use_rsa_le_cert` (Block List, Max: 1) The option allows choosing the RSA Let's Encrypt certificate type for the resource. (see [below for nested schema](#nestedblock--options--use_rsa_le_cert))
- `user_agent_acl` (Block List, Max: 1) User agents policy option allows to control access to the content for specified user-agent. (see [below for nested schema](#nestedblock--options--user_agent_acl))
- `waap` (Block List, Max: 1) Option allows to enable WAAP (Web Application and API Protection). (see [below for nested schema](#nestedblock--options--waap))
- `waf` (Block List, Max: 1) Option allows to enable Basic WAF to protect you against the most common threats. (see [below for nested schema](#nestedblock--options--waf))
- `websockets` (Block List, Max: 1) WebSockets option allows WebSockets connections to an origin server. (see [below for nested schema](#nestedblock--options--websockets))

Expand Down Expand Up @@ -695,6 +696,18 @@ Optional:
- `enabled` (Boolean)


<a id="nestedblock--options--waap"></a>
### Nested Schema for `options.waap`

Required:

- `value` (Boolean)

Optional:

- `enabled` (Boolean)


<a id="nestedblock--options--waf"></a>
### Nested Schema for `options.waf`

Expand Down
13 changes: 13 additions & 0 deletions docs/resources/cdn_rule.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ Optional:
- `static_request_headers` (Block List, Max: 1) Specify custom HTTP Headers for a CDN server to add to request. (see [below for nested schema](#nestedblock--options--static_request_headers))
- `static_response_headers` (Block List, Max: 1) Specify custom HTTP Headers that a CDN server adds to a response. (see [below for nested schema](#nestedblock--options--static_response_headers))
- `user_agent_acl` (Block List, Max: 1) User agents policy option allows to control access to the content for specified user-agent. (see [below for nested schema](#nestedblock--options--user_agent_acl))
- `waap` (Block List, Max: 1) Option allows to enable WAAP (Web Application and API Protection). (see [below for nested schema](#nestedblock--options--waap))
- `waf` (Block List, Max: 1) Option allows to enable Basic WAF to protect you against the most common threats. (see [below for nested schema](#nestedblock--options--waf))
- `websockets` (Block List, Max: 1) WebSockets option allows WebSockets connections to an origin server. (see [below for nested schema](#nestedblock--options--websockets))

Expand Down Expand Up @@ -682,6 +683,18 @@ Optional:
- `enabled` (Boolean)


<a id="nestedblock--options--waap"></a>
### Nested Schema for `options.waap`

Required:

- `value` (Boolean)

Optional:

- `enabled` (Boolean)


<a id="nestedblock--options--waf"></a>
### Nested Schema for `options.waf`

Expand Down
19 changes: 19 additions & 0 deletions gcore/resource_gcore_cdn_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,25 @@ var (
},
},
},
"waap": {
Type: schema.TypeList,
MaxItems: 1,
Optional: true,
Description: "Option allows to enable WAAP (Web Application and API Protection).",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"enabled": {
Type: schema.TypeBool,
Optional: true,
Default: true,
},
"value": {
Type: schema.TypeBool,
Required: true,
},
},
},
},
"waf": {
Type: schema.TypeList,
MaxItems: 1,
Expand Down
10 changes: 10 additions & 0 deletions gcore/resource_gcore_cdn_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,12 @@ func listToOptions(l []interface{}) *gcdn.Options {
Value: opt["value"].(bool),
}
}
if opt, ok := getOptByName(fields, "waap"); ok {
opts.WAAP = &gcdn.WAAP{
Enabled: opt["enabled"].(bool),
Value: opt["value"].(bool),
}
}
if opt, ok := getOptByName(fields, "waf"); ok {
opts.WAF = &gcdn.WAF{
Enabled: opt["enabled"].(bool),
Expand Down Expand Up @@ -775,6 +781,10 @@ func optionsToList(options *gcdn.Options) []interface{} {
m := structToMap(options.UseRSALECert)
result["use_rsa_le_cert"] = []interface{}{m}
}
if options.WAAP != nil {
m := structToMap(options.WAAP)
result["waap"] = []interface{}{m}
}
if options.WAF != nil {
m := structToMap(options.WAF)
result["waf"] = []interface{}{m}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/AlekSi/pointer v1.2.0
github.com/G-Core/gcore-dns-sdk-go v0.2.9
github.com/G-Core/gcore-storage-sdk-go v0.1.34
github.com/G-Core/gcorelabscdn-go v1.0.17
github.com/G-Core/gcorelabscdn-go v1.0.19
github.com/G-Core/gcorelabscloud-go v0.8.8
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/terraform-plugin-sdk/v2 v2.27.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ github.com/G-Core/gcore-storage-sdk-go v0.1.34 h1:0GPQfz1kA6mQi6fiisGsh0Um4H9PZe
github.com/G-Core/gcore-storage-sdk-go v0.1.34/go.mod h1:BUAEZZZJJt/+luRFunqziv3+JnbVMLbQXDWz9kV8Te8=
github.com/G-Core/gcorelabscdn-go v1.0.17 h1:g5i53mzPpg513qcXzxuEdL1v/rK3yiAd8LOVjMh/noM=
github.com/G-Core/gcorelabscdn-go v1.0.17/go.mod h1:iSGXaTvZBzDHQW+rKFS918BgFVpONcyLEijwh8WsXpE=
github.com/G-Core/gcorelabscdn-go v1.0.19 h1:P4qYP+cnO+0DrVftGnL1gt7En8/RYsl20zw4wud9Krs=
github.com/G-Core/gcorelabscdn-go v1.0.19/go.mod h1:iSGXaTvZBzDHQW+rKFS918BgFVpONcyLEijwh8WsXpE=
github.com/G-Core/gcorelabscloud-go v0.8.0 h1:6w+Mikiz+GbHJs1PD+tPD1gIR88Xl3UPkJuvQVuG7bs=
github.com/G-Core/gcorelabscloud-go v0.8.0/go.mod h1:13Z1USxlxPbDFuYQyWqfNexlk4kUvOYTXbnvV/Z1lZo=
github.com/G-Core/gcorelabscloud-go v0.8.4 h1:Yf0c0ZFOTxu0VjMgMVooHp2k2fYYKLLU5jqFRuEVEcg=
Expand Down
Loading