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 Subnet
query {
queryawsSubnet {
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
}
}
}
Get data for a single AWS Subnet that you know the ID for:
query {
getawsSubnet(id: "12345") {
arn
}
}
Get data for all of the Subnets in a certain AWS account:
query {
queryawsSubnet(filter: { accountId: { eq: "12345" } }) {
arn
}
}
Get data for all of the Subnets that are NOT in a certain AWS account:
query {
queryawsSubnet(filter: { not: { accountId: { eq: "12345" } } }) {
arn
}
}
Get data for all of the Subnets that have EC2 Instances in them:
query {
queryawsSubnet(filter: { has: ec2Instance }) {
arn
}
}
Use multiple filter selectors, (i.e. has, and, not, or) to get data for all of the Subnets that have EC2 Instances AND RDS DB Instances in them OR that do not have NATs in them. Note that you can use has, and, not, or completely independently of each other:
query {
queryawsSubnet(
filter: {
has: ec2Instance
and: { has: rdsDbInstance }
or: { not: { has: natGateway } }
}
) {
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 {
queryawsSubnet(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 {
queryawsSubnet(order: { desc: ipV4Cidr }) {
ipV4Cidr
}
}
Only select and return the first two Subnets that are found:
query {
queryawsSubnet(first: 2, order: { desc: ipV4Cidr }) {
ipV4Cidr
}
}
Only select and return the first two Subnets that are found, but offset by one so Subnets two & three are returned:
query {
queryawsSubnet(first: 2, order: { desc: ipV4Cidr }, offset: 1) {
arn
}
}
Count the number of Subnets across all scanned AWS accounts:
query {
aggregateawsSubnet {
count
}
}
Count the number of Subnets in a single account. Note that you can apply all of the same filters that are listed above to aggregate queries:
query {
aggregateawsSubnet(filter: { accountId: { eq: "12345" } }) {
count
}
}
Find all of the Subnets that are in various AZs in the us-east-1 region across all your accounts:
query {
queryawsSubnet(filter: { availabilityZone: { regexp: "/.*us-east-1*./" } }) {
availabilityZone
}
}
Find all of the Subnets that have a tag of Environment:Production for a single AWS Account:
query {
queryawsTag(
filter: { key: { eq: "Environment" }, value: { eq: "Production" } }
) {
subnet(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 {
queryawsSubnet(filter: { availabilityZone: { regexp: "/.*us-east-1*./" } }) {
availabilityZone
}
queryawsTag(
filter: { key: { eq: "Environment" }, value: { eq: "Production" } }
) {
subnet(filter: { accountId: { eq: "12345" } }) {
arn
}
}
}
Putting it all together; get all data for all Subnets 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 Subnets but if you want to it's easy to go from say, Subnets -> EC2 -> EBS...etc:
query {
queryawsSubnet {
id
accountId
arn
autoAssignPublicIpv4Address
autoAssignPublicIpv6Address
availabilityZone
availableIpV4Addresses
defaultForAz
ipV4Cidr
ipV6Cidr
state
tags {
id
key
value
}
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
}
}
asg {
id
accountId
arn
name
region
launchConfigurationName
launchTemplateId
launchTemplateName
launchTemplateVersion
mixedInstancesPolicy {
launchTemplateId
}
minSize
maxSize
desiredCapacity
predictedCapacity
cooldown
availabilityZones
loadBalancerNames
targetGroupARNs
healthCheckType
healthCheckGracePeriod
ec2InstanceIds
suspendedProcesses {
id
}
placementGroup
vpcZoneIdentifier
enabledMetrics {
id
}
status
terminationPolicies
newInstancesProtectedFromScaleIn
serviceLinkedRoleARN
maxInstanceLifetime
capacityRebalanceEnabled
warmPoolConfigMaxGroupPreparedCapacity
warmPoolConfigMinSize
warmPoolConfigPoolState
warmPoolConfigStatus
warmPoolSize
context
tags {
id
key
value
}
launchConfiguration {
imageId
}
ec2Instance {
arn
}
securityGroups {
arn
}
ebs {
arn
}
subnet {
arn
}
}
ec2Instance {
id
accountId
arn
region
ami
tenancy
elasticIps
publicDns
privateDns
monitoring
privateIps
keyPair {
id
name
fingerprint
}
cpuCoreCount
hibernation
ebsOptimized
ipv4PublicIp
instanceType
ipv6Addresses
placementGroup
instanceState
sourceDestCheck
availabilityZone
cpuThreadsPerCore
iamInstanceProfile
deletionProtection
dailyCost {
cost
currency
formattedCost
}
primaryNetworkInterface
metadataOptions {
state
}
metadatasecurityGroupIdsOptions
securityGroupIds
ephemeralBlockDevices {
deviceName
}
tags {
id
key
value
}
alb {
arn
}
asg {
arn
}
ebs {
arn
}
eip {
arn
}
networkInterfaces {
arn
}
securityGroups {
arn
}
subnet {
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
}
}
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
}
}
natGateway {
id
accountId
arn
state
createTime
dailyCost {
cost
formattedCost
currency
}
tags {
id
key
value
}
networkInterface {
arn
}
subnet {
arn
}
vpc {
arn
}
}
networkInterface {
id
accountId
arn
subnetId
macAddress
description
availabilityZone
status
vpcId
interfaceType
securityGroups
privateDnsName
privateIps
attachment {
id
}
tags {
id
key
value
}
ec2Instance {
arn
}
eip {
arn
}
natGateway {
arn
}
subnet {
arn
}
vpc {
arn
}
}
routeTable {
id
accountId
arn
vpcId
routes {
id
}
mainRouteTable
explicitlyAssociatedWithSubnets
subnetAssociations
tags {
id
key
value
}
subnet {
arn
}
vpc {
arn
}
}
vpc {
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
}
}
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
}
}
}
}