Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ CloudGraph AWS Provider will ask you what regions you would like to crawl and wi
| cloud9 | |
| cloudformationStack | cloudformationStack, iamRole, sns |
| cloudformationStackSet | iamRole |
| cloudfront | elb, s3 |
| cloudfront | cloudwatch, elb, s3 |
| cloudtrail | cloudwatch, cloudwatchLog, kms, s3, sns |
| cloudwatch | cloudtrail, cloudwatchLog, sns |
| cloudwatch | cloudfront, cloudtrail, cloudwatchLog, sns |
| cloudwatchLog | cloudtrail, cloudwatch, ecsCluster, elasticSearchDomain, kms, managedAirflow, rdsDbInstance |
| codebuild | iamRole, kms, vpc, securityGroup, subnet |
| cognitoIdentityPool | iamRole, iamOpenIdConnectProvider, iamSamlProvider, elasticSearchDomain |
Expand Down
1 change: 1 addition & 0 deletions src/services/cloudfront/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type awsCloudfront implements awsBaseService @key(fields: "id") {
s3: [awsS3] @hasInverse(field: cloudfrontDistributions)
tags: [awsRawTag]
webAcl: [awsWafV2WebAcl] @hasInverse(field: cloudfront)
cloudwatch: [awsCloudwatch] @hasInverse(field: cloudfront)
}

type awsCloudfrontOriginData {
Expand Down
34 changes: 33 additions & 1 deletion src/services/cloudwatch/connections.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { ServiceConnection } from '@cloudgraph/sdk'
import { isEmpty } from 'lodash'
import { RawAwsCloudwatch } from './data'
import { RawAwsCloudfront } from '../cloudfront/data'
import services from '../../enums/services'
import { globalRegionName } from '../../enums/regions'

export default ({
service: cloudwatch,
Expand All @@ -15,7 +17,11 @@ export default ({
}): {
[property: string]: ServiceConnection[]
} => {
const { AlarmName: id, AlarmActions: alarmActions } = cloudwatch
const {
AlarmName: id,
AlarmActions: alarmActions,
Dimensions: dimensions,
} = cloudwatch
const connections: ServiceConnection[] = []

/**
Expand All @@ -40,6 +46,32 @@ export default ({
}
}

/**
* Find Cloudfront
* related to the cloudwatch
*/
const cloudfronts = data.find(({ name }) => name === services.cloudfront)
if (cloudfronts?.data?.[globalRegionName]) {
const cloudfrontsInRegion: RawAwsCloudfront[] = cloudfronts.data[globalRegionName].filter(
({ summary: { Id: cloudfrontId } }: RawAwsCloudfront) =>
dimensions?.some(d => d.Value === cloudfrontId)
)

if (!isEmpty(cloudfrontsInRegion)) {
for (const cf of cloudfrontsInRegion) {
const {
summary: { Id: cloudfrontId },
}: RawAwsCloudfront = cf
connections.push({
id: cloudfrontId,
resourceType: services.cloudfront,
relation: 'child',
field: 'cloudfront',
})
}
}
}

const result = {
[id]: connections,
}
Expand Down
1 change: 1 addition & 0 deletions src/services/cloudwatch/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type awsCloudwatch implements awsBaseService @key(fields: "arn") {
cloudwatchLog: [awsCloudwatchLog] @hasInverse(field: cloudwatch)
sns: [awsSns] @hasInverse(field: cloudwatch)
cloudtrail: [awsCloudtrail] @hasInverse(field: cloudwatch)
cloudfront: [awsCloudfront] @hasInverse(field: cloudwatch)
}

type awsCloudwatchDimensions
Expand Down
8 changes: 7 additions & 1 deletion src/types/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,7 @@ export type AwsCloudFormationStackSetParameter = {

export type AwsCloudfront = AwsBaseService & {
callerReference?: Maybe<Scalars['String']>;
cloudwatch?: Maybe<Array<Maybe<AwsCloudwatch>>>;
customErrorResponses?: Maybe<Array<Maybe<AwsCloudfrontCustomErrorResponse>>>;
defaultCacheBehavior?: Maybe<AwsCloudfrontCacheBehavior>;
defaultRootObject?: Maybe<Scalars['String']>;
Expand Down Expand Up @@ -892,6 +893,7 @@ export type AwsCloudtrailStatus = {
export type AwsCloudwatch = AwsBaseService & {
actions?: Maybe<Array<Maybe<Scalars['String']>>>;
actionsEnabled?: Maybe<Scalars['String']>;
cloudfront?: Maybe<Array<Maybe<AwsCloudfront>>>;
cloudtrail?: Maybe<Array<Maybe<AwsCloudtrail>>>;
cloudwatchLog?: Maybe<Array<Maybe<AwsCloudwatchLog>>>;
comparisonOperator?: Maybe<Scalars['String']>;
Expand Down Expand Up @@ -4212,8 +4214,12 @@ export type AwsTransitGateway = AwsBaseService & {
vpnEcmpSupport?: Maybe<Scalars['String']>;
};

export type AwsTransitGatewayAttachment = AwsBaseService & {
export type AwsTransitGatewayAttachment = {
accountId: Scalars['String'];
arn: Scalars['String'];
creationTime?: Maybe<Scalars['String']>;
id: Scalars['String'];
region?: Maybe<Scalars['String']>;
resourceId?: Maybe<Scalars['String']>;
resourceOwnerId?: Maybe<Scalars['String']>;
resourceType?: Maybe<Scalars['String']>;
Expand Down