Skip to content

Commit 1452894

Browse files
committed
Revert "feat: Add Additional data to transit gateway attachment"
This reverts commit 52b277a.
1 parent 52b277a commit 1452894

7 files changed

Lines changed: 8 additions & 113 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,11 @@ CloudGraph AWS Provider will ask you what regions you would like to crawl and wi
153153
| ses | |
154154
| sns | kms, cloudtrail, cloudwatch, s3 |
155155
| sqs | elasticBeanstalkEnv, s3 |
156-
| subnet | alb, asg, codebuild, dmsReplicationInstance, ec2, ecsService, efsMountTarget, elastiCacheCluster, elasticSearchDomain, elb, lambda, managedAirflow, natGateway, networkInterface, rdsCluster, sageMakerNotebookInstance, routeTable, transitGatewayAttachment, vpc, eksCluster, emrCluster, flowLog |
156+
| subnet | alb, asg, codebuild, dmsReplicationInstance, ec2, ecsService, efsMountTarget, elastiCacheCluster, elasticSearchDomain, elb, lambda, managedAirflow, natGateway, networkInterface, rdsCluster, sageMakerNotebookInstance, routeTable, vpc, eksCluster, emrCluster, flowLog |
157157
| systemsManagerInstance | ec2, iamRole |
158158
| systemsManagerDocument | |
159159
| transitGateway | routeTable, transitGatewayAttachment, vpnConnection |
160-
| transitGatewayAttachment | routeTable, subnet, transitGateway, vpc, vpnConnection |
160+
| transitGatewayAttachment | routeTable, transitGateway, vpc, vpnConnection |
161161
| vpc | alb, codebuild, dmsReplicationInstance, ec2, eip, elb, ecsService, efsMountTarget, eksCluster igw, elastiCacheCluster, elasticSearchDomain, lambda, nacl, natGateway, networkInterface, rdsClusterSnapshot, rdsDbInstance, redshiftCluster, route53HostedZone, routeTable, subnet, flowLog, vpnGateway, transitGatewayAttachment |
162162
| vpnConnection | customerGateway, transitGateway, transitGatewayAttachment, vpnGateway |
163163
| vpnGateway | vpc, vpnConnection |

src/properties/logger.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,6 @@ export default {
479479
* Transit Gateway Attachment
480480
*/
481481
fetchedTransitGatewayAttachments: (num: number): string => `Found ${num} Transit Gateway Attachments`,
482-
fetchedTransitGatewayVpcAttachments: (num: number): string => `Found ${num} Transit Gateway VPC Attachments`,
483482
/**
484483
* VPN Gateway
485484
*/

src/services/subnet/schema.graphql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,4 @@ type awsSubnet implements awsBaseService @key(fields: "id") {
3333
sageMakerNotebookInstances: [awsSageMakerNotebookInstance]
3434
@hasInverse(field: subnet)
3535
rdsCluster: [awsRdsCluster] @hasInverse(field: subnets)
36-
transitGatewayAttachment: [awsTransitGatewayAttachment] @hasInverse(field: subnets)
3736
}

src/services/transitGatewayAttachment/connections.ts

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import isEmpty from 'lodash/isEmpty'
22

33
import { ServiceConnection } from '@cloudgraph/sdk'
44

5+
import { TransitGatewayAttachment, TagList } from 'aws-sdk/clients/ec2'
6+
57
import services from '../../enums/services'
68
import { RawAwsVpnConnection } from '../vpnConnection/data'
79
import { RawAwsVpc } from '../vpc/data'
810
import { RawAwsTransitGateway } from '../transitGateway/data'
9-
import { RawAwsTransitGatewayAttachment } from '../transitGatewayAttachment/data'
1011
import { RawAwsRouteTable } from '../routeTable/data'
11-
import { RawAwsSubnet } from '../subnet/data'
1212

1313
/**
1414
* Transit Gateway Attachment
@@ -21,7 +21,9 @@ export default ({
2121
}: {
2222
account: string
2323
data: { name: string; data: { [property: string]: any[] } }[]
24-
service: RawAwsTransitGatewayAttachment
24+
service: TransitGatewayAttachment & {
25+
Tags?: TagList
26+
}
2527
region: string
2628
}): { [key: string]: ServiceConnection[] } => {
2729
const connections: ServiceConnection[] = []
@@ -30,7 +32,6 @@ export default ({
3032
TransitGatewayId: transitGatewayId,
3133
Association: association,
3234
ResourceId: resourceId,
33-
SubnetIds: subnetIds,
3435
} = transitGatewayAttachment
3536

3637
/**
@@ -146,29 +147,6 @@ export default ({
146147
}
147148
}
148149

149-
/**
150-
* Find Subnets
151-
* related to this Transit Gateway Attachment
152-
*/
153-
const subnets = data.find(({ name }) => name === services.subnet)
154-
if (subnets?.data?.[region]) {
155-
const subnetsInRegion = subnets.data[region].filter(
156-
({ SubnetId }: RawAwsSubnet) => subnetIds.includes(SubnetId)
157-
)
158-
if (!isEmpty(subnetsInRegion)) {
159-
for (const subnet of subnetsInRegion) {
160-
const { SubnetId }: RawAwsSubnet = subnet
161-
162-
connections.push({
163-
id: SubnetId,
164-
resourceType: services.subnet,
165-
relation: 'child',
166-
field: 'subnets',
167-
})
168-
}
169-
}
170-
}
171-
172150
const transitGatewayAttachmentResult = {
173151
[id]: connections,
174152
}

src/services/transitGatewayAttachment/data.ts

Lines changed: 1 addition & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ import EC2, {
77
DescribeTransitGatewayAttachmentsResult,
88
TransitGatewayAttachmentList,
99
TransitGatewayAttachment,
10-
DescribeTransitGatewayVpcAttachmentsResult,
11-
TransitGatewayVpcAttachmentList,
12-
TransitGatewayVpcAttachment,
13-
DescribeTransitGatewayVpcAttachmentsRequest,
1410
} from 'aws-sdk/clients/ec2'
1511

1612
import { Config } from 'aws-sdk/lib/config'
@@ -56,6 +52,7 @@ const listTransitGatewayAttachmentsData = async ({
5652
err,
5753
})
5854
}
55+
5956
if (!isEmpty(data)) {
6057
const {
6158
NextToken: nextToken,
@@ -87,67 +84,6 @@ const listTransitGatewayAttachmentsData = async ({
8784
)
8885
})
8986

90-
const listTransitGatewayVpcAttachmentsData = async ({
91-
ec2,
92-
region,
93-
nextToken: NextToken = '',
94-
}: {
95-
ec2: EC2
96-
region: string
97-
nextToken?: string
98-
}): Promise<(TransitGatewayVpcAttachment & { region: string })[]> =>
99-
new Promise<(TransitGatewayVpcAttachment & { region: string })[]>(resolve => {
100-
let transitGatewayVpcAttachmentData: (TransitGatewayVpcAttachment & {
101-
region: string
102-
})[] = []
103-
const transitGatewayVpcAttachmentList: TransitGatewayVpcAttachmentList = []
104-
let args: DescribeTransitGatewayVpcAttachmentsRequest = {}
105-
106-
if (NextToken) {
107-
args = { ...args, NextToken }
108-
}
109-
110-
ec2.describeTransitGatewayVpcAttachments(
111-
args,
112-
(err: AWSError, data: DescribeTransitGatewayVpcAttachmentsResult) => {
113-
if (err) {
114-
errorLog.generateAwsErrorLog({
115-
functionName: 'ec2:describeTransitGatewayVpcAttachments',
116-
err,
117-
})
118-
}
119-
120-
if (!isEmpty(data)) {
121-
const {
122-
NextToken: nextToken,
123-
TransitGatewayVpcAttachments: transitGatewayVpcAttachments = [],
124-
} = data
125-
126-
transitGatewayVpcAttachmentList.push(...transitGatewayVpcAttachments)
127-
128-
logger.debug(
129-
lt.fetchedTransitGatewayVpcAttachments(
130-
transitGatewayVpcAttachments.length
131-
)
132-
)
133-
134-
if (nextToken) {
135-
listTransitGatewayVpcAttachmentsData({ ec2, region, nextToken })
136-
}
137-
138-
transitGatewayVpcAttachmentData = transitGatewayVpcAttachmentList.map(
139-
vpcAttachment => ({
140-
...vpcAttachment,
141-
region,
142-
})
143-
)
144-
}
145-
146-
resolve(transitGatewayVpcAttachmentData)
147-
}
148-
)
149-
})
150-
15187
/**
15288
* Transit Gateway Attachment
15389
*/
@@ -156,7 +92,6 @@ export interface RawAwsTransitGatewayAttachment
15692
extends Omit<TransitGatewayAttachment, 'Tags'> {
15793
region: string
15894
Tags?: TagMap
159-
SubnetIds?: string[]
16095
}
16196

16297
export default async ({
@@ -183,24 +118,11 @@ export default async ({
183118
})
184119

185120
if (!isEmpty(transitGatewayAttachments)) {
186-
// Get Transit Gateway Vpc Attachment Data
187-
const transitGatewayVpcAttachments =
188-
await listTransitGatewayVpcAttachmentsData({
189-
ec2,
190-
region,
191-
})
192-
193121
for (const attachment of transitGatewayAttachments) {
194122
transitGatewayAttachmentsResult.push({
195123
...attachment,
196124
region,
197125
Tags: convertAwsTagsToTagMap(attachment.Tags as AwsTag[]),
198-
SubnetIds:
199-
transitGatewayVpcAttachments?.find(
200-
a =>
201-
a.TransitGatewayAttachmentId ===
202-
attachment.TransitGatewayAttachmentId
203-
)?.SubnetIds || [],
204126
})
205127
}
206128
}

src/services/transitGatewayAttachment/schema.graphql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,4 @@ type awsTransitGatewayAttachment @key(fields: "arn") {
1717
routeTable: [awsRouteTable] @hasInverse(field: transitGatewayAttachment)
1818
vpc: [awsVpc] @hasInverse(field: transitGatewayAttachments)
1919
vpnConnection: [awsVpnConnection] @hasInverse(field: transitGatewayAttachment)
20-
subnets: [awsSubnet] @hasInverse(field: transitGatewayAttachment)
2120
}

src/types/generated.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4054,7 +4054,6 @@ export type AwsSubnet = AwsBaseService & {
40544054
sageMakerNotebookInstances?: Maybe<Array<Maybe<AwsSageMakerNotebookInstance>>>;
40554055
state?: Maybe<Scalars['String']>;
40564056
tags?: Maybe<Array<Maybe<AwsRawTag>>>;
4057-
transitGatewayAttachment?: Maybe<Array<Maybe<AwsTransitGatewayAttachment>>>;
40584057
vpc?: Maybe<Array<Maybe<AwsVpc>>>;
40594058
};
40604059

@@ -4226,7 +4225,6 @@ export type AwsTransitGatewayAttachment = {
42264225
resourceType?: Maybe<Scalars['String']>;
42274226
routeTable?: Maybe<Array<Maybe<AwsRouteTable>>>;
42284227
state?: Maybe<Scalars['String']>;
4229-
subnets?: Maybe<Array<Maybe<AwsSubnet>>>;
42304228
tags?: Maybe<Array<Maybe<AwsRawTag>>>;
42314229
transitGateway?: Maybe<Array<Maybe<AwsTransitGateway>>>;
42324230
transitGatewayId?: Maybe<Scalars['String']>;

0 commit comments

Comments
 (0)