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

Access Context Manager: add support for access level condition 'regions' #1882

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
3 changes: 3 additions & 0 deletions .changelog/3291.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
accesscontextmanager: Added `regions` field to `google_access_context_manager_access_level`
```
26 changes: 26 additions & 0 deletions google-beta/resource_access_context_manager_access_level.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,16 @@ Formats: 'user:{emailid}', 'serviceAccount:{emailid}'`,
a NAND over its non-empty fields, each field must be false for
the Condition overall to be satisfied. Defaults to false.`,
},
"regions": {
Type: schema.TypeList,
Optional: true,
Description: `The request must originate from one of the provided
countries/regions.
Format: A valid ISO 3166-1 alpha-2 code.`,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"required_access_levels": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -500,6 +510,7 @@ func flattenAccessContextManagerAccessLevelBasicConditions(v interface{}, d *sch
"members": flattenAccessContextManagerAccessLevelBasicConditionsMembers(original["members"], d, config),
"negate": flattenAccessContextManagerAccessLevelBasicConditionsNegate(original["negate"], d, config),
"device_policy": flattenAccessContextManagerAccessLevelBasicConditionsDevicePolicy(original["devicePolicy"], d, config),
"regions": flattenAccessContextManagerAccessLevelBasicConditionsRegions(original["regions"], d, config),
})
}
return transformed
Expand Down Expand Up @@ -590,6 +601,10 @@ func flattenAccessContextManagerAccessLevelBasicConditionsDevicePolicyRequireCor
return v
}

func flattenAccessContextManagerAccessLevelBasicConditionsRegions(v interface{}, d *schema.ResourceData, config *Config) interface{} {
return v
}

func flattenAccessContextManagerAccessLevelName(v interface{}, d *schema.ResourceData, config *Config) interface{} {
return v
}
Expand Down Expand Up @@ -677,6 +692,13 @@ func expandAccessContextManagerAccessLevelBasicConditions(v interface{}, d Terra
transformed["devicePolicy"] = transformedDevicePolicy
}

transformedRegions, err := expandAccessContextManagerAccessLevelBasicConditionsRegions(original["regions"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedRegions); val.IsValid() && !isEmptyValue(val) {
transformed["regions"] = transformedRegions
}

req = append(req, transformed)
}
return req, nil
Expand Down Expand Up @@ -809,6 +831,10 @@ func expandAccessContextManagerAccessLevelBasicConditionsDevicePolicyRequireCorp
return v, nil
}

func expandAccessContextManagerAccessLevelBasicConditionsRegions(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}

func expandAccessContextManagerAccessLevelParent(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ resource "google_access_context_manager_access_level" "test-access" {
os_type = "DESKTOP_CHROME_OS"
}
}
regions = [
"IT",
"US",
]
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions website/docs/r/access_context_manager_access_level.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ resource "google_access_context_manager_access_level" "access-level" {
os_type = "DESKTOP_CHROME_OS"
}
}
regions = [
"CH",
"IT",
"US",
]
}
}
}
Expand Down Expand Up @@ -152,6 +157,12 @@ The `conditions` block supports:
the Condition to be true. If not specified, all devices are
allowed. Structure is documented below.

* `regions` -
(Optional)
The request must originate from one of the provided
countries/regions.
Format: A valid ISO 3166-1 alpha-2 code.


The `device_policy` block supports:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ resource "google_access_context_manager_access_level" "access-level" {
os_type = "DESKTOP_CHROME_OS"
}
}
}
regions = [
"CH",
"IT",
"US",
]
}
}
}

Expand Down