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
AWS
Services

NAT Gateway

17min

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 AWS NAT Gateway

GraphQL
|
query {
  queryawsNatGateway {
    id
    accountId
    arn
    region
    state
    createTime
    dailyCost {
      cost
      currency
      formattedCost
    }
    tags {
      id
      key
      value
    }
    networkInterface {
      arn
      # Other fields and connections here...
    }
    subnet {
      arn
      # Other fields and connections here...
    }
    vpc {
      arn
      # Other fields and connections here...
    }
  }
}


Filtering

Get data for a single AWS NAT Gateway that you know the ID or arn for:

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

GraphQL
|
query {
  getawsNatGateway(arn: "arn:aws:ec2:us-east-1:111122223333:natgateway/nat-11122223333f466ec") {
    arn
    # Other fields and connections here...
  }
}


Get data for all of the NAT Gateways in a certain AWS account:

GraphQL
|
query {
  queryawsNatGateway(filter: { accountId: { eq: "12345" } }) {
    arn
    # Other fields and connections here...
  }
}

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

# id
# arn
# region
# state
# createTime

# And the following Dgraph filters can also be applied:

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


Get data for all of the NAT Gateways that are NOT in a certain AWS account:

GraphQL
|
query {
  queryawsNatGateway(filter: { not: { accountId: { eq: "12345" } } }) {
    arn
    # Other fields and connections here...
  }
}


Advanced Filtering

Get data for all of the NAT Gateways that have a connected subnet:

GraphQL
|
query {
  queryawsNatGateway(filter: { has: subnet }) {
    arn
    # Other fields and connections here...
  }
}

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

# state
# createTime
# dailyCost
# tags
# networkInterface
# vpc


Use multiple filter selectors, (i.e. has, and, not, or) to get data for all of the NAT Gateways that have subnet instances AND vpc instances connected to them OR that do not have networkInterface instances connected to them. Note that you can use has, and, not, or completely independently of each other:

GraphQL
|
query {
  queryawsNatGateway(
    filter: {
      has: subnet
      and: { has: vpc }
      or: { not: { has: networkInterface } }
    }
  ) {
    arn
    # Other fields and connections here...
  }
}


You may also filter using a regex when filtering on a string field like, region if you want to look for a value that matches say, us- to get all NAT Gateways in us regions:

GraphQL
|
query {
  queryawsNatGateway(filter: { region: { regexp: "/.*us-*/" } }) {
    arn
    # Other fields and connections here...
  }
}


Ordering

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

GraphQL
|
query {
  queryawsNatGateway(order: { desc: createTime }) {
    arn
    # Other fields and connections here...
  }
}

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

# id
# accountId
# arn
# region
# state
# createTime


Only select and return the first two NAT Gateways that are found:

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


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

GraphQL
|
query {
  queryawsNatGateway(first: 2, order: { desc: createTime }, offset: 1) {
    arn
    # Other fields and connections here...
  }
}


Aggregation

Count the number NAT Gateways across all scanned AWS accounts:

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

# Note that in addition to "count" you can request the
# Following min and max values based on attributes of your NAT Gateways:

# idMin
# idMax
# accountIdMin
# accountIdMax
# arnMin
# arnMax
# regionMin
# regionMax
# stateMin
# stateMax
# createTimeMin
# createTimeMax


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

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


Examples

Find all of the NAT Gateways that are in the us-east-1 region across all your accounts:

GraphQL
|
query {
  queryawsNatGateway(filter: { region: { eq: "us-east-1" } }) {
    arn
    # Other fields and connections here...
  }
}


Kitchen Sink

Putting it all together; get all data for all NAT Gateways 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 gateways but if you want to it's easy to go from say, gateway -> vpc -> routeTable ...etc:

GraphQL
|
query {
  queryawsNatGateway {
    id
    accountId
    arn
    region
    state
    createTime
    dailyCost {
      cost
      currency
      formattedCost
    }
    networkInterface {
      id
      accountId
      arn
      region
      subnetId
      macAddress
      description
      availabilityZone
      status
      vpcId
      interfaceType
      securityGroups
      privateDnsName
      privateIps
      attachment {
        id
        attachmentId
        deleteOnTermination
        status
      }
      tags {
        id
        key
        value
      }
      ec2Instance {
        arn
        # Other fields and connections here...
      }
      eip {
        arn
        # Other fields and connections here...
      }
      natGateway {
        arn
        # Other fields and connections here...
      }
      subnet {
        arn
        # Other fields and connections here...
      }
      vpc {
        arn
        # Other fields and connections here...
      }
    }
    subnet {
      id
      accountId
      arn
      region
      autoAssignPublicIpv4Address
      autoAssignPublicIpv6Address
      availabilityZone
      availableIpV4Addresses
      defaultForAz
      ipV4Cidr
      ipV6Cidr
      state
      tags {
        id
        key
        value
      }
      alb {
        arn
        # Other fields and connections here...
      }
      asg {
        arn
        # Other fields and connections here...
      }
      ec2Instance {
        arn
        # Other fields and connections here...
      }
      elb {
        arn
        # Other fields and connections here...
      }
      lambda {
        arn
        # Other fields and connections here...
      }
      natGateway {
        arn
        # Other fields and connections here...
      }
      networkInterface {
        arn
        # Other fields and connections here...
      }
      routeTable {
        arn
        # Other fields and connections here...
      }
      vpc {
        arn
        # Other fields and connections here...
      }
      rdsDbInstance {
        arn
        # Other fields and connections here...
      }
      eksCluster {
        arn
        # Other fields and connections here...
      }
      ecsService {
        arn
        # Other fields and connections here...
      }
    }
    vpc {
      id
      accountId
      arn
      region
      defaultVpc
      dhcpOptionsSet
      enableDnsHostnames
      enableDnsSupport
      instanceTenancy
      ipV4Cidr
      ipV6Cidr
      state
      tags {
        id
        key
        value
      }
      alb {
        arn
        # Other fields and connections here...
      }
      eip {
        arn
        # Other fields and connections here...
      }
      igw {
        arn
        # Other fields and connections here...
      }
      lambda {
        arn
        # Other fields and connections here...
      }
      nacl {
        arn
        # Other fields and connections here...
      }
      natGateway {
        arn
        # Other fields and connections here...
      }
      networkInterface {
        arn
        # Other fields and connections here...
      }
      rdsDbInstance {
        arn
        # Other fields and connections here...
      }
      redshiftCluster {
        arn
        # Other fields and connections here...
      }
      route53HostedZone {
        arn
        # Other fields and connections here...
      }
      routeTable {
        arn
        # Other fields and connections here...
      }
      subnet {
        arn
        # Other fields and connections here...
      }
      eksCluster {
        arn
        # Other fields and connections here...
      }
      ecsService {
        arn
        # Other fields and connections here...
      }
    }
  }
}


References

Dgraph documentation on querying

AWS NAT Gateway documentation

Updated 03 Mar 2023
Did this page help you?
PREVIOUS
Lambda
NEXT
Network ACL
Docs powered by
Archbee
TABLE OF CONTENTS
Overview
Filtering
Advanced Filtering
Ordering
Aggregation
Examples
Kitchen Sink
References
Docs powered by
Archbee