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

Add support for Access geo rules #803

Merged
merged 3 commits into from
Oct 6, 2020
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 cloudflare/resource_cloudflare_access_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ var AccessGroupOptionSchemaElement = &schema.Resource{
Type: schema.TypeString,
Optional: true,
},
"geo": {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"gsuite": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -368,6 +375,12 @@ func BuildAccessGroupCondition(options map[string]interface{}) []interface{} {
AuthMethod string `json:"auth_method"`
}{AuthMethod: values.(string)}})
}
} else if accessGroupType == "geo" {
if values != "" {
group = append(group, cloudflare.AccessGroupGeo{Geo: struct {
CountryCode string `json:"country_code"`
}{CountryCode: values.(string)}})
}
} else if accessGroupType == "gsuite" {
for _, v := range values.([]interface{}) {
gsuiteCfg := v.(map[string]interface{})
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/access_group.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ conditions which can be applied. The conditions are:
* `auth_method` - (Optional) A string identifying the authentication
method code. The list of codes are listed here: https://tools.ietf.org/html/rfc8176#section-2.
Custom values are also supported.
* `geo` - (Optional) A list of country codes. Example: `geo = ["US"]`
* `gsuite` - (Optional) Use GSuite as the authentication mechanism. Example:

```hcl
Expand Down