Skip to content

Instantly share code, notes, and snippets.

@calum-github
Created May 20, 2021 04:34
Show Gist options
  • Save calum-github/800592ceead32bb6695b4c2c1482eeea to your computer and use it in GitHub Desktop.
Save calum-github/800592ceead32bb6695b4c2c1482eeea to your computer and use it in GitHub Desktop.
# Create a conditional IAM rule that grants access to establish an IAP tunnel
# IF the user is connecting from an authorised network defined in the access
# list
resource "google_iap_tunnel_iam_member" "allow-remote-access-to-iap" {
project = "<your-project-id>"
role = "roles/iap.tunnelResourceAccessor"
member = "user:calum.hunter@the.cloud"
condition {
title = "allow_remote_access_to_iap"
description = "Allow access to IAP tunnel for authorized users"
expression = "\"accessPolicies/<access-policy-id>/accessLevels/<my-access-level-name>\" in request.auth.access_levels"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment