Skip to content

Commit 02f6a7d

Browse files
authored
feat: enable support for aliyun RDS resources (#27)
feat: enable support for aliyun RDS resources Refs: #26 --------- Signed-off-by: seven <zilisheng1996@gmail.com>
1 parent b25e3cf commit 02f6a7d

15 files changed

+625
-229
lines changed

package-lock.json

Lines changed: 39 additions & 167 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"@alicloud/ros-cdk-oss": "^1.4.0",
5959
"@alicloud/ros-cdk-ossdeployment": "^1.4.0",
6060
"@alicloud/ros-cdk-ram": "^1.4.0",
61+
"@alicloud/ros-cdk-rds": "^1.5.0",
6162
"@alicloud/ros-cdk-sls": "^1.5.0",
6263
"@alicloud/ros20190910": "^3.5.2",
6364
"ajv": "^8.17.1",

samples/aliyun-poc-es.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
version: 0.0.1
2+
3+
provider:
4+
name: aliyun
5+
region: cn-chengdu
6+
7+
8+
service: insight-db-poc
9+
10+
tags:
11+
owner: geek-fun
12+
13+
databases:
14+
# insight_es_db:
15+
# name: insight-poc-es
16+
# type: ELASTICSEARCH_SERVERLESS
17+
# version: '7.10'
18+
# engine_mode: SEARCH
19+
# cu: 1
20+
# storage_size: 20
21+
# security:
22+
# basic_auth:
23+
# password: 'U34I6InQ8elseTgqTWT2t2oFXpoqFg'
24+
insight_poc_db:
25+
name: insight-poc-rds
26+
type: RDS_PGSQL_SERVERLESS
27+
version: PGSQL_16
28+
security:
29+
basic_auth:
30+
password: 'U34I6InQ8elseTgqTWT2t2oFXpoqFg'

samples/aliyun-poc-fc.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
version: 0.0.1
2+
provider:
3+
name: aliyun
4+
region: cn-chengdu
5+
6+
vars:
7+
region: cn-hangzhou
8+
testv: testVarValue
9+
handler: index.handler
10+
11+
stages:
12+
default:
13+
region: ${vars.region}
14+
node_env: default
15+
dev:
16+
region: ${vars.region}
17+
node_env: development
18+
prod:
19+
region: cn-shanghai
20+
21+
service: insight-poc
22+
23+
tags:
24+
owner: geek-fun
25+
26+
functions:
27+
insight_poc_fn:
28+
name: insight-poc-fn
29+
runtime: nodejs18
30+
handler: ${vars.handler}
31+
code: tests/fixtures/artifacts/artifact.zip
32+
memory: 512
33+
timeout: 10
34+
environment:
35+
NODE_ENV: ${stages.node_env}
36+
TEST_VAR: ${vars.testv}
37+
TEST_VAR_EXTRA: abcds-${vars.testv}-andyou
38+
39+
databases:
40+
insight_poc_db:
41+
name: insight-poc-db
42+
type: RDS_POSTGRESQL_SERVERLESS
43+
version: '17.0'
44+
security:
45+
basic_auth:
46+
password: 'U34I6InQ8elseTgqTWT2t2oFXpoqFg'
47+
48+
events:
49+
gateway_event:
50+
type: API_GATEWAY
51+
name: insight-poc-gateway
52+
triggers:
53+
- method: GET
54+
path: /api/hello
55+
backend: ${functions.insight_poc_fn}
56+
# custom_domain:
57+
# domain_name: test.com
58+
# certificate_name: test
59+
# certificate_private_key: test
60+
# certificate_body: test

samples/aliyun-poc-rds.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
version: 0.0.1
2+
3+
provider:
4+
name: aliyun
5+
region: cn-chengdu
6+
7+
8+
service: insight-rds-poc
9+
10+
tags:
11+
owner: geek-fun
12+
13+
databases:
14+
insight_poc_db:
15+
name: insight-poc-rds
16+
type: RDS_PGSQL_SERVERLESS
17+
version: PGSQL_16
18+
security:
19+
basic_auth:
20+
master_user: 'db_root'
21+
password: 'U34I6InQ8elseTgqTWT2t2oFXpoqFg'
22+
network:
23+
type: 'PRIVATE'
24+

samples/huawei-poc-fc.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
version: 0.0.1
2+
provider:
3+
name: huawei
4+
region: cn-north-4
5+
6+
vars:
7+
testv: testVarValue
8+
handler: index.handler
9+
10+
stages:
11+
default:
12+
node_env: default
13+
dev:
14+
region: ${vars.region}
15+
node_env: development
16+
prod:
17+
node_env: prod
18+
service: insight-poc
19+
20+
tags:
21+
owner: geek-fun
22+
23+
functions:
24+
insight_poc_fn:
25+
name: insight-poc-fn
26+
runtime: nodejs18
27+
handler: ${vars.handler}
28+
code: tests/fixtures/artifacts/artifact.zip
29+
memory: 512
30+
timeout: 10
31+
environment:
32+
NODE_ENV: ${stages.node_env}
33+
TEST_VAR: ${vars.testv}
34+
TEST_VAR_EXTRA: abcds-${vars.testv}-andyou
35+
36+
#databases:
37+
# insight_es_db:
38+
# name: insight-poc-es
39+
# type: ELASTICSEARCH_SERVERLESS
40+
# version: 7.10
41+
# engine_mode: SEARCH
42+
# security:
43+
# basic_auth:
44+
# password: 123456
45+
# cu: 1
46+
# storage_size: 20
47+
48+
events:
49+
gateway_event:
50+
type: API_GATEWAY
51+
name: insight-poc-gateway
52+
triggers:
53+
- method: GET
54+
path: /api/hello
55+
backend: ${functions.insight_poc_fn}
56+
# custom_domain:
57+
# domain_name: test.com
58+
# certificate_name: test
59+
# certificate_private_key: test
60+
# certificate_body: test

src/parser/databaseParser.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DatabaseDomain, DatabaseEnum, DatabaseRaw } from '../types';
1+
import { DatabaseDomain, DatabaseEnum, DatabaseRaw, DatabaseVersionEnum } from '../types';
22
import { get, isEmpty } from 'lodash';
33

44
export const parseDatabase = (databases?: {
@@ -11,17 +11,23 @@ export const parseDatabase = (databases?: {
1111
key: key,
1212
name: database.name,
1313
type: database.type as DatabaseEnum,
14-
version: database.version,
15-
engineMode: database.engine_mode,
14+
version: database.version as DatabaseVersionEnum,
1615
security: {
1716
basicAuth: {
17+
username: get(database, 'security.basic_auth.master_user'),
1818
password: get(database, 'security.basic_auth.password'),
1919
},
2020
},
21-
cu: database.cu,
22-
storageSize: database.storage_size,
23-
network: database.network && {
24-
public: database.network?.public as boolean,
21+
cu: {
22+
min: database.cu?.min ?? 0,
23+
max: database.cu?.max ?? 6,
24+
},
25+
storage: {
26+
min: database.storage?.min ?? 20,
27+
},
28+
network: {
29+
type: database.network?.type ?? 'PRIVATE',
30+
ingressRules: database.network?.ingress_rules ?? ['0.0.0.0/0'],
2531
},
2632
}));
2733
};

0 commit comments

Comments
 (0)