Skip to content

Commit ad05bc9

Browse files
authored
Merge pull request #132 from cloudgraphdev/feature/EP-3149-updates-needed-for-terraform
feat(aws): Added some adjustment needed for TF
2 parents bf485b0 + 07a9c02 commit ad05bc9

File tree

14 files changed

+80
-38
lines changed

14 files changed

+80
-38
lines changed

src/enums/serviceAliases.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export default {
5454
[services.lambda]: 'lambdaFunctions',
5555
[services.managedAirflow]: 'managedAirflows',
5656
[services.managedPrefixList]: 'managedPrefixLists',
57-
[services.mskCluster]: 'mskCluster',
57+
[services.mskCluster]: 'mskClusters',
5858
[services.nat]: 'natGateway',
5959
[services.networkInterface]: 'networkInterfaces',
6060
[services.organization]: 'organizations',

src/services/account/schema.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ type awsAccount implements awsOptionalService @key(fields: "id") {
6969
lambdaFunctions: [awsLambda]
7070
managedAirflows: [awsManagedAirflow]
7171
managedPrefixLists: [awsManagedPrefixList]
72+
mskClusters: [awsMskCluster]
7273
nacl: [awsNetworkAcl]
7374
natGateway: [awsNatGateway]
7475
networkInterfaces: [awsNetworkInterface]

src/services/apiGatewayResource/format.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default ({
1515
region: string
1616
account: string
1717
}): AwsAGResourceType => {
18-
const { id, path, resourceMethods = {} } = service
18+
const { id, path, restApiId, resourceMethods = {} } = service
1919

2020
const arn = apiGatewayResourceArn({
2121
restApiArn: apiGatewayArn({ region: service.region }),
@@ -39,5 +39,6 @@ export default ({
3939
region,
4040
path,
4141
methods,
42+
restApiId
4243
}
4344
}

src/services/apiGatewayResource/schema.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ type awsApiGatewayMethod @key(fields: "arn") {
77
}
88

99
type awsApiGatewayResource implements awsBaseService @key(fields: "arn") {
10+
restApiId: String @search(by: [hash, regexp])
1011
restApi: [awsApiGatewayRestApi] @hasInverse(field: resources) #change to plural
1112
path: String @search(by: [hash, regexp])
1213
methods: [awsApiGatewayMethod]

src/services/apiGatewayStage/format.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export default ({
2222
variables: vars = {},
2323
tags = {},
2424
region,
25+
restApiId
2526
} = service
2627

2728
const variables = Object.entries(vars).map(([k, v]) => ({
@@ -45,5 +46,6 @@ export default ({
4546
xrayTracing: tracingEnabled,
4647
variables,
4748
tags: formatTagsFromMap(tags),
49+
restApiId
4850
}
4951
}

src/services/apiGatewayStage/schema.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type awsApiGatewayStage implements awsBaseService @key(fields: "arn") {
2929
documentationVersion: String @search(by: [hash, regexp])
3030
clientCertificateId: String @search(by: [hash])
3131
xrayTracing: Boolean @search
32+
restApiId: String @search(by: [hash, regexp])
3233
variables: [awsApiGatewayStageVariable]
3334
tags: [awsRawTag]
3435
restApi: [awsApiGatewayRestApi] @hasInverse(field: stages)

src/services/msk/connections.ts

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ServiceConnection } from '@cloudgraph/sdk'
22

3-
import services from '../../enums/services'
43
import { Cluster } from 'aws-sdk/clients/kafka'
4+
import services from '../../enums/services'
55

66
/**
77
* Msk
@@ -22,42 +22,35 @@ export default ({
2222
}): { [key: string]: ServiceConnection[] } => {
2323
const connections: ServiceConnection[] = []
2424

25-
const {
26-
ClusterArn: id,
27-
Serverless: serverless,
28-
} = mskCluster || {}
29-
25+
const { ClusterArn: id, Serverless: serverless } = mskCluster || {}
26+
3027
/**
3128
* Add subnets
3229
*/
33-
serverless?.VpcConfigs
34-
?.filter(vc => vc.SubnetIds)
35-
?.forEach(vc => {
36-
connections.push(
37-
...vc?.SubnetIds?.map(subnetId => ({
38-
id: subnetId,
39-
resourceType: services.subnet,
40-
relation: 'child',
41-
field: 'subnet',
42-
}))
43-
)
44-
})
30+
serverless?.VpcConfigs?.filter(vc => vc.SubnetIds)?.forEach(vc => {
31+
connections.push(
32+
...vc?.SubnetIds?.map(subnetId => ({
33+
id: subnetId,
34+
resourceType: services.subnet,
35+
relation: 'child',
36+
field: 'subnets',
37+
}))
38+
)
39+
})
4540

4641
/**
4742
* Add Security Groups
4843
*/
49-
serverless?.VpcConfigs
50-
?.filter(vc => vc.SecurityGroupIds)
51-
?.forEach(vc => {
52-
connections.push(
53-
...vc?.SecurityGroupIds?.map(sgId => ({
54-
id: sgId,
55-
resourceType: services.sg,
56-
relation: 'child',
57-
field: 'securityGroups',
58-
}))
59-
)
60-
})
44+
serverless?.VpcConfigs?.filter(vc => vc.SecurityGroupIds)?.forEach(vc => {
45+
connections.push(
46+
...vc?.SecurityGroupIds?.map(sgId => ({
47+
id: sgId,
48+
resourceType: services.sg,
49+
relation: 'child',
50+
field: 'securityGroups',
51+
}))
52+
)
53+
})
6154

6255
const mskResult = {
6356
[id]: connections,

src/services/msk/schema.graphql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,4 +234,6 @@ type awsMskCluster implements awsBaseService @key(fields: "arn") {
234234
provisioned: awsMskClusterProvisioned
235235
serverless: awsMskClusterServerless
236236
tags: [awsRawTag]
237+
subnets: [awsSubnet] @hasInverse(field: mskClusters)
238+
securityGroups: [awsSecurityGroup] @hasInverse(field: mskClusters)
237239
}

src/services/route53Record/format.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1+
import { isEmpty } from 'lodash'
12
import { AwsRoute53Record } from '../../types/generated'
2-
import { RawAwsRoute53Record } from './data'
33
import { getHostedZoneId, getRecordId } from '../../utils/ids'
4+
import { RawAwsRoute53Record } from './data'
5+
6+
// Normalize name due special chars like '*' are replaced with '\\052'
7+
const normalizeName = (name: string): string => {
8+
if (isEmpty(name)) return ''
9+
const normalizedName = name.replace(/\\052/g, '*')
10+
return normalizedName.endsWith('.')
11+
? normalizedName.slice(0, -1)
12+
: normalizedName
13+
}
414

515
/**
616
* Route53 Record
@@ -24,8 +34,14 @@ export default ({
2434
SetIdentifier: identifier = '',
2535
} = rawData
2636

37+
const normalizedName = normalizeName(name)
2738
const hostedZoneId = getHostedZoneId(Id)
28-
const id = getRecordId({ hostedZoneId, name, type, identifier })
39+
const id = getRecordId({
40+
hostedZoneId,
41+
name: normalizedName,
42+
type,
43+
identifier,
44+
})
2945

3046
// Resource records
3147
const resourceRecords = records.map(({ Value }) => Value)
@@ -34,7 +50,7 @@ export default ({
3450
id,
3551
accountId: account,
3652
zoneId: hostedZoneId,
37-
name,
53+
name: normalizedName,
3854
setIdentifier: identifier,
3955
type,
4056
ttl,

src/services/securityGroup/schema.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ type awsSecurityGroup implements awsBaseService @key(fields: "id") {
3030
sageMakerNotebookInstances: [awsSageMakerNotebookInstance]
3131
@hasInverse(field: securityGroups)
3232
vpcEndpoints: [awsVpcEndpoint] @hasInverse(field: securityGroups)
33+
mskClusters: [awsMskCluster] @hasInverse(field: securityGroups)
3334
}
3435

3536
type awsSgOutboundRule

0 commit comments

Comments
 (0)