Commit 7cac56c
Migrate Aliyun Database Resources (RDS & ES Serverless) to state-based management engine (#146)
This pull request adds support for managing Alibaba Cloud RDS
(Relational Database Service) and ES (Elasticsearch Serverless)
resources in the codebase. It introduces new client initializations,
operation modules, and type definitions for both services, and updates
ESLint and dependencies accordingly.
**New Alibaba Cloud service support:**
* Added `@alicloud/rds20140815` and `@alicloud/es-serverless20230627`
dependencies to `package.json` to enable RDS and ES Serverless
operations.
* Initialized `RdsClient` and `EsServerlessClient` in
`src/common/aliyunClient/index.ts`, including endpoint configuration and
exporting their operation creators.
[[1]](diffhunk://#diff-f3f90b061baa39815fc9e43d17033101d09035011ad0334569a1d351bdbe8760R7-R8)
[[2]](diffhunk://#diff-f3f90b061baa39815fc9e43d17033101d09035011ad0334569a1d351bdbe8760R19-R26)
[[3]](diffhunk://#diff-f3f90b061baa39815fc9e43d17033101d09035011ad0334569a1d351bdbe8760R67-R74)
[[4]](diffhunk://#diff-f3f90b061baa39815fc9e43d17033101d09035011ad0334569a1d351bdbe8760R83-R84)
[[5]](diffhunk://#diff-f3f90b061baa39815fc9e43d17033101d09035011ad0334569a1d351bdbe8760R99-R100)
**New operation modules:**
* Added `src/common/aliyunClient/rdsOperations.ts` to provide functions
for creating, retrieving, updating, and deleting RDS instances, with
status polling and error handling.
* Added `src/common/aliyunClient/esOperations.ts` to provide similar
CRUD operations for ES Serverless applications, including status polling
and error handling.
**Code quality improvements:**
* Enabled the ESLint rule `@typescript-eslint/no-unused-vars` with
exceptions for variables prefixed with `_`, improving code cleanliness
without breaking convention for intentionally unused variables.
* Removed an unnecessary ESLint disable comment in
`src/common/stateManager.ts` for cleaner code.
<!-- START COPILOT ORIGINAL PROMPT -->
<details>
<summary>Original prompt</summary>
>
> ----
>
> *This section details on the original issue you should resolve*
>
> <issue_title>[MIGRATION] Migrate Aliyun Database Resources to
Terraform-like State Engine</issue_title>
> <issue_description>## Summary
> Migrate Aliyun database resources (RDS Serverless, Elasticsearch
Serverless) from ROS template-based deployment to the unified
Terraform-like state management engine.
>
> ## Background
> Currently, Aliyun databases are managed via ROS CDK constructs in
`src/stack/rosStack/database.ts`. This must now be migrated to a new
architecture based on state management with strict separation of
provider-agnostic and provider-specific logic.
>
> ## Updated Architecture
> ```
> ┌─────────────────────────────────────────┐
> │ Resource / Planner / Executor Layer │ ← Provider-agnostic business
logic
> │ (Pure functions, no SDK imports) │
> └─────────────────────────────────────────┘
> ↓
> ┌─────────────────────────────────────────┐
> │ Functional Client Layer │ ← Encapsulated SDK operations
> │ (aliyunClient.ts, tencentClient.ts) │
> └─────────────────────────────────────────┘
> ↓
> ┌─────────────────────────────────────────┐
> │ Cloud Provider SDKs │ ← @alicloud/*, tencentcloud-*
> └─────────────────────────────────────────┘
> ```
>
> - **Resource/Planner/Executor Layer:** Pure, provider-agnostic
business logic for resources, drift/planning, execution. No direct SDK
import or cloud-specific code. (See: `databaseResource.ts`,
`databasePlanner.ts`, `databaseExecutor.ts`)
> - **Functional Client Layer:** Encapsulates all SDK operations. E.g.
`aliyunClient.ts` abstracts Aliyun API/SDK calls for RDS, ES, etc. This
is the *only* layer with cloud SDK imports or API calls. New functional
clients must be implemented for supported clouds.
> - **Cloud Provider SDKs:** External dependencies such as
`@alicloud/ros-cdk-rds`, `@alicloud/ros-cdk-elasticsearch-serverless`,
`tencentcloud-*` SDKs, etc.
>
> ## Current Implementation (to be migrated)
> - **File**:
[`src/stack/rosStack/database.ts`](https://github.com/geek-fun/serverlessinsight/blob/master/src/stack/rosStack/database.ts)
> - Supports: RDS MySQL/PostgreSQL/MSSQL Serverless, Elasticsearch
Serverless
> - Uses `@alicloud/ros-cdk-rds`,
`@alicloud/ros-cdk-elasticsearch-serverless`
>
> ## Target Implementation
> Create new modules under `src/stack/aliyunStack/` as per new
architecture:
> - **Client**: `aliyunClient.ts`
> - **Types**: `rdsTypes.ts`, `esServerlessTypes.ts`
> - **Resource:** `databaseResource.ts`
> - **Planner:** `databasePlanner.ts`
> - **Executor:** `databaseExecutor.ts`
>
> ## Requirements
> ### 1. RDS Serverless Functional Client
> ```typescript
> export const createRdsInstance = async (context: Context, config:
RdsConfig): Promise<string>
> export const getRdsInstance = async (context: Context, instanceId:
string): Promise<RdsInfo | null>
> export const updateRdsInstance = async (context: Context, instanceId:
string, config: RdsConfig): Promise<void>
> export const deleteRdsInstance = async (context: Context, instanceId:
string): Promise<void>
> ```
> ### 2. Elasticsearch Serverless Functional Client
> ```typescript
> export const createEsApp = async (context: Context, config: EsConfig):
Promise<string>
> export const getEsApp = async (context: Context, appId: string):
Promise<EsInfo | null>
> export const updateEsApp = async (context: Context, appId: string,
config: EsConfig): Promise<void>
> export const deleteEsApp = async (context: Context, appId: string):
Promise<void>
> ```
> ### 3. Handle Features
> - RDS Serverless: MySQL 5.7/8.0, PostgreSQL 14/15/16, MSSQL 2016-2019
> - Elasticsearch Serverless with basic auth
> - Auto-scaling configuration (min/max CU)
> - Storage configuration
> - Network/VPC settings
> ### 4. State Types
> Add to `ResourceTypeEnum`:
> - `ALIYUN_RDS_SERVERLESS`
> - `ALIYUN_ES_SERVERLESS`
>
> ## Acceptance Criteria
> - [ ] RDS Serverless instances can be managed via state
> - [ ] Elasticsearch Serverless apps can be managed via state
> - [ ] Configuration changes trigger proper updates
> - [ ] Drift detection works for database resources
>
> ## References
> - Current ROS implementation:
[`src/stack/rosStack/database.ts`](https://github.com/geek-fun/serverlessinsight/blob/master/src/stack/rosStack/database.ts)
> - Tencent TDSQL-C pattern:
[`src/stack/scfStack/tdsqlcPlanner.ts`](https://github.com/geek-fun/serverlessinsight/blob/master/src/stack/scfStack/tdsqlcPlanner.ts)
> - See more architecture discussion in the documentation or
RFCs.</issue_description>
>
> ## Comments on the Issue (you are @copilot in this section)
>
> <comments>
> </comments>
>
</details>
<!-- START COPILOT CODING AGENT SUFFIX -->
- Fixes #130
<!-- START COPILOT CODING AGENT TIPS -->
---
💬 We'd love your input! Share your thoughts on Copilot coding agent in
our [2 minute survey](https://gh.io/copilot-coding-agent-survey).
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Blankll <28639911+Blankll@users.noreply.github.com>
Co-authored-by: Blankll <zilisheng1996@gmail.com>1 parent 2edb344 commit 7cac56c
File tree
18 files changed
+2324
-1
lines changed- src
- common
- aliyunClient
- lang
- stack/aliyunStack
- types/domains
- tests/stack/aliyunStack
18 files changed
+2324
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
48 | 55 | | |
49 | 56 | | |
50 | 57 | | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
| 60 | + | |
59 | 61 | | |
60 | 62 | | |
61 | 63 | | |
| |||
0 commit comments