Links

Google Cloud: Managing Access to Groups

In this tutorial, you'll learn how to configure Grant Kits to automate access requests to an Google Cloud Identity Group by attaching a Google Cloud Identity Group Membership. This use case models granting new users memberships to a GCP group.
The main terraform resources we'll be using for GCP are:
google_cloud_identity_group
google_cloud_identity_group_membership
We will be using the GCP Identity Starter Kit as a base and replace configuration stubs for our use case.

Before you start

  1. 1.
    Make sure you have:
  2. 2.
    Make sure you setup:
    1. 2.
      A Connection to a repo by following Connect a Repo

Step 1: Configure Your Grant Kit

Configure Output

Grant Kits rely on your GitHub account and repository name to output access changes, which we'll set through Terraform local variables. Update the locals block in main.tf with your account_name and repo_name
main.tf
locals {
account_name = "" #CHANGEME
repo_name = "" #CHANGEME
...
}

Configure Reviewers

Workflow defines who should approve an access request.
Let's update the reviewers block by adding yourself as the reviewer by switching [email protected] with the email address you use to sign into Abbey.
main.tf
resource "abbey_grant_kit" "..." {
...
workflow = {
steps = [
{
reviewers = {
- one_of = ["[email protected]"] # CHANGEME
+ one_of = ["[email protected]"]
Now you'll need to link GCP with Abbey.
curl -X POST \
-H "Authorization: Bearer $ABBEY_API_TOKEN" \
-H 'Content-Type: application/json' \
https://api.abbey.io/v1/users/<user_id>/apps \
-d '{"type": "google", "data": {"id": "<your GCP id>"}}'

Step 3: Configure GCP for Terraform

Configure GCP User

You can skip this step if your GCP user email address matches your Abbey email address.
Replace the value for gcp_member in the locals block to the google email address for the user you wish to add to group.
main.tf
1
locals {
2
- gcp_member = "{{ .user.google.id }}"
3
+ gcp_member = [email protected]
4
...
5
}

Configure GCP Billing Project

Replace the billing_project field in the google provider block with your project ID and correct region.
providers.tf
1
provider "google" {
2
- billing_project = "replace-me"
3
+ billing_project = "your-project-id"
4
- region = "replace-me"
5
+ region = "your-region"
6
}

Configure GCP Customer ID

In the terminal run gcloud organizations list, which should output something like
DISPLAY_NAME ID DIRECTORY_CUSTOMER_ID
abbey.io 00000000 C1111111
Update the value for gcp_customer_id in the locals block with the DIRECTORY_CUSTOMER_ID
main.tf
1
locals {
2
...
3
- gcp_customer_id = "$replace-me-with-gcp-customer-id"
4
+ gcp_customer_id = "C1111111"
5
}

Step 4: Configure GCP Permissions

In this step we will
  • Create and use GCP resources (Project, Service Account, Workload Identity Pool & Provider)
  • Add Repository Secrets so Github Actions to make calls to GCP
Create a new GCP project or use an existing one. Make sure that the Cloud Identity API is enabled for your project (https://console.cloud.google.com/apis/api/cloudidentity.googleapis.com)
After that, we need to configure Workload Identity Federation to allow Github Actions to make calls from your repo when managing the group membership. This allows Github to only gain secure temporary access tokens rather than exporting long-lived JSON secrets.
Follow these instructions to set it up https://github.com/google-github-actions/auth#setting-up-workload-identity-federation. Don't worry about making any changes to the actions YAML file, just save the Service Account email and the Workload Identity Provider ID - we'll add those as repository secrets.
Next, add the following repository secrets so Github Actions can access these credentials.
  1. 1.
    GCP_SERVICE_ACCOUNT
  2. 2.
    GCP_WORKLOAD_IDENTITY_PROVIDER
  3. 3.
    ABBEY_TOKEN - API token taken from Settings > API Tokens
You can do this via Github repo page -> Settings -> Secrets and Variables -> Actions -> New Repository Secret and create with the above names.
What should it look like?

Step 5: Deploy Your Starter Kit

To deploy your Starter Kit, follow instructions from Deploy Your Grant Kit.

Step 6: Automate Access Management

🎉
Congratulations! Abbey is now managing permissions to your Resource for you.
🎉
You can now start requesting and approving access by following the Request Access and Approve or Deny Access Requests guides.
Abbey strives to help you automate and secure access management without being intrusive.
To that end, this Pull Request contains native Terraform HCL code using normal open source Terraform Provider libraries. It represents the permissions change. In this case, it's just a simple creation of a new Terraform Resource.
After approving the request, you should be able to see that the user has been added to the google group.
  1. 2.
    Select the group you are adding a member to
  2. 3.
    View members
Finally, this starter kit comes with a time-based policy by default, the user will automatically be removed after 1 hour.

Next Steps

To learn more about what Resources you can configure, try one of our Step-by-Step Tutorials.
For more information on how Abbey works, visit the Key Concepts or Grant Kits page.