Subnet
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.
You can currently query the following attributes and connections on a GCP Subnet
query { querygcpSubnet { 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... } } }
Get data for a single GCP Subnet that you know the ID for:
query { getgcpSubnet(id: "12345") { id # Other fields and connections here... } }
Get data for all of the Subnets in a certain GCP project:
query { querygcpSubnet(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 # kind # creationTimestamp # description # enableFlowLogs # fingerprint # gatewayAddress # ipCidrRange # ipv6CidrRange # privateIpGoogleAccess # privateIpv6GoogleAccess # purpose # role # selfLink # state # 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 Subnets that are NOT in a certain GCP project:
query { querygcpSubnet(filter: { not: { projectId: { eq: "12345" } } }) { id # Other fields and connections here... } }
Get data for all of the Subnets that have CIDR Ranges:
query { querygcpSubnet(filter: { has: ipCidrRange }) { id # Other fields and connections here... } } # Note that in addition to "ipCidrRange" you can filter # Using "has" based on any of the following attributes: # id # projectId # region # name # labels # creationTimestamp # description # enableFlowLogs # fingerprint # gatewayAddress # ipCidrRange # ipv6CidrRange # kind # logConfig # privateIpGoogleAccess # privateIpv6GoogleAccess # purpose # role # secondaryIpRanges # selfLink # state # project # network # vpcConnectors # vmInstances # aiPlatformNotebooks # CISFindings
Use multiple filter selectors, (i.e. has, and, not, or). Note that you can use has, and, not, or completely independently of each other:
query { querygcpSubnet( filter: { has: network and: { has: vpcConnectors } or: { not: { has: network } } } ) { projectId # 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:
query { querygcpSubnet(filter: { ipCidrRange: { regexp: "/.*10.0.0.0.*/" } }) { projectId # Other fields and connections here... } }
You can order the results you get back either asc or desc depending on your preference:
query { querygcpSubnet(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 # kind # creationTimestamp # description # enableFlowLogs # fingerprint # gatewayAddress # ipCidrRange # ipv6CidrRange # kind # privateIpGoogleAccess # privateIpv6GoogleAccess # purpose # role # selfLink # state
Only select and return the first two Subnets that are found:
query { querygcpSubnet(first: 2, order: { desc: ipCidrRange }) { ipCidrRange # Other fields and connections here... } }
Only select and return the first two Subnets that are found, but offset by one so Subnets two & three are returned:
query { querygcpSubnet(first: 2, order: { desc: ipCidrRange }, offset: 1) { projectId # Other fields and connections here... } }
Count the number of Subnets across all scanned GCP projects:
query { aggregategcpSubnet { count # Other fields and connections here... } }
Count the number of Subnets in a single project. Note that you can apply all of the same filters that are listed above to aggregate queries:
query { aggregategcpSubnet(filter: { projectId: { eq: "12345" } }) { count # Other fields and connections here... } }
Get the Networks for a given Subnet using advanced filtering:
query { querygcpSubnet( 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:
query { querygcpSubnet(filter: { region: { regexp: "/.*us-east*./" } }) { region # Other fields and connections here... } querygcpTag( filter: { key: { eq: "Environment" }, value: { eq: "Production" } } ) { subnet(filter: { projectId: { eq: "12345" } }) { projectId # Other fields and connections here... } } }
Putting it all together; get all data for all Subnets across all regions for all scanned GCP projects in a single query. For the purposes of this example we will only get direct children of the Subnets:
query { querygcpSubnet { 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 { 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... } } vpcConnectors { 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... } } vmInstances { id projectId region name kind labels { id key value } advancedMachineFeatures { enableNestedVirtualization threadsPerCore } canIpForward confidentialInstanceConfig { enableConfidentialCompute } cpuPlatform creationTimestamp deletionProtection description disks { id autoDelete boot deviceName diskEncryptionKey { kmsKeyName kmsKeyServiceAccount rawKey sha256 } diskSizeGb guestOsFeatures { id type } index initializeParams { description diskName diskSizeGb diskType labels { id key value } onUpdateAction provisionedIops resourcePolicies sourceImage sourceImageEncryptionKey { kmsKeyName kmsKeyServiceAccount rawKey sha256 } sourceSnapshot sourceSnapshotEncryptionKey { kmsKeyName kmsKeyServiceAccount rawKey sha256 } } interface kind licenses mode shieldedInstanceInitialState { dbs { id content fileType } dbxs { id content fileType } keks { id content fileType } pk { id content fileType } } source type } displayDevice { enableDisplay } fingerprint guestAccelerators { id acceleratorCount acceleratorType } hostname kind labelFingerprint labels { id key value } lastStartTimestamp lastStopTimestamp lastSuspendedTimestamp machineType metadata { fingerprint items { id key value } kind } minCpuPlatform networkInterfaces { id accessConfigs { id kind name natIP networkTier publicPtrDomainName setPublicPtr type } aliasIpRanges { id ipCidrRange subnetworkRangeName } fingerprint ipv6Address kind name network networkIP nicType subnetwork } privateIpv6GoogleAccess reservationAffinity { consumeReservationType key values } resourcePolicies satisfiesPzs scheduling { automaticRestart locationHint minNodeCpus nodeAffinities { id key operator values } onHostMaintenance preemptible } selfLink serviceAccounts { id email scopes } shieldedInstanceConfig { enableIntegrityMonitoring enableSecureBoot enableVtpm } shieldedInstanceIntegrityPolicy { updateAutoLearnPolicy } startRestricted status statusMessage tags { fingerprint items } zone project { name # Other fields and connections here... } network { name # Other fields and connections here... } subnet { name # Other fields and connections here... } } } }