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 an AWS VPC
query {
queryawsVpc {
accountId
arn
defaultVpc
dhcpOptionsSet
enableDnsHostnames
enableDnsSupport
id
instanceTenancy
ipV4Cidr
ipV6Cidr
state
alb {
arn
}
eip {
arn
}
elb {
arn
}
igw {
arn
}
tags {
id
key
value
}
nacl {
arn
}
lambda {
arn
}
subnet {
arn
}
natGateway {
arn
}
routeTable {
arn
}
rdsDbInstance {
arn
}
route53HostedZone {
arn
}
}
}
Get data for a single AWS VPC that you know the ID for:
query {
getawsVpc(id: "12345") {
arn
}
}
Get data for a single VPC that you know the ARN for:
query {
getawsVpc(arn: "arn:12345") {
arn
}
}
Get data for all of the VPCs in a certain AWS account:
query {
queryawsVpc(filter: { accountId: { eq: "12345" } }) {
arn
}
}
Get data for all of the VPCs that are NOT in a certain AWS account:
query {
queryawsVpc(filter: { not: { accountId: { eq: "12345" } } }) {
arn
}
}
Get data for all of the VPCs that have Lambdas in them:
query {
queryawsVpc(filter: { has: lambda }) {
arn
}
}
Use multiple filter selectors, (i.e. has, and, not, or) to get data for all of the VPCs that have Lambdas AND RDS DB Instances in them OR that do not have IGWs in them. Note that you can use has, and, not, or completely independently of each other:
query {
queryawsVpc(
filter: {
has: lambda
and: { has: rdsDbInstance }
or: { not: { has: igw } }
}
) {
arn
}
}
You may also filter using a regex when filtering on a string field like, ipV4Cidr if you want to look for a value that matches say, 10.0.0.0:
query {
queryawsVpc(filter: { ipV4Cidr: { regexp: "/.*10.0.0.0.*/" } }) {
arn
}
}
You can order the results you get back either asc or desc depending on your preference:
query {
queryawsVpc(order: { desc: ipV4Cidr }) {
ipV4Cidr
}
}
Only select and return the first two VPCs that are found:
query {
queryawsVpc(first: 2, order: { desc: ipV4Cidr }) {
ipV4Cidr
}
}
Only select and return the first two VPCs that are found, but offset by one so VPCs two & three are returned:
query {
queryawsVpc(first: 2, order: { desc: ipV4Cidr }, offset: 1) {
arn
}
}
Count the number of VPCs across all scanned AWS accounts:
query {
aggregateawsVpc {
count
}
}
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:
query {
aggregateawsVpc(filter: { accountId: { eq: "12345" } }) {
count
}
}
Find the default VPCs across all your scanned AWS Accounts to see if they are being used:
query {
queryawsVpc(filter: { defaultVpc: true }) {
arn
}
}
Find all of the VPCs that have a tag of Environment:Production for a single AWS Account:
query {
queryawsTag(
filter: { key: { eq: "Environment" }, value: { eq: "Production" } }
) {
vpc(filter: { accountId: { eq: "12345" } }) {
arn
}
}
}
With CloudGraph you can run multiple queries at the same time so you can combine the above two queries if you like:
query {
queryawsVpc(filter: { defaultVpc: true }) {
arn
}
queryawsTag(
filter: { key: { eq: "Environment" }, value: { eq: "Production" } }
) {
vpc(filter: { accountId: { eq: "12345" } }) {
arn
}
}
}
When you think, "in terms of a graph", you can do almost anything with CloudGraph. Say for example that you want to know what Lamba 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 Lambda children, you are able to answer this question easily. Simply check to see what lambda functions the VPC is "connected" to, and compare that against the list of all lambda functions like so:
query {
queryawsVpc(filter: { arn: { eq: "arn:12345" } }) {
arn
lambda {
arn
}
}
queryawsLambda {
arn
}
}
Putting it all together; get all data for all VPCs across all regions for all scanned AWS accounts in a single query. For the purposes of this example we will only get direct children of the VPCs but if you want to it's easy to go from say, VPC -> ALB -> EC2 -> EBS...etc:
query {
queryawsVpc {
accountId
arn
defaultVpc
dhcpOptionsSet
enableDnsHostnames
enableDnsSupport
id
instanceTenancy
ipV4Cidr
ipV6Cidr
state
alb {
id
accountId
arn
dnsName
scheme
type
subnets
hostedZone
defaultVpc
ipAddressType
idleTimeout
deletionProtection
http2
accessLogsEnabled
dropInvalidHeaderFields
createdAt
status
tags {
id
key
value
}
securityGroups {
arn
}
ec2Instance {
arn
}
vpc {
arn
}
route53Record {
id
}
listeners {
arn
}
subnet {
arn
}
}
eip {
arn
id
accountId
arn
vpc
domain
publicIp
privateIp
instanceId
publicIpv4Pool
networkInterfaceId
ec2InstanceAssociationId
networkInterfaceOwnerId
networkBorderGroup
customerOwnedIp
customerOwnedIpv4Pool
tags {
id
key
value
}
vpcs {
arn
}
ec2Instance {
arn
}
networkInterface {
arn
}
}
elb {
id
accountId
arn
dnsName
hostedZone
createdAt
type
status
scheme
vpcId
sourceSecurityGroup {
groupName
}
securityGroupsIds
subnets
accessLogs
crossZoneLoadBalancing
idleTimeout
instances {
id
}
healthCheck {
target
}
listeners {
id
}
tags {
id
key
value
}
cloudfrontDistribution {
arn
}
securityGroups {
arn
}
vpc {
arn
}
route53Record {
id
}
subnet {
arn
}
}
igw {
accountId
arn
id
owner
attachments {
vpcId
}
tags {
id
key
value
}
vpc {
arn
}
}
tags {
id
key
value
}
nacl {
id
arn
accountId
default
inboundRules {
id
}
outboundRules {
id
}
associatedSubnets {
id
}
region
tags {
id
key
value
}
vpc {
arn
}
vpcId
}
lambda {
id
accountId
arn
description
handler
kmsKeyArn
lastModified
memorySize
reservedConcurrentExecutions
role
runtime
sourceCodeSize
timeout
tracingConfig
version
environmentVariables {
id
key
value
}
tags {
id
key
value
}
kms {
arn
}
securityGroups {
arn
}
subnet {
arn
}
vpc {
arn
}
cognitoUserPool {
arn
}
}
subnet {
id
accountId
arn
autoAssignPublicIpv4Address
autoAssignPublicIpv6Address
availabilityZone
availableIpV4Addresses
defaultForAz
ipV4Cidr
ipV6Cidr
state
tags {
id
key
value
}
alb {
arn
}
asg {
arn
}
ec2Instance {
arn
}
elb {
arn
}
lambda {
arn
}
natGateway {
arn
}
networkInterface {
arn
}
routeTable {
arn
}
vpc {
arn
}
rdsDbInstance {
arn
}
}
natGateway {
id
accountId
arn
state
createTime
dailyCost {
cost
formattedCost
currency
}
tags {
id
key
value
}
networkInterface {
arn
}
subnet {
arn
}
vpc {
arn
}
}
routeTable {
id
accountId
arn
vpcId
routes {
id
}
mainRouteTable
explicitlyAssociatedWithSubnets
subnetAssociations
tags {
id
key
value
}
subnet {
arn
}
vpc {
arn
}
}
rdsDbInstance {
id
accountId
arn
name
port
address
hostedZoneId
username
resourceId
engine
engineVersion
createdTime
copyTagsToSnapshot
deletionProtection
dBInstanceIdentifier
performanceInsightsEnabled
autoMinorVersionUpgrade
iamDbAuthenticationEnabled
optionsGroups
parameterGroup
storageType
instanceClass
allocatedStorage
multiAZ
subnetGroup
availabilityZone
publiclyAccessible
certificateAuthority
status
failoverPriority
kmsKey
encrypted
tags {
id
key
value
}
cluster {
arn
}
securityGroups {
arn
}
subnet {
arn
}
vpc {
arn
}
}
route53HostedZone {
id
accountId
arn
name
comment
delegationSetId
nameServers
route53Record {
id
}
vpc {
arn
}
}
}
}