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 KMS
GraphQL
|
query{queryawsKms{idaccountIdarnregiondescriptionkeyRotationEnabledusagepolicy{id# Other fields and connections here...}enabledkeyStatecustomerMasterKeySpeccreationDatekeyManagerorigindeletionDatevalidTotags{idkeyvalue}lambda{arn# Other fields and connections here...}cloudtrail{arn# Other fields and connections here...}redshiftCluster{arn# Other fields and connections here...}sns{arn# Other fields and connections here...}eksCluster{arn# Other fields and connections here...}}}
Filtering
Get data for a single AWS KMS key that you know the ID or arn for:
GraphQL
|
query{getawsKms(id:"12345"){arn# Other fields and connections here...}}
GraphQL
|
query{getawsKms(arn:"arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab"){arn# Other fields and connections here...}}
Get data for all of the KMS keys in a certain AWS account:
GraphQL
|
query{queryawsKms(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# description // can use fulltext filters# keyRotationEnabled# usage# enabled# keyState# customMasterKeySpec# creationDate# keyManager# origin# deletionDate# validTo# 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 KMS keys that are NOT in a certain AWS account:
GraphQL
|
query{queryawsKms(filter:{not:{accountId:{eq:"12345"}}}){arn# Other fields and connections here...}}
Advanced Filtering
Get data for all of the KMS keys that have a connected cloudtrail:
GraphQL
|
query{queryawsKms(filter:{has:cloudtrail}){arn# Other fields and connections here...}}# Note that in addition to "cloudtrail" you can filter# Using "has" based on any of the following attributes:# description# keyRotationEnabled# usage# policy# enabled# keyState# customMasterKeySpec# tags# creationDate# keyManager# origin# deletionDate# validTo# lambda# redshiftCluster# sns# eksCluster
Use multiple filter selectors, (i.e. has, and, not, or) to get data for all of the KMS keys that have cloudtrail instances AND lambda instances connected to them OR that do not have sns instances connected to them. Note that you can use has, and, not, or completely independently of each other:
GraphQL
|
query{queryawsKms(filter:{has:cloudtrail,and:{has:lambda},or:{not:{has:sns}}}){arn# Other fields and connections here...}}
You may also filter using a regex when filtering on a string field like, description if you want to look for a value that matches say, important:
GraphQL
|
query{queryawsKms(filter:{description:{regexp:"/.*important*/"}}){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{queryawsKms(order:{desc:creationDate}){arn# Other fields and connections here...}}# Note that in addition to "creationDate" you can filter# Using "asc" or "desc" based on any of the following attributes:# id# accountId# arn# region# description# keyRotationEnabled# usage# policy# enabled# keyState# customMasterKeySpec# keyManager# origin# deletionDate# validTo
Only select and return the first two KMS keys that are found:
GraphQL
|
query{queryawsKms(first:2,order:{desc:creationDate}){arn# Other fields and connections here...}}
Only select and return the first two KMS keys that are found, but offset by one so keys two & three are returned:
GraphQL
|
query{queryawsKms(first:2,order:{desc:creationDate},offset:1){arn# Other fields and connections here...}}
Aggregation
Count the number KMS keys across all scanned AWS accounts:
GraphQL
|
query{aggregateawsKms{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 KMS keys:# idMin# idMax# accountIdMin# accountIdMax# arnMin# arnMax# regionMin# regionMax# descriptionMin# descriptionMax# keyRotationEnabledMin# keyRotationEnabledMax# usageMin# usageMax# policyMin# policyMax# enabledMin# enabledMax# keyStateMin# keyStateMax# customMasterKeySpecMin# customMasterKeySpecMax# creationDateMin# creationDateMax# keyManagerMin# keyManagerMax# originMin# originMax# deletionDateMin# deletionDateMax# validToMin# validToMax
Count the number of KMS keys in a single account. Note that you can apply all of the same filters that are listed above to aggregate queries:
GraphQL
|
query{aggregateawsKms(filter:{accountId:{eq:"12345"}}){count# Other fields and connections here...}}
Examples
Find all of the KMS keys that are in the us-east-1 region across all your accounts:
GraphQL
|
query{queryawsKms(filter:{region:{eq:"us-east-1"}}){arn# Other fields and connections here...}}
Find all of the KMS keys that have a tag of Environment:Production for a single AWS Account:
GraphQL
|
query{queryawsTag(filter:{key:{eq:"Environment"},value:{eq:"Production"}}){kms(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{queryawsKms(filter:{region:{eq:"us-east-1"}}){arn# Other fields and connections here...}queryawsTag(filter:{key:{eq:"Environment"},value:{eq:"Production"}}){kms(filter:{accountId:{eq:"12345"}}){arn# Other fields and connections here...}}}
Kitchen Sink
Putting it all together; get all data for all KMS keys 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 keys but if you want to it's easy to go from say, kms -> lambda -> vpc ...etc:
GraphQL
|
query{queryawsKms{idaccountIdarnregiondescriptionkeyRotationEnabledusagepolicy{id}enabledkeyStatecustomerMasterKeySpectags{idkeyvalue}creationDatekeyManagerorigindeletionDatevalidTocloudtrail{idcgId# Special id CloudGraph uses to make multi-region/multi-account cloudtrails uniqueaccountIdarnnameregions3BucketNames3KeyPrefixincludeGlobalServiceEventsisMultiRegionTrailhomeRegionlogFileValidationEnabledcloudWatchLogsLogGroupArncloudWatchLogsRoleArnkmsKeyIdhasCustomEventSelectorshasInsightSelectorsisOrganizationTrailtags{idkeyvalue}s3{arn# Other fields and connections here...}sns{arn# Other fields and connections here...}kms{arn# Other fields and connections here...}}redshiftCluster{idaccountIdarnallowVersionUpgradeautomatedSnapshotRetentionPeriodavailabilityZoneclusterAvailabilityStatusclusterCreateTimeclusterRevisionNumberclusterStatusclusterSubnetGroupNameclusterVersiondBNameencryptedenhancedVpcRoutingmanualSnapshotRetentionPeriodmasterUsernamemodifyStatusnodeTypenumberOfNodespreferredMaintenanceWindowpubliclyAccessibletags{idkeyvalue}kms{arn# Other fields and connections here...}vpc{arn# Other fields and connections here...}}sns{idaccountIdarnpolicy{id}displayNamedeliveryPolicysubscriptions{idarnendpointprotocol}tags{idkeyvalue}cloudtrail{arn# Other fields and connections here...}kms{arn# Other fields and connections here...}}lambda{idaccountIdarnregiondescriptionhandlerkmsKeyArnlastModifiedmemorySizereservedConcurrentExecutionsroleruntimesourceCodeSizetimeouttracingConfigversionenvironmentVariables{idkeyvalue}tags{idkeyvalue}kms{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...}cognitoUserPool{arn# Other fields and connections here...}}eksCluster{idaccountIdarnnamecreatedAtversionendpointstatusclientRequestTokenplatformVersionencryptionConfig{idresourcesprovider{keyArn}}certificateAuthority{data}logging{clusterLogging{idtypesenabled}}identity{oidc{issuer}}resourcesVpcConfig{subnetIdssecurityGroupIdsclusterSecurityGroupIdvpcIdendpointPublicAccessendpointPrivateAccesspublicAccessCidrs}kubernetesNetworkConfig{serviceIpv4Cidr}tags{idkeyvalue}iamRoles{arn# Other fields and connections here...}kms{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...}}}}