Skip to content

Commit 762dc79

Browse files
author
Christopher Brandt
authored
Merge pull request #1 from cloudgraphdev/feature/CG-1137
feat(boilerplate): add boilerplate, vpc, subnet and tags
2 parents c8ee8f1 + a4b1da7 commit 762dc79

32 files changed

+1362
-4
lines changed

README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ Use the CloudGraph Tencent Provider to scan and normalize cloud infrastructure u
77
- [CloudGraph Tencent Provider](#cloudgraph-tencent-provider)
88
- [Install](#install)
99
- [Authentication](#authentication)
10-
- [Multi Account](#multi-account)
1110
- [Configuration](#configuration)
1211
- [Supported Services](#supported-services)
1312
<!-- tocstop -->
@@ -22,9 +21,10 @@ cg init tencent
2221

2322
# Authentication
2423

24+
Authenticate the CloudGraph Tencent Provider using one or more SecretId/SecretKey pair(s). Visit the TencentCloud API Key page to apply for
25+
security credentials:
2526

26-
# Multi Account
27-
27+
- [TencentCloud API Key](https://console.cloud.tencent.com/capi)
2828

2929
# Configuration
3030

@@ -37,9 +37,24 @@ NOTE: CloudGraph will output where it stores the configuration file and provider
3737

3838
CloudGraph will generate this configuration file when you run `cg init tencent`. You may update it manually or by running `cg init tencent` again.
3939

40+
```
41+
"tencent": {
42+
"accounts": [
43+
{
44+
"secretId": "AKIDz8krbsJ5yKBZQpn74WFkmLPx3*******",
45+
"secretKey": "Gu5t9xGARNpq86cd98joQYCN3*******"
46+
}
47+
],
48+
"regions": "ap-bangkok,ap-jakarta,ap-beijing,ap-chengdu,ap-chongqing,ap-guangzhou,ap-shenzhen-fsi,ap-hongkong,ap-mumbai,ap-nanjing,ap-seoul,ap-tokyo,ap-shanghai,ap-shanghai-fsi,ap-singapore,eu-frankfurt,eu-moscow,na-ashburn,na-siliconvalley,na-toronto,sa-saopaulo",
49+
"resources": "subnet,vpc"
50+
}
51+
```
52+
4053
CloudGraph Tencent Provider will ask you what regions you would like to crawl and will by default crawl for **all** supported resources in **selected** regions in the **default** account. You can update the `regions` or `resources` fields in the `cloud-graphrc.json` file to change this behavior. You can also select which `resources` to crawl in the `cg init tencent` command by passing the the `-r` flag: `cg init tencent -r`
4154

4255
# Supported Services
4356

4457
| Service | Relations |
4558
| ------------------- | ------------------- |
59+
| subnet | vpc |
60+
| vpc | subnet |

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,14 @@
3636
"@graphql-tools/load-files": "^6.3.2",
3737
"@graphql-tools/merge": "^8.0.1",
3838
"@sentry/node": "^6.7.2",
39+
"@types/long": "^4.0.2",
3940
"chalk": "^4.1.2",
41+
"cuid": "^2.1.8",
4042
"dotenv": "^10.0.0",
4143
"graphql": "^16.2.0",
4244
"lodash": "^4.17.21",
4345
"pino": "^6.11.3",
46+
"tencentcloud-sdk-nodejs": "^4.0.333",
4447
"typescript": "^4.3.5"
4548
},
4649
"devDependencies": {

src/config/constants.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { regionMap } from '../enums/regions'
2+
import services from '../enums/services'
3+
4+
export const GLOBAL_REGION = 'global'
5+
export const DEFAULT_REGION = regionMap.easternUS
6+
export const DEFAULT_RESOURCES = Object.values(services).join(',')

src/config/environment.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import dotenv from 'dotenv'
2+
3+
const { parsed: environment } = dotenv.config()
4+
5+
export default {
6+
...process.env,
7+
...environment,
8+
}

src/enums/regions.ts

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
export const regionMap = {
2+
southeastAsiaPacific1: 'ap-bangkok',
3+
southeastAsiaPacific2: 'ap-jakarta',
4+
northChina: 'ap-beijing',
5+
southwestChina1: 'ap-chengdu',
6+
southwestChina2: 'ap-chongqing',
7+
southChina1: 'ap-guangzhou',
8+
southChina2: 'ap-shenzhen-fsi',
9+
hongKong: 'ap-hongkong',
10+
southAsiaPacific: 'ap-mumbai',
11+
eastChina: 'ap-nanjing',
12+
northeastAsiaPacific1: 'ap-seoul',
13+
northeastAsiaPacific2: 'ap-tokyo',
14+
eastChina1: 'ap-shanghai',
15+
eastChina2: 'ap-shanghai-fsi',
16+
southeastAsiaPacific: 'ap-singapore',
17+
europe1: 'eu-frankfurt',
18+
europe2: 'eu-moscow',
19+
easternUS: 'na-ashburn',
20+
westernUS: 'na-siliconvalley',
21+
northAmerica: 'na-toronto',
22+
southAmerica: 'sa-saopaulo',
23+
}
24+
25+
const {
26+
southeastAsiaPacific1,
27+
southeastAsiaPacific2,
28+
northChina,
29+
southwestChina1,
30+
southwestChina2,
31+
southChina1,
32+
southChina2,
33+
hongKong,
34+
southAsiaPacific,
35+
eastChina,
36+
northeastAsiaPacific1,
37+
northeastAsiaPacific2,
38+
eastChina1,
39+
eastChina2,
40+
southeastAsiaPacific,
41+
europe1,
42+
europe2,
43+
easternUS,
44+
westernUS,
45+
northAmerica,
46+
southAmerica,
47+
} = regionMap
48+
49+
export default [
50+
southeastAsiaPacific1,
51+
southeastAsiaPacific2,
52+
northChina,
53+
southwestChina1,
54+
southwestChina2,
55+
southChina1,
56+
southChina2,
57+
hongKong,
58+
southAsiaPacific,
59+
eastChina,
60+
northeastAsiaPacific1,
61+
northeastAsiaPacific2,
62+
eastChina1,
63+
eastChina2,
64+
southeastAsiaPacific,
65+
europe1,
66+
europe2,
67+
easternUS,
68+
westernUS,
69+
northAmerica,
70+
southAmerica,
71+
]

src/enums/relations.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import services from './services'
2+
3+
/**
4+
* Set relations between services to data sharing
5+
* The key of the object represents the parent or base service,
6+
* it might contain an array of dependant or children that must be executed after the parent
7+
*/
8+
export default {
9+
10+
}

src/enums/schemasMap.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import services from './services'
2+
3+
/**
4+
* schemasMap is an object that contains schemas name by resource
5+
*/
6+
export default {
7+
[services.subnet]: 'tencentSubnet',
8+
[services.vpc]: 'tencentVpc',
9+
tag: 'tencentTag',
10+
}

src/enums/serviceAliases.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export default {
2+
subnet: 'subnets',
3+
vpc: 'vpcInstances',
4+
}

src/enums/serviceMap.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import services from './services'
2+
import TencentSubnet from '../services/subnet'
3+
import TencentVpc from '../services/vpc'
4+
import TencentTag from '../services/tag'
5+
6+
/**
7+
* serviceMap is an object that contains all currently supported services
8+
* serviceMap is used by the serviceFactory to produce instances of service classes
9+
*/
10+
export default {
11+
[services.subnet]: TencentSubnet,
12+
[services.vpc]: TencentVpc,
13+
tag: TencentTag,
14+
}

src/enums/services.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export default {
2+
subnet: 'subnet',
3+
vpc: 'vpc',
4+
}

0 commit comments

Comments
 (0)