Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable support for aliyun RDS resources #27

Merged
merged 7 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
206 changes: 39 additions & 167 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"@alicloud/ros-cdk-oss": "^1.4.0",
"@alicloud/ros-cdk-ossdeployment": "^1.4.0",
"@alicloud/ros-cdk-ram": "^1.4.0",
"@alicloud/ros-cdk-rds": "^1.5.0",
"@alicloud/ros-cdk-sls": "^1.5.0",
"@alicloud/ros20190910": "^3.5.2",
"ajv": "^8.17.1",
Expand Down
30 changes: 30 additions & 0 deletions samples/aliyun-poc-es.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: 0.0.1

provider:
name: aliyun
region: cn-chengdu


service: insight-db-poc

tags:
owner: geek-fun

databases:
# insight_es_db:
# name: insight-poc-es
# type: ELASTICSEARCH_SERVERLESS
# version: '7.10'
# engine_mode: SEARCH
# cu: 1
# storage_size: 20
# security:
# basic_auth:
# password: 'U34I6InQ8elseTgqTWT2t2oFXpoqFg'
insight_poc_db:
name: insight-poc-rds
type: RDS_PGSQL_SERVERLESS
version: PGSQL_16
security:
basic_auth:
password: 'U34I6InQ8elseTgqTWT2t2oFXpoqFg'
60 changes: 60 additions & 0 deletions samples/aliyun-poc-fc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
version: 0.0.1
provider:
name: aliyun
region: cn-chengdu

vars:
region: cn-hangzhou
testv: testVarValue
handler: index.handler

stages:
default:
region: ${vars.region}
node_env: default
dev:
region: ${vars.region}
node_env: development
prod:
region: cn-shanghai

service: insight-poc

tags:
owner: geek-fun

functions:
insight_poc_fn:
name: insight-poc-fn
runtime: nodejs18
handler: ${vars.handler}
code: tests/fixtures/artifacts/artifact.zip
memory: 512
timeout: 10
environment:
NODE_ENV: ${stages.node_env}
TEST_VAR: ${vars.testv}
TEST_VAR_EXTRA: abcds-${vars.testv}-andyou

databases:
insight_poc_db:
name: insight-poc-db
type: RDS_POSTGRESQL_SERVERLESS
version: '17.0'
security:
basic_auth:
password: 'U34I6InQ8elseTgqTWT2t2oFXpoqFg'

events:
gateway_event:
type: API_GATEWAY
name: insight-poc-gateway
triggers:
- method: GET
path: /api/hello
backend: ${functions.insight_poc_fn}
# custom_domain:
# domain_name: test.com
# certificate_name: test
# certificate_private_key: test
# certificate_body: test
24 changes: 24 additions & 0 deletions samples/aliyun-poc-rds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: 0.0.1

provider:
name: aliyun
region: cn-chengdu


service: insight-rds-poc

tags:
owner: geek-fun

databases:
insight_poc_db:
name: insight-poc-rds
type: RDS_PGSQL_SERVERLESS
version: PGSQL_16
security:
basic_auth:
master_user: 'db_root'
password: 'U34I6InQ8elseTgqTWT2t2oFXpoqFg'
network:
type: 'PRIVATE'

60 changes: 60 additions & 0 deletions samples/huawei-poc-fc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
version: 0.0.1
provider:
name: huawei
region: cn-north-4

vars:
testv: testVarValue
handler: index.handler

stages:
default:
node_env: default
dev:
region: ${vars.region}
node_env: development
prod:
node_env: prod
service: insight-poc

tags:
owner: geek-fun

functions:
insight_poc_fn:
name: insight-poc-fn
runtime: nodejs18
handler: ${vars.handler}
code: tests/fixtures/artifacts/artifact.zip
memory: 512
timeout: 10
environment:
NODE_ENV: ${stages.node_env}
TEST_VAR: ${vars.testv}
TEST_VAR_EXTRA: abcds-${vars.testv}-andyou

#databases:
# insight_es_db:
# name: insight-poc-es
# type: ELASTICSEARCH_SERVERLESS
# version: 7.10
# engine_mode: SEARCH
# security:
# basic_auth:
# password: 123456
# cu: 1
# storage_size: 20

events:
gateway_event:
type: API_GATEWAY
name: insight-poc-gateway
triggers:
- method: GET
path: /api/hello
backend: ${functions.insight_poc_fn}
# custom_domain:
# domain_name: test.com
# certificate_name: test
# certificate_private_key: test
# certificate_body: test
20 changes: 13 additions & 7 deletions src/parser/databaseParser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DatabaseDomain, DatabaseEnum, DatabaseRaw } from '../types';
import { DatabaseDomain, DatabaseEnum, DatabaseRaw, DatabaseVersionEnum } from '../types';
import { get, isEmpty } from 'lodash';

export const parseDatabase = (databases?: {
Expand All @@ -11,17 +11,23 @@ export const parseDatabase = (databases?: {
key: key,
name: database.name,
type: database.type as DatabaseEnum,
version: database.version,
engineMode: database.engine_mode,
version: database.version as DatabaseVersionEnum,
security: {
basicAuth: {
username: get(database, 'security.basic_auth.master_user'),
password: get(database, 'security.basic_auth.password'),
},
},
cu: database.cu,
storageSize: database.storage_size,
network: database.network && {
public: database.network?.public as boolean,
cu: {
min: database.cu?.min ?? 0,
max: database.cu?.max ?? 6,
},
storage: {
min: database.storage?.min ?? 20,
},
network: {
type: database.network?.type ?? 'PRIVATE',
ingressRules: database.network?.ingress_rules ?? ['0.0.0.0/0'],
},
}));
};
Loading
Loading