Skip to content

Commit 2c323fa

Browse files
committed
Merge branch 'alpha' into feature/EP-3199-support-missing-glue-services
2 parents be11f33 + 6d5037d commit 2c323fa

File tree

19 files changed

+477
-116
lines changed

19 files changed

+477
-116
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# [0.89.0-alpha.10](https://github.com/cloudgraphdev/cloudgraph-provider-aws/compare/0.89.0-alpha.9...0.89.0-alpha.10) (2023-06-01)
2+
3+
4+
### Features
5+
6+
* add config missing services ([ad4f1a1](https://github.com/cloudgraphdev/cloudgraph-provider-aws/commit/ad4f1a1e2f58caa21838cc1966621e863bc648e8))
7+
18
# [0.89.0-alpha.9](https://github.com/cloudgraphdev/cloudgraph-provider-aws/compare/0.89.0-alpha.8...0.89.0-alpha.9) (2023-06-01)
29

310

README.md

Lines changed: 113 additions & 111 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cloudgraph/cg-provider-aws",
3-
"version": "0.89.0-alpha.9",
3+
"version": "0.89.0-alpha.10",
44
"description": "cloud-graph provider plugin for AWS used to fetch AWS cloud data.",
55
"publishConfig": {
66
"registry": "https://registry.npmjs.org/",

src/enums/serviceAliases.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ export default {
2121
[services.cloudwatchDashboard]: 'cloudwatchDashboards',
2222
[services.cloudwatchEventRule]: 'cloudwatchEventRules',
2323
[services.codebuild]: 'codebuilds',
24+
[services.configurationDeliveryChannel]: 'configurationDeliveryChannels',
2425
[services.configurationRecorder]: 'configurationRecorders',
26+
[services.configurationRule]: 'configurationRules',
2527
[services.dmsReplicationInstance]: 'dmsReplicationInstances',
2628
[services.ebsSnapshot]: 'ebsSnapshots',
2729
[services.ec2Instance]: 'ec2Instances',

src/enums/serviceMap.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ import CloudWatchLog from '../services/cloudwatchLogs'
2626
import CodeBuild from '../services/codeBuild'
2727
import CognitoIdentityPool from '../services/cognitoIdentityPool'
2828
import CognitoUserPool from '../services/cognitoUserPool'
29+
import ConfigurationDeliveryChannel from '../services/configurationDeliveryChannel'
2930
import ConfigurationRecorder from '../services/configurationRecorder'
31+
import ConfigurationRule from '../services/configurationRule'
3032
import CustomerGateway from '../services/customerGateway'
3133
import DmsReplicationInstance from '../services/dmsReplicationInstance'
3234
import DynamoDB from '../services/dynamodb'
@@ -152,7 +154,9 @@ export default {
152154
[services.codebuild]: CodeBuild,
153155
[services.cognitoIdentityPool]: CognitoIdentityPool,
154156
[services.cognitoUserPool]: CognitoUserPool,
157+
[services.configurationDeliveryChannel]: ConfigurationDeliveryChannel,
155158
[services.configurationRecorder]: ConfigurationRecorder,
159+
[services.configurationRule]: ConfigurationRule,
156160
[services.ebs]: EBS,
157161
[services.ebsSnapshot]: EBSSnapshot,
158162
[services.ec2Instance]: EC2,

src/enums/services.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ export default {
2626
codebuild: 'codebuild',
2727
cognitoIdentityPool: 'cognitoIdentityPool',
2828
cognitoUserPool: 'cognitoUserPool',
29+
configurationDeliveryChannel: 'configurationDeliveryChannel',
2930
configurationRecorder: 'configurationRecorder',
31+
configurationRule: 'configurationRule',
3032
customerGateway: 'customerGateway',
3133
dmsReplicationInstance: 'dmsReplicationInstance',
3234
dynamodb: 'dynamodb',

src/properties/logger.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,13 +305,13 @@ export default {
305305
lookingforRdsClusters: 'Looking for RDS Clusters...',
306306
creatingRdsInstance: (num: number): string => `Creating RDS Instance #${num}`,
307307
fetchedRdsClusters: (num: number): string => `Fetched ${num} RDS Clusters`,
308-
fetchedRdsGlobalClusters: (num: number): string => `Fetched ${num} RDS Global Clusters`,
308+
fetchedRdsGlobalClusters: (num: number): string =>
309+
`Fetched ${num} RDS Global Clusters`,
309310
fetchedRdsInstances: (num: number): string =>
310311
`Fetched ${num} RDS DB Instances`,
311312
fetchedRdsEventSubscriptions: (num: number): string =>
312313
`Fetched ${num} RDS DB Event Subscriptions`,
313-
fetchedRdsDbProxies: (num: number): string =>
314-
`Fetched ${num} RDS DB Proxies`,
314+
fetchedRdsDbProxies: (num: number): string => `Fetched ${num} RDS DB Proxies`,
315315
noClusterFound: '❎ DB Instance is not part of a cluster ❎ ',
316316
foundCluster: 'Found the cluster the instance belongs to',
317317
addingRdsInstances: (num: number): string =>
@@ -705,6 +705,11 @@ export default {
705705
gettingCloudwatchLogGroups: 'Fetching CloudWatch Log groups...',
706706
foundMoreCloudwatchMetricFilters: (num: number): string =>
707707
`Found another ${num} CloudWatch Metric filters in this region...`,
708+
/**
709+
* Configuration Delivery Channel
710+
*/
711+
fetchedCOnfigurationDeliveryChannels: (num: number): string =>
712+
`Fetched ${num} Configuration Delivery Channels`,
708713
/**
709714
* Configuration Recorders
710715
*/
@@ -715,6 +720,11 @@ export default {
715720
*/
716721
fetchedConfigurationRecorderStatus: (num: number): string =>
717722
`Fetched ${num} Configuration Recorder Status`,
723+
/**
724+
* Configuration Rules
725+
*/
726+
fetchedConfigurationRules: (num: number): string =>
727+
`Fetched ${num} Configuration Rules`,
718728
/**
719729
* Vpc Endpoints
720730
*/

src/services/account/schema.graphql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ type awsAccount implements awsOptionalService @key(fields: "id") {
2424
codebuilds: [awsCodebuild]
2525
cognitoIdentityPool: [awsCognitoIdentityPool]
2626
cognitoUserPool: [awsCognitoUserPool]
27+
configurationDeliveryChannels: [awsConfigurationDeliveryChannel]
2728
configurationRecorders: [awsConfigurationRecorder]
29+
configurationRules: [awsConfigurationRule]
2830
customerGateway: [awsCustomerGateway]
2931
dmsReplicationInstances: [awsDmsReplicationInstance]
3032
dynamodb: [awsDynamoDbTable]
@@ -81,7 +83,7 @@ type awsAccount implements awsOptionalService @key(fields: "id") {
8183
networkInterfaces: [awsNetworkInterface]
8284
organizations: [awsOrganization]
8385
rdsClusters: [awsRdsCluster]
84-
rdsGlobalCluster : [awsRdsGlobalCluster]
86+
rdsGlobalCluster: [awsRdsGlobalCluster]
8587
rdsClusterSnapshots: [awsRdsClusterSnapshot]
8688
rdsDbInstances: [awsRdsDbInstance]
8789
rdsEventSubscription: [awsRdsEventSubscription]
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
import CloudGraph from '@cloudgraph/sdk'
2+
import groupBy from 'lodash/groupBy'
3+
import isEmpty from 'lodash/isEmpty'
4+
5+
import EC2, {
6+
DeliveryChannel,
7+
DeliveryChannelList,
8+
DescribeDeliveryChannelsResponse,
9+
} from 'aws-sdk/clients/configservice'
10+
11+
import { Config } from 'aws-sdk/lib/config'
12+
import { AWSError } from 'aws-sdk/lib/error'
13+
14+
import { initTestEndpoint } from '../../utils'
15+
import AwsErrorLog from '../../utils/errorLog'
16+
import awsLoggerText from '../../properties/logger'
17+
18+
const lt = { ...awsLoggerText }
19+
const { logger } = CloudGraph
20+
const serviceName = 'Configuration Delivery Channel'
21+
const errorLog = new AwsErrorLog(serviceName)
22+
const endpoint = initTestEndpoint(serviceName)
23+
24+
export interface RawAwsConfigurationDeliveryChannel extends DeliveryChannel {
25+
region: string
26+
}
27+
28+
const listConfigurationDeliveryChannelData = async ({
29+
ec2,
30+
}: {
31+
ec2: EC2
32+
}): Promise<DeliveryChannelList> =>
33+
new Promise<DeliveryChannelList>(resolve => {
34+
try {
35+
ec2.describeDeliveryChannels(
36+
{},
37+
(err: AWSError, data: DescribeDeliveryChannelsResponse) => {
38+
if (err) {
39+
errorLog.generateAwsErrorLog({
40+
functionName: 'ec2:describeDeliveryChannels',
41+
err,
42+
})
43+
}
44+
45+
if (isEmpty(data)) {
46+
return resolve([])
47+
}
48+
49+
const { DeliveryChannels: channels = [] } = data || {}
50+
51+
resolve(channels)
52+
}
53+
)
54+
} catch (error) {
55+
resolve([])
56+
}
57+
})
58+
59+
export default async ({
60+
regions,
61+
config,
62+
}: {
63+
regions: string
64+
config: Config
65+
}): Promise<{
66+
[region: string]: RawAwsConfigurationDeliveryChannel[]
67+
}> =>
68+
new Promise(async resolve => {
69+
const configurationDeliveryChannelsResult: RawAwsConfigurationDeliveryChannel[] =
70+
[]
71+
72+
const regionPromises = regions.split(',').map(region => {
73+
const ec2 = new EC2({ ...config, region, endpoint })
74+
75+
return new Promise<void>(
76+
async resolveConfigurationDeliveryChannelData => {
77+
// Get Configuration Delivery Channel Data
78+
const configurationDeliveryChannels =
79+
await listConfigurationDeliveryChannelData({
80+
ec2,
81+
})
82+
83+
if (!isEmpty(configurationDeliveryChannels)) {
84+
for (const configurationDeliveryChannel of configurationDeliveryChannels) {
85+
configurationDeliveryChannelsResult.push({
86+
...configurationDeliveryChannel,
87+
region,
88+
})
89+
}
90+
}
91+
92+
resolveConfigurationDeliveryChannelData()
93+
}
94+
)
95+
})
96+
97+
await Promise.all(regionPromises)
98+
logger.debug(
99+
lt.fetchedCOnfigurationDeliveryChannels(
100+
configurationDeliveryChannelsResult.length
101+
)
102+
)
103+
errorLog.reset()
104+
105+
resolve(groupBy(configurationDeliveryChannelsResult, 'region'))
106+
})
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { AwsConfigurationDeliveryChannel } from '../../types'
2+
import { RawAwsConfigurationDeliveryChannel } from './data'
3+
4+
/**
5+
* Configuration Delivery Channel
6+
*/
7+
8+
export default ({
9+
service: rawData,
10+
account,
11+
region,
12+
}: {
13+
service: RawAwsConfigurationDeliveryChannel
14+
account: string
15+
region: string
16+
}): AwsConfigurationDeliveryChannel => {
17+
const { name } = rawData
18+
19+
return {
20+
id: name,
21+
accountId: account,
22+
arn: name,
23+
region,
24+
name,
25+
}
26+
}

0 commit comments

Comments
 (0)