This page describes generally how to create basic access levels. To create custom access levels and use Advanced Mode in the Google Cloud console, see Creating a custom access level.
This page includes more focused implementations of access levels. See the following examples:
- Limit access on a corporate network
- Limit access by device attributes
- Grant access by user or service account
Before you begin
- Learn about access levels.
Create a basic access level
Console
To create a basic access level:
Open the Access Context Manager page in the Google Cloud console.
If you are prompted, select your organization.
At the top of the Access Context Manager page, click New.
In the New Access Level pane:
In the Access level title field, enter a title for the access level. The title must be at most 50 characters, start with a letter, and can contain only numbers, letters, underscores, and spaces.
In the Conditions section, click the add button for the type of attribute you want to add, and then provide the values you want applied to that attribute.
For a complete list of the attributes you can add, read about access level attributes.
For example, if you want the access level to consider where a request is coming from within your network, you would select the IP Subnetworks attribute.
Repeat this step to add multiple attributes to the same condition. When a condition has multiple attributes, all of the attributes must be met by the access request.
An access level condition can include one of each type of attribute. Some attributes include additional options, such as the Device Policy attribute.
Access levels support conditions based on user identity. However, to add identities to a condition, you must create or update the access level using the gcloud CLI or the API.
Use the When condition is met, return option to specify whether you want the condition to require that a request meet all specified attributes (TRUE) or whether the request must meet anything but those attributes (FALSE).
For example, if you want to deny requests from a certain IP address range of your network, specify the IP address range using the IP Subnetworks attribute and then set the condition to FALSE.
Optionally, click Add another condition to add an additional condition to your access level and then repeat the previous two steps.
For example, if you want to deny access to a subset of IP addresses within a broader IP address range, create a new condition, specify the subset IP address range for the IP Subnetworks attribute, and set the condition to return FALSE.
Repeat this step to add multiple conditions to the same access level.
If you created more than one condition, use Combine condition with to specify whether you want the access level to require a request to meet at least one of the conditions (OR), or all of the conditions (AND).
Click Save.
gcloud
Before you begin
- If it doesn't exist yet, create an access policy for your organization.
To create an access level using the gcloud command-line tool, use the
gcloud access-context-manager levels create command.
gcloud access-context-manager levels create LEVEL_NAME OPTIONS \ --policy=POLICY
Where:
LEVEL_NAME is the unique name for the access level. It must begin with a letter and include only letters, numbers, and underscores. The name can be a maximum of 50 characters.
OPTIONS are the required options from the following table.
Options basic-level-specA YAML file that specifies one or more conditions for the access level.
titleA short title for the access level. The access level's title is displayed in the Google Cloud console.
combine-function(Optional) Determines how conditions are combined.
Valid values:
AND,ORdescription(Optional) A long-form description of the access level.
POLICY is the ID of your organization's access policy. If you have a default policy set, this parameter is optional.
Optionally, you can include any of the gcloud-wide flags.
basic-level-spec YAML file
When you use the gcloud command-line tool to create an access level, you must provide a YAML
file for the basic-level-spec option. The YAML file defines one or more
conditions for the access level. Conditions must contain at least one
attribute. When a condition contains more than one attribute, they are
combined as either an AND operation (all must be true) or as a NAND
operation (none can be true), depending on whether the negate attribute
is included in the condition.
For a complete list of the attributes you can include in your YAML file, read about access level attributes.
For more information about access levels and YAML, refer to the example YAML for an access level.
Example command
gcloud access-context-manager levels create Device_Trust \
--basic-level-spec=corpdevspec.yaml \
--combine-function=AND \
--description='Access level that conforms to corporate spec.' \
--title='Device_Trust Extended' \
--policy=1521580097614100
API
Before you begin
- If it doesn't exist yet, create an access policy for your organization.
To create an access level, call accessLevels.create.
POST https://accesscontextmanager.googleapis.com/v1/accessPolicies/POLICY/accessLevels
Where:
- POLICY is the ID of your organization's access policy.
Request body
The request body must include an AccessLevel
resource that specifies the conditions you want for the new access level.
Each Condition has one or more attributes that are
evaluated as an AND operation (all must be true) or as a
NAND operation (none can be true) depending on whether the negate
field is set to true. The resulting evaluation determines whether the
condition is met or not.