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 Security Group:
GraphQL
|
query{queryawsSecurityGroup{idaccountIdarnnamevpcIddescriptiontags{idkeyvalue}ownerdefaultinboundRules{id# Other fields and connections here...}outboundRules{id# Other fields and connections here...}inboundRuleCountoutboundRuleCountalb{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...}}}
Filtering
Get data for a single AWS Security Group that you know the ID for:
GraphQL
|
query{getawsSecurityGroup(id:"12345"){arn# Other fields and connections here...}}
Get data for a single Security Group that you know the ARN for:
GraphQL
|
query{getawsSecurityGroup(arn:"arn:12345"){arn# Other fields and connections here...}}
Get data for all of the Security Groups in a certain AWS account:
GraphQL
|
query{queryawsSecurityGroup(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# vpcId# description // can use fulltext filters# owner# default# inboundRuleCount# outboundRuleCount# 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 Security Groups that are NOT in a certain AWS account:
GraphQL
|
query{queryawsSecurityGroup(filter:{not:{accountId:{eq:"12345"}}}){arn# Other fields and connections here...}}
Advanced Filtering
Get data for all of the Security Groups that have EC2 Instances in them:
GraphQL
|
query{queryawsSecurityGroup(filter:{has:ec2Instance}){arn# Other fields and connections here...}}# Note that in addition to "ec2Instance" you can filter# Using "has" based on any of the following attributes:# id# accountId# arn# name# vpcId# description# tags# owner# default# inboundRules# outboundRules# inboundRuleCount# outboundRuleCount# alb# lambda# elb# ec2Instance# asg# rdsCluster# rdsDbInstance
Use multiple filter selectors, (i.e. has, and, not, or) to get data for all of the Security Groups that have Lambdas AND RDS DB Instances associated with them OR that do not have ALBs associated in them. Note that you can use has, and, not, or completely independently of each other:
GraphQL
|
query{queryawsSecurityGroup(filter:{has:lambdaand:{has:rdsDbInstance}or:{not:{has:alb}}}){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, production (case insensitive):
GraphQL
|
query{queryawsSecurityGroup(filter:{description:{regexp:"/.*production.*/i"}}){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{queryawsSecurityGroup(order:{desc:vpcId}){vpcId# Other fields and connections here...}}# Note that in addition to "vpcId" you can filter# Using "asc" or "desc" based on any of the following attributes:# id# accountId# arn# name# description# owner# inboundRuleCount# outboundRuleCount
Only select and return the first two Security Groups that are found:
GraphQL
|
query{queryawsSecurityGroup(first:2,order:{desc:vpcId}){vpcId# Other fields and connections here...}}
Only select and return the first two Security Groups that are found, but offset by one so Security Groups two & three are returned:
GraphQL
|
query{queryawsSecurityGroup(first:2,order:{desc:vpcId},offset:1){arn# Other fields and connections here...}}
Aggregation
Count the number of Security Groups across all scanned AWS accounts:
GraphQL
|
query{aggregateawsSecurityGroup{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 Security Groups:# idMin# idMax# accountIdMin# accountIdMax# arnMin# arnMax# nameMin# nameMax# vpcIdMin# vpcIdMax# descriptionMin# descriptionMax# ownerMin# ownerMax# inboundRuleCountMin# inboundRuleCountMax# inboundRuleCountSum# inboundRuleCountAvg# outboundRuleCountMin# outboundRuleCountMax# outboundRuleCountSum# outboundRuleCountAvg
Count the number of Security Groups in a single account. Note that you can apply all of the same filters that are listed above to aggregate queries:
GraphQL
|
query{aggregateawsSecurityGroup(filter:{accountId:{eq:"12345"}}){count# Other fields and connections here...}}
Examples
Get all of the Security Groups in VPC 12345:
GraphQL
|
query{queryawsSecurityGroup(filter:{vpcId:{eq:"12345"}}){id# Other fields and connections here...}}
Find all of the Security Groups that have a tag of Environment:Production for a single AWS Account:
GraphQL
|
query{queryawsTag(filter:{key:{eq:"Environment"},value:{eq:"Production"}}){securityGroups(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{queryawsSecurityGroup(filter:{vpcId:{eq:"12345"}}){id# Other fields and connections here...}queryawsTag(filter:{key:{eq:"Environment"},value:{eq:"Production"}}){securityGroups(filter:{accountId:{eq:"12345"}}){arn# Other fields and connections here...}}}
Kitchen Sink
Putting it all together; get all data for all Security Groups 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 Security Groups but if you want to it's easy to go from say, Security Group -> ALB -> EC2 -> EBS...etc:
GraphQL
|
query{queryawsSecurityGroup{idaccountIdarnnamevpcIddescriptiontags{idkeyvalue}ownerdefaultinboundRules{iddescriptionportRangeprotocolsourceuserIdgroupNamepeeringStatus}outboundRules{iddescriptiondestinationportRangeprotocoluserIdgroupNamepeeringStatus}inboundRuleCountoutboundRuleCountalb{idaccountIdarndnsNameschemetypesubnetshostedZonedefaultVpcipAddressTypeidleTimeoutdeletionProtectionhttp2accessLogsEnableddropInvalidHeaderFieldscreatedAtstatustags{idkeyvalue}securityGroups{arn# Other fields and connections here...}ec2Instance{arn# Other fields and connections here...}vpc{arn# Other fields and connections here...}route53Record{id# Other fields and connections here...}listeners{arn# Other fields and connections here...}subnet{arn# Other fields and connections here...}}lambda{idaccountIdarndescriptionhandlerkmsKeyArnlastModifiedmemorySizereservedConcurrentExecutionsroleruntimesourceCodeSizetimeouttracingConfigversionenvironmentVariables{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...}}elb{idaccountIdarndnsNamehostedZonecreatedAttypestatusschemevpcIdsourceSecurityGroup{groupName# Other fields and connections here...}securityGroupsIdssubnetsaccessLogscrossZoneLoadBalancingidleTimeoutinstances{id# Other fields and connections here...}healthCheck{target# Other fields and connections here...}listeners{id# Other fields and connections here...}tags{idkeyvalue}cloudfrontDistribution{arn# Other fields and connections here...}securityGroups{arn# Other fields and connections here...}vpc{arn# Other fields and connections here...}route53Record{id# Other fields and connections here...}subnet{arn# Other fields and connections here...}}ec2Instance{idaccountIdarnregionamitenancyelasticIpspublicDnsprivateDnsmonitoringprivateIpskeyPair{idnamefingerprint}cpuCoreCounthibernationebsOptimizedipv4PublicIpinstanceTypeipv6AddressesplacementGroupinstanceStatesourceDestCheckavailabilityZonecpuThreadsPerCoreiamInstanceProfiledeletionProtectiondailyCost{costcurrencyformattedCost}primaryNetworkInterfacemetadataOptions{state# Other fields and connections here...}metadatasecurityGroupIdsOptionssecurityGroupIdsephemeralBlockDevices{deviceName# Other fields and connections here...}tags{idkeyvalue}alb{arn# Other fields and connections here...}asg{arn# Other fields and connections here...}ebs{arn# Other fields and connections here...}eip{arn# Other fields and connections here...}networkInterfaces{arn# Other fields and connections here...}securityGroups{arn# Other fields and connections here...}subnet{arn# Other fields and connections here...}}asg{idaccountIdarnnameregionlaunchConfigurationNamelaunchTemplateIdlaunchTemplateNamelaunchTemplateVersionmixedInstancesPolicy{launchTemplateId# Other fields and connections here...}minSizemaxSizedesiredCapacitypredictedCapacitycooldownavailabilityZonesloadBalancerNamestargetGroupARNshealthCheckTypehealthCheckGracePeriodec2InstanceIdssuspendedProcesses{id# Other fields and connections here...}placementGroupvpcZoneIdentifierenabledMetrics{id# Other fields and connections here...}statusterminationPoliciesnewInstancesProtectedFromScaleInserviceLinkedRoleARNmaxInstanceLifetimecapacityRebalanceEnabledwarmPoolConfigMaxGroupPreparedCapacitywarmPoolConfigMinSizewarmPoolConfigPoolStatewarmPoolConfigStatuswarmPoolSizecontexttags{idkeyvalue}launchConfiguration{imageId# Other fields and connections here...}ec2Instance{arn# Other fields and connections here...}securityGroups{arn# Other fields and connections here...}ebs{arn# Other fields and connections here...}subnet{arn# Other fields and connections here...}}rdsCluster{idaccountIdarnallocatedStoragebackupRetentionPeriodcharacterSetNamedatabaseNamedbClusterIdentifiersubnetsstatuspercentProgressreaderEndpointmultiAZengineengineVersionportusernamereplicationSourceIdentifierhostedZoneIdencryptedkmsKeyresourceIdiamDbAuthenticationEnabledcloneGroupIdcreatedTimecapacityengineModedeletionProtectionhttpEndpointEnabledcopyTagsToSnapshotcrossAccountClonetags{idkeyvalue}globalWriteForwardingRequestedinstances{arn# Other fields and connections here...}securityGroups{arn# Other fields and connections here...}}rdsDbInstance{idaccountIdarnnameportaddresshostedZoneIdusernameresourceIdengineengineVersioncreatedTimecopyTagsToSnapshotdeletionProtectiondBInstanceIdentifierperformanceInsightsEnabledautoMinorVersionUpgradeiamDbAuthenticationEnabledoptionsGroupsparameterGroupstorageTypeinstanceClassallocatedStoragemultiAZsubnetGroupavailabilityZonepubliclyAccessiblecertificateAuthoritystatusfailoverPrioritykmsKeyencryptedtags{idkeyvalue}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...}}}}