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 

Transit 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 Transit Gateway

GraphQL
|
query {
  queryawsTransitGateway{
    id
    accountId
    arn
    region
    ownerId
    description
    dnsSupport
    vpnEcmpSupport
    amazonSideAsn
    autoAcceptSharedAttachments
    defaultRouteTableAssociation
    associationDefaultRouteTableId
    defaultRouteTableAssociation
    propagationDefaultRouteTableId
    tags {
      id
      key
      value
    }
    routeTable {
      arn
      # Other fields and connections here...
    }
    transitGatewayAttachment {
      arn
      # Other fields and connections here...
    }
    vpnConnection {
      arn
      # Other fields and connections here...
    }
  }
}


Filtering

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

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

GraphQL
|
query {
  getawsTransitGateway(arn: "arn:aws:ec2:us-east-1:111122223333:transit-gateway/tgw-11122223333f466ec") {
    arn
    # Other fields and connections here...
  }
}


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

GraphQL
|
query {
  queryawsTransitGateway(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
# ownerId
# description
# dnsSupport
# vpnEcmpSupport
# amazonSideAsn
# autoAcceptSharedAttachments
# defaultRouteTableAssociation
# associationDefaultRouteTableId
# defaultRouteTableAssociation
# propagationDefaultRouteTableId

# And the following Dgraph filters can also be applied:

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


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

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


Advanced Filtering

Get data for all of the Transit Gateways that have a connected transitGatewayAttachment:

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

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

# id
# accountId
# arn
# region
# ownerId
# description
# dnsSupport
# vpnEcmpSupport
# amazonSideAsn
# autoAcceptSharedAttachments
# defaultRouteTableAssociation
# associationDefaultRouteTableId
# defaultRouteTableAssociation
# propagationDefaultRouteTableId
# tags 
# routeTable 
# transitGatewayAttachment 
# vpnConnection


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

GraphQL
|
query {
  queryawsTransitGateway(
    filter: {
      has: transitGatewayAttachment
      and: { has: vpnConnection }
      or: { not: { has: routeTable } }
    }
  ) {
    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 Transit Gateways in us regions:

GraphQL
|
query {
  queryawsTransitGateway(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 {
  queryawsTransitGateway(order: { desc: region }) {
    arn
    # Other fields and connections here...
  }
}

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

# id
# accountId
# arn
# ownerId
# description
# dnsSupport
# vpnEcmpSupport
# amazonSideAsn
# autoAcceptSharedAttachments
# defaultRouteTableAssociation
# associationDefaultRouteTableId
# defaultRouteTableAssociation
# propagationDefaultRouteTableId


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

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


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

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


Aggregation

Count the number Transit Gateways across all scanned AWS accounts:

GraphQL
|
query {
  aggregateawsTransitGateway {
    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 Transit Gateway:

# idMin
# idMax
# accountIdMin
# accountIdMax
# arnMin
# arnMax
# regionMin
# regionMax
# ownerIdMin
# ownerIdMax
# descriptionMin
# descriptionMax
# dnsSupportMin
# dnsSupportMax
# vpnEcmpSupportMin
# vpnEcmpSupportMax
# amazonSideAsnMin
# amazonSideAsnMax
# autoAcceptSharedAttachmentsMin
# autoAcceptSharedAttachmentsMax
# defaultRouteTableAssociationMin
# defaultRouteTableAssociationMax
# associationDefaultRouteTableIdMin
# associationDefaultRouteTableIdMax
# defaultRouteTableAssociationMin
# defaultRouteTableAssociationMax
# propagationDefaultRouteTableIdMin
# propagationDefaultRouteTableIdMax


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

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


Examples

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

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


Kitchen Sink

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

GraphQL
|
query {
  queryawsTransitGateway{
    id
    accountId
    arn
    region
    ownerId
    description
    dnsSupport
    vpnEcmpSupport
    amazonSideAsn
    autoAcceptSharedAttachments
    defaultRouteTableAssociation
    associationDefaultRouteTableId
    defaultRouteTableAssociation
    propagationDefaultRouteTableId
    tags {
      id
      key
      value
    }
    routeTable {
      id
      accountId
      arn
      region
      vpcId
      routes {
        id
        # Other fields and connections here...
      }
      mainRouteTable
      explicitlyAssociatedWithSubnets
      explicitlyAssociatedWithSubnets
      tags {
        id
        key
        value
    	}
      subnet {
        arn
        # Other fields and connections here...
      }
      vpc {
        arn
        # Other fields and connections here...
      }
      transitGateway {
        arn
        # Other fields and connections here...
      }
      transitGatewayAttachment {
        arn
        # Other fields and connections here...
      }   
    }
    transitGatewayAttachment {
      id
      accountId
      arn
      region
      transitGatewayId
      transitGatewayOwnerId
      resourceOwnerId
      resourceType
      resourceId
      state
      transitGatewayRouteTableId
      creationTime
      tags {
        id
        key
        value
    	}
      transitGateway {
        arn
        # Other fields and connections here...
      }
      routeTable {
        arn
        # Other fields and connections here...
      }
      vpc {
        arn
        # Other fields and connections here...
      }
      vpnConnection {
        arn
        # Other fields and connections here...
      }  
    }
    vpnConnection {
      id
      accountId
      arn
      region
      category
      customerGatewayId
      state
      type
      vpnGatewayId
      transitGatewayId
      options {
        id
        enableAcceleration
        staticRoutesOnly
        localIpv4NetworkCidr
        remoteIpv4NetworkCidr
        tunnelInsideIpVersion
        type
        tunnelOptions {
          id
          outsideIpAddress
          tunnelInsideCidr
          preSharedKey
        }
      }
      routes {
        id
        destinationCidrBlock
        source
        state
      }
      vgwTelemetry {
        id
        acceptedRouteCount
        lastStatusChange
        certificateArn
        outsideIpAddress
        status
        statusMessage
      }
      tags {
        id
        key
        value
    	}
      transitGateway {
        arn
        # Other fields and connections here...
      }
      customerGateway {
        arn
        # Other fields and connections here...
      }
      vpnGateway {
        arn
        # Other fields and connections here...
      }
      transitGatewayAttachment {
        arn
        # Other fields and connections here...
      }
    }
  }
}


References

Dgraph documentation on querying

AWS Transit Gateway documentation

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