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

RDS Db Instance

18min

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 RDS DB Instance

GraphQL
|
query {
  queryawsRdsDbInstance {
    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
      # Other fields and connections here...
    }
    securityGroups {
      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 RDS DB Instance that you know the ARN for:

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


Get data for all of the RDS DB Instances in a certain AWS account:

GraphQL
|
query {
  queryawsRdsDbInstance(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
# name
# port
# address
# hostedZoneId
# username
# resourceId
# engine
# engineVersion
# createdTime
# copyTagsToSnapshot
# deletionProtection
# dBInstanceIdentifier
# performanceInsightsEnabled
# autoMinorVersionUpgrade
# iamDbAuthenticationEnabled
# storageType
# instanceClass
# allocatedStorage
# multiAZ
# subnetGroup
# availabilityZone
# publiclyAccessible
# certificateAuthority
# status
# failoverPriority
# kmsKey
# encrypted

# 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 RDS DB Instances that are NOT in a certain AWS account:

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


Advanced Filtering

Get data for all of the RDS DB Instances that are part of clusters:

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

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

# 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
# securityGroups
# subnet
# vpc


Use multiple filter selectors, (i.e. has, and, not, or) to get data for all of the RDS DB Instances that have Tags AND are part of a cluster OR that do not have a Parameter Group. Note that you can use has, and, not, or completely independently of each other:

GraphQL
|
query {
  queryawsRdsDbInstance(
    filter: {
      has: tags
      and: { has: cluster }
      or: { not: { has: parameterGroup } }
    }
  ) {
    arn
    # Other fields and connections here...
  }
}


You may also filter using a regex when filtering on a string field like, engineVersion if you want to look for a value that matches say, 11.1:

GraphQL
|
query {
  queryawsRdsDbInstance(filter: { engineVersion: { regexp: "/.*11.1.*/" } }) {
    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 {
  queryawsRdsDbInstance(order: { desc: engineVersion }) {
    engineVersion
    # Other fields and connections here...
  }
}

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

# id
# accountId
# arn
# name
# port
# address
# hostedZoneId
# username
# resourceId
# engine
# engineVersion
# createdTime
# dBInstanceIdentifier
# optionsGroups
# parameterGroup
# storageType
# instanceClass
# allocatedStorage
# subnetGroup
# availabilityZone
# certificateAuthority
# status
# failoverPriority
# kmsKey


Only select and return the first two RDS DB Instances that are found:

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


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

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


Aggregation

Count the number RDS DB Instances across all scanned AWS accounts:

GraphQL
|
query {
  aggregateawsRdsDbInstance {
    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 RDS DB Instances:

# idMin
# idMax
# accountIdMin
# accountIdMax
# arnMin
# arnMax
# nameMin
# nameMax
# portMin
# portMax
# portSum
# portAvg
# addressMin
# addressMax
# hostedZoneIdMin
# hostedZoneIdMax
# usernameMin
# usernameMax
# resourceIdMin
# resourceIdMax
# engineMin
# engineMax
# engineVersionMin
# engineVersionMax
# createdTimeMin
# createdTimeMax
# dBInstanceIdentifierMin
# dBInstanceIdentifierMax
# optionsGroupsMin
# optionsGroupsMax
# parameterGroupMin
# parameterGroupMax
# storageTypeMin
# storageTypeMax
# instanceClassMin
# instanceClassMax
# allocatedStorageMin
# allocatedStorageMax
# allocatedStorageSum
# allocatedStorageAvg
# subnetGroupMin
# subnetGroupMax
# availabilityZoneMin
# availabilityZoneMax
# certificateAuthorityMin
# certificateAuthorityMax
# statusMin
# statusMax
# failoverPriorityMin
# failoverPriorityMax
# failoverPrioritySum
# failoverPriorityAvg
# kmsKeyMin
# kmsKeyMax


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

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


Examples

For each Aurora Postgres RDS DB Instance running on Postgres version 11.x that has a r5 instance class in AWS Account 12345, get the encryption status and check to see if the database is publicly accessible:

GraphQL
|
query {
  queryawsRdsDbInstance(
    filter: {
      accountId: { eq: "12345" }
      engine: { eq: "aurora-postgresql" }
      engineVersion: { regexp: "/^11.*/" }
      instanceClass: { regexp: "/r5/" }
    }
  ) {
    arn
    encrypted
    publiclyAccessible
  }
}


Find all of the RDS DB Instances that have a tag of Environment:Production for a single AWS Account:

GraphQL
|
query {
  queryawsTag(
    filter: { key: { eq: "Environment" }, value: { eq: "Production" } }
  ) {
    rdsDbInstance(filter: { accountId: { eq: "12345" } }) {
      arn
      # 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:

GraphQL
|
query {
  queryawsRdsDbInstance(
    filter: {
      accountId: { eq: "12345" }
      engine: { eq: "aurora-postgresql" }
      engineVersion: { regexp: "/^11.*/" }
      instanceClass: { regexp: "/r5/" }
    }
  ) {
    arn
    encrypted
    publiclyAccessible
  }
  queryawsTag(
    filter: { key: { eq: "Environment" }, value: { eq: "Production" } }
  ) {
    rdsDbInstance(filter: { accountId: { eq: "12345" } }) {
      arn
      # Other fields and connections here...
    }
  }
}


Kitchen Sink

Putting it all together; get all data for all RDS DB Instances 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 RDS DB Instances but if you want to it's easy to go from say, RDS DB Instance -> Subnet -> VPC...etc:

GraphQL
|
query {
  queryawsRdsDbInstance {
    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 {
      id
      accountId
      arn
      allocatedStorage
      backupRetentionPeriod
      characterSetName
      databaseName
      dbClusterIdentifier
      subnets
      status
      percentProgress
      readerEndpoint
      multiAZ
      engine
      engineVersion
      port
      username
      replicationSourceIdentifier
      hostedZoneId
      encrypted
      kmsKey
      resourceId
      iamDbAuthenticationEnabled
      cloneGroupId
      createdTime
      capacity
      engineMode
      deletionProtection
      httpEndpointEnabled
      copyTagsToSnapshot
      crossAccountClone
      tags {
        id
        key
        value
      }
      globalWriteForwardingRequested
      instances {
        arn
        # Other fields and connections here...
      }
      securityGroups {
        arn
        # Other fields and connections here...
      }
    }
    securityGroups {
      id
      accountId
      arn
      name
      vpcId
      description
      tags {
        id
        key
        value
      }
      owner
      default
      inboundRules {
        id
        # Other fields and connections here...
      }
      outboundRules {
        id
        # Other fields and connections here...
      }
      inboundRuleCount
      outboundRuleCount
      alb {
        arn
        # Other fields and connections here...
      }
      lambda {
        arn
        # Other fields and connections here...
      }
      elb {
        arn
        # Other fields and connections here...
      }
      ec2Instance {
        arn
        # Other fields and connections here...
      }
      asg {
        arn
        # Other fields and connections here...
      }
      rdsCluster {
        arn
        # Other fields and connections here...
      }
      rdsDbInstance {
        arn
        # Other fields and connections here...
      }
    }
    subnet {
      id
      accountId
      arn
      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...
      }
    }
    vpc {
      accountId
      arn
      defaultVpc
      dhcpOptionsSet
      enableDnsHostnames
      enableDnsSupport
      id
      instanceTenancy
      ipV4Cidr
      ipV6Cidr
      state
      alb {
        arn
        # Other fields and connections here...
      }
      eip {
        arn
        # Other fields and connections here...
      }
      elb {
        arn
        # Other fields and connections here...
      }
      igw {
        arn
        # Other fields and connections here...
      }
      tags {
        id
        key
        value
      }
      nacl {
        arn
        # Other fields and connections here...
      }
      lambda {
        arn
        # Other fields and connections here...
      }
      subnet {
        arn
        # Other fields and connections here...
      }
      natGateway {
        arn
        # Other fields and connections here...
      }
      routeTable {
        arn
        # Other fields and connections here...
      }
      rdsDbInstance {
        # Other fields and connections here...
        arn
      }
      route53HostedZone {
        # Other fields and connections here...
        arn
      }
    }
  }
}


References

Dgraph documentation on querying

AWS RDS DB Instance documentation

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