website logo
HomeGithubSlack
⌘K
Overview
Quick Start
Supported Services
Running CloudGraph in EKS
Compliance
Rules Engine
AWS
Querying AWS Data
AWS Policy Packs
Billing Data
Services
Azure
Querying Azure Data
Azure Policy Packs
Services
GCP
Querying GCP Data
GCP Policy Packs
Services
K8s
Querying Kubernetes Data
Services
Docs powered by archbee 

VPC Connector

18min

Note: if you are running CloudGraph locally you can view the interactive, automatically generated documentation in either GraphQL Playground or Altair by clicking the docs button on the right-hand side of the screen. After reading the below information we highly suggest you use one of these tools to test your queries as they will autocomplete fields for you and let you know if your queries are valid before you even submit them.

Overview

You can currently query the following attributes and connections on an GCP VPC

GraphQL
|
query {
  querygcpVpcConnector {
    id
    projectId
    region
    name
    ipCidrRange
    state
    minThroughput
    maxThroughput
    connectedProjects
    cloudFunctions {
      name
      # Other fields and connections here...
    }
    project {
      name
      # Other fields and connections here...
    }
    network {
      name
      # Other fields and connections here...
    }
    subnets {
      name
      # Other fields and connections here...
    }
  }
}


Filtering

Get data for a single GCP VPC that you know the ID for:

GraphQL
|
query {
  getgcpVpcConnector(id: "12345") {
    id
    # Other fields and connections here...
  }
}


Get data for all of the VPCs in a GCP project:

GraphQL
|
query {
  querygcpVpcConnector(filter: { projectId: { eq: "12345" } }) {
    id
    # Other fields and connections here...
  }
}

# Note that in addition to "projectId" you can
# Filter based on any of the following attributes:

# id
# projectId
# region
# name
# ipCidrRange
# state
# minThroughput
# maxThroughput
# connectedProjects

# And the following Dgraph filters can also be applied:

# has
# and
# or
# not
# regexp (regular expressions)

# fulltext filters

# alloftext
# anyoftext


Get data for all of the VPCs that are NOT in a GCP project:

GraphQL
|
query {
  querygcpVpcConnector(filter: { not: { projectId: { eq: "12345" } } }) {
    id
    # Other fields and connections here...
  }
}


Advanced Filtering

Get data for all of the VPCs that have cloud functions in them:

GraphQL
|
query {
  querygcpVpcConnector(filter: { has: cloudFunctions }) {
    id
    # Other fields and connections here...
  }
}

# Note that in addition to "cloudFunctions" you can filter
# Using "has" based on any of the following attributes:

# id
# projectId
# region
# name
# ipCidrRange
# state
# minThroughput
# maxThroughput
# connectedProjects
# cloudFunctions
# project
# network
# subnets
# CISFindings


Use multiple filter selectors, (i.e. has, and, not, or) to get data for all of the VPCs that have cloud functions AND subnets in them OR that do not have networks in them. Note that you can use has, and, not, or completely independently of each other:

GraphQL
|
query {
  querygcpVpcConnector(
    filter: {
      has: cloudFunction
      and: { has: subnet }
      or: { not: { has: network } }
    }
  ) {
    id
    # Other fields and connections here...
  }
}


You may also filter using a regex when filtering on a string field like, ipCidrRange if you want to look for a value that matches say, 10.0.0.0:

GraphQL
|
query {
  querygcpVpcConnector(filter: { ipCidrRange: { regexp: "/.*10.0.0.0.*/" } }) {
    id
    # Other fields and connections here...
  }
}


Ordering

You can order the results you get back either asc or desc depending on your preference:

GraphQL
|
query {
  querygcpVpcConnector(order: { desc: ipCidrRange }) {
    ipCidrRange
    # Other fields and connections here...
  }
}

# Note that in addition to "ipCidrRange" you can filter
# Using "asc" or "desc" based on any of the following attributes:

# id
# projectId
# region
# name
# ipCidrRange
# state
# minThroughput
# maxThroughput
# connectedProjects


Only select and return the first two VPCs that are found:

GraphQL
|
query {
  querygcpVpcConnector(first: 2, order: { desc: ipCidrRange }) {
    ipCidrRange
    # Other fields and connections here...
  }
}


Only select and return the first two VPCs that are found, but offset by one so VPCs two & three are returned:

GraphQL
|
query {
  querygcpVpcConnector(first: 2, order: { desc: ipCidrRange }, offset: 1) {
    id
    # Other fields and connections here...
  }
}


Aggregation

Count the number of VPCs across all scanned GCP accounts:

GraphQL
|
query {
  aggregategcpVpcConnector {
    count
    # Other fields and connections here...
  }
}


Count the number of VPCs in a single account. Note that you can apply all of the same filters that are listed above to aggregate queries:

GraphQL
|
query {
  aggregategcpVpcConnector(filter: { projectId: { eq: "12345" } }) {
    count
    # Other fields and connections here...
  }
}


Examples

Get the Networks for a given VPC using advanced filtering:

GraphQL
|
query {
  querygcpVpcConnector(
    filter: {
      projectId: { eq: "12345" }
      name: { regexp: "/.*name-of-project*/" }
      has: network
    }
  ) {
    network {
      id
      # Other fields and connections here...
    }
  }
}


With CloudGraph you can run multiple queries at the same time so you can combine the above two queries if you like:

GraphQL
|
query {
  aggregategcpSubnet(filter: { region: { eq: "sometime" } }) {
    count
    # Other attributes and connections here...
  }
  querygcpSubnet(
    filter: {
      projectId: { eq: "12345" }
      name: { regexp: "/.*name-of-project*/" }
      has: network
    }
  ) {
    network {
      id
      # Other fields and connections here...
    }
  }
}


When you think, "in terms of a graph", you can do almost anything with CloudGraph. Say for example that you want to know what cloud functions don't belong to a VPC (i.e. they don't leverage VPC networking). Because CloudGraph connects all resources that have relationships, such as VPC parents to their cloud function children, you are able to answer this question easily. Simply check to see what cloud functions the VPC is "connected" to, and compare that against the list of all cloud functions like so:

GraphQL
|
query {
  querygcpVpcConnector(filter: { id: { eq: "id:12345" } }) {
    id
    cloudFunctions {
      id
    }
  }
  querygcpCloudFunction {
    id
  }
}


Kitchen Sink

Putting it all together; get all data for all VPCs across all regions for all scanned GCP accounts in a single query. For the purposes of this example we will only get direct children of the VPCs:

GraphQL
|
query {
  querygcpVpcConnector {
    id
    projectId
    region
    name
    ipCidrRange
    state
    minThroughput
    maxThroughput
    connectedProjects
    cloudFunctions {
      id
      projectId
      region
      name
      kind
      labels {
        id
        key
        value
      }
      description
      sourceArchiveUrl
      sourceRepository {
        url
        deployedUrl
      }
      sourceUploadUrl
      httpsTrigger {
        url
        securityLevel
      }
      eventTrigger {
        eventType
        resource
        service
      }
      status
      entryPoint
      runtime
      timeout {
        seconds
        nanos
      }
      availableMemoryMb
      serviceAccountEmail
      updateTime
      versionId
      labels {
        id
        key
        value
      }
      environmentVariables {
        id
        key
        value
      }
      maxInstances
      vpcConnectorEgressSettings
      ingressSettings
      buildId
      project {
        name
        # Other fields and connections here...
      }
      vpcConnectors {
        name
        # Other fields and connections here...
      }
    }
    project {
      id
      name
      parent
      projectId
      state
      displayName
      createTime
      updateTime
      deleteTime
      etag
      labels {
        id
        key
        value
      }
      alertPolicies {
        name
        # Other fields and connections here...
      }
      apiKeys {
        name
        # Other fields and connections here...
      }
      cloudFunctions {
        name
        # Other fields and connections here...
      }
      computeProject {
        name
        # Other fields and connections here...
      }
      dnsManagedZones {
        name
        # Other fields and connections here...
      }
      dnsPolicies {
        name
        # Other fields and connections here...
      }
      bigQueryDataset {
        name
        # Other fields and connections here...
      }
      bigQueryConnection {
        name
        # Other fields and connections here...
      }
      bigQueryReservation {
        name
        # Other fields and connections here...
      }
      bigQueryReservationCapacityCommitment {
        name
        # Other fields and connections here...
      }
      bigQueryDataTransfer {
        name
        # Other fields and connections here...
      }
      bigQueryDataTransferRun {
        name
        # Other fields and connections here...
      }
      vpcConnectors {
        name
        # Other fields and connections here...
      }
      kmsKeyRing {
        name
        # Other fields and connections here...
      }
      cloudRouters {
        name
        # Other fields and connections here...
      }
      iamPolicies {
        id
        # Other fields and connections here...
      }
      logBuckets {
        name
        # Other fields and connections here...
      }
      logMetrics {
        name
        # Other fields and connections here...
      }
      logViews {
        name
        # Other fields and connections here...
      }
      logSinks {
        name
        # Other fields and connections here...
      }
      storageBuckets {
        name
        # Other fields and connections here...
      }
      firewalls {
        name
        # Other fields and connections here...
      }
      folder {
        name
        # Other fields and connections here...
      }
      organization {
        name
        # Other fields and connections here...
      }
      secrets {
        name
        # Other fields and connections here...
      }
      sslPolicies {
        name
        # Other fields and connections here...
      }
      networks {
        name
        # Other fields and connections here...
      }
      subnets {
        name
        # Other fields and connections here...
      }
      targetSslProxies {
        name
        # Other fields and connections here...
      }
      targetHttpsProxies {
        name
        # Other fields and connections here...
      }
      vmInstances {
        name
        # Other fields and connections here...
      }
      assets {
        name
        # Other fields and connections here...
      }
      sqlInstances {
        name
        # Other fields and connections here...
      }
      serviceAccounts {
        name
        # Other fields and connections here...
      }
      kmsCryptoKeys {
        name
        # Other fields and connections here...
      }
      dataprocClusters {
        name
        # Other fields and connections here...
      }
      dataprocAutoscalingPolicies {
        name
        # Other fields and connections here...
      }
      dataprocJobs {
        name
        # Other fields and connections here...
      }
      dataprocWorkflowTemplates {
        name
        # Other fields and connections here...
      }
    }
    network {
      id
      projectId
      region
      name
      kind
      labels {
        id
        key
        value
      }
      ipV4Range
      autoCreateSubnetworks
      creationTimestamp
      description
      gatewayIPv4
      kind
      mtu
      peerings {
        id
        autoCreateRoutes
        exchangeSubnetRoutes
        exportCustomRoutes
        exportSubnetRoutesWithPublicIp
        importCustomRoutes
        importSubnetRoutesWithPublicIp
        name
        network
        peerMtu
        state
        stateDetails
      }
      routingConfig {
        routingMode
      }
      selfLink
      dnsPolicies {
        name
        # Other fields and connections here...
      }
      firewalls {
        name
        # Other fields and connections here...
      }
      project {
        name
        # Other fields and connections here...
      }
      sqlInstances {
        name
        # Other fields and connections here...
      }
      subnets {
        name
        # Other fields and connections here...
      }
      vpcConnectors {
        name
        # Other fields and connections here...
      }
      vmInstances {
        name
        # Other fields and connections here...
      }
      cloudRouters {
        name
        # Other fields and connections here...
      }
    }
    subnets {
      id
      projectId
      region
      name
      kind
      labels {
        id
        key
        value
      }
      creationTimestamp
      description
      enableFlowLogs
      fingerprint
      gatewayAddress
      ipCidrRange
      ipv6CidrRange
      kind
      logConfig {
        aggregationInterval
        enable
        filterExpr
        flowSampling
        metadata
        metadataFields
      }
      privateIpGoogleAccess
      privateIpv6GoogleAccess
      purpose
      role
      secondaryIpRanges {
        id
        ipCidrRange
        rangeName
      }
      selfLink
      state
      project {
        displayName
        # Other fields and connections here...
      }
      network {
        name
        # Other fields and connections here...
      }
      vpcConnectors {
        name
        # Other fields and connections here...
      }
      vmInstances {
        name
        # Other fields and connections here...
      }
    }
  }
}


References

GCP VPC documentation

Dgraph documentation on querying

Updated 03 Mar 2023
Did this page help you?
Yes
No
PREVIOUS
VM Instance
NEXT
Subnet
Docs powered by archbee 
TABLE OF CONTENTS
Overview
Filtering
Advanced Filtering
Ordering
Aggregation
Examples
Kitchen Sink
References