Skip to content

feat: Migrate Aliyun OSS Bucket to Terraform-like state engine#145

Merged
Blankll merged 4 commits intomasterfrom
copilot/migrate-aliyun-oss-bucket
Jan 5, 2026
Merged

feat: Migrate Aliyun OSS Bucket to Terraform-like state engine#145
Blankll merged 4 commits intomasterfrom
copilot/migrate-aliyun-oss-bucket

Conversation

Copy link
Contributor

Copilot AI commented Jan 5, 2026

  • Add ALIYUN_OSS_BUCKET to ResourceTypeEnum in src/types/domains/state.ts
  • Create ossOperations.ts in src/common/aliyunClient/ - OSS SDK operations wrapper
  • Update src/common/aliyunClient/index.ts to use OSS operations
  • Create ossTypes.ts - Type definitions for OSS bucket config and conversion functions
  • Create ossResource.ts - CRUD lifecycle with state management
  • Create ossPlanner.ts - Plan generation for bucket operations
  • Create ossExecutor.ts - Plan execution for bucket operations
  • Update src/stack/aliyunStack/index.ts to export new OSS modules
  • Create unit tests for ossTypes and ossPlanner
  • Run linting and build to verify changes
  • Run code review and address feedback
  • Run CodeQL security check (no issues found)

Code Review Feedback Addressed:

  • Extracted ACL type to shared BucketACL enum in src/stack/bucketTypes.ts
  • Created CommonBucketConfig, CommonBucketInfo, and CommonBucketInstance shared types
  • Expanded OssBucketInfo to include comprehensive bucket information (owner, storage class, data redundancy, CORS, lifecycle, logging, etc.)
  • Changed beforeEach to afterEach in ossPlanner.test.ts
  • Removed duplicated property assignments in ossTypes.ts

Security Summary

No security vulnerabilities were discovered by CodeQL analysis.

Original prompt

This section details on the original issue you should resolve

<issue_title>[MIGRATION] Migrate Aliyun OSS Bucket Resource to Terraform-like State Engine</issue_title>
<issue_description>## Summary
Migrate Aliyun OSS bucket resource management from ROS template-based deployment to the unified Terraform-like state management engine.

Background

Currently, Aliyun OSS buckets are managed via ROS CDK constructs in src/stack/rosStack/bucket.ts. This needs to be refactored to use the state-based workflow.

Current Implementation (to be migrated)

  • File: src/stack/rosStack/bucket.ts
  • Uses @alicloud/ros-cdk-oss, @alicloud/ros-cdk-ossdeployment, @alicloud/ros-cdk-dns, @alicloud/ros-cdk-ram
  • Handles: ACL configuration, website hosting, static file deployment, custom domains, DNS records

Target Implementation

Create new modules under src/stack/aliyunStack/:

  • Provider: ossProvider.ts - Aliyun OSS SDK operations
  • Types: ossTypes.ts - Type definitions and config hash
  • Resource: ossResource.ts - CRUD lifecycle with state management
  • Planner: ossPlanner.ts - Plan generation
  • Executor: ossExecutor.ts - Plan execution

Requirements

1. Create Aliyun OSS Provider (ossProvider.ts)

export const createOssBucket = async (context: Context, config: OssBucketConfig): Promise<void>
export const getOssBucket = async (context: Context, bucketName:  string): Promise<OssBucketInfo | null>
export const updateOssBucket = async (context:  Context, config: OssBucketConfig): Promise<void>
export const deleteOssBucket = async (context: Context, bucketName: string): Promise<void>
export const uploadStaticFiles = async (context: Context, bucketName: string, sourcePath: string): Promise<void>

Use ali-oss SDK instead of ROS CDK.

2. Create OSS Types (ossTypes.ts)

export type OssBucketConfig = {
  BucketName: string;
  ACL:  'private' | 'public-read' | 'public-read-write';
  Website?:  { IndexDocument: string; ErrorDocument:  string; ErrorCode: number };
  Domain?: string;
};
export const bucketToOssConfig = (bucket:  BucketDomain): OssBucketConfig => { ... };
export const computeBucketConfigHash = (config: OssBucketConfig): string => { ... };

3. Handle Features

  • ACL management (private, public-read, public-read-write)
  • Website hosting configuration
  • Static file deployment from local path
  • Custom domain binding with DNS records
  • Server-side encryption

4. Update State Types

Add ALIYUN_OSS_BUCKET to ResourceTypeEnum in src/types/domains/state.ts

Acceptance Criteria

  • OSS buckets can be created, updated, and deleted via state management
  • Website hosting and static file deployment works
  • Custom domain configuration works
  • State file tracks bucket resources with config hash
  • Drift detection works for bucket configuration changes

References

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits January 5, 2026 09:29
Co-authored-by: Blankll <28639911+Blankll@users.noreply.github.com>
…assertions

Co-authored-by: Blankll <28639911+Blankll@users.noreply.github.com>
Copilot AI changed the title [WIP] Migrate Aliyun OSS bucket resource to Terraform-like state engine feat: Migrate Aliyun OSS Bucket to Terraform-like state engine Jan 5, 2026
Copilot AI requested a review from Blankll January 5, 2026 09:38
@codecov
Copy link

codecov bot commented Jan 5, 2026

Codecov Report

❌ Patch coverage is 27.89116% with 212 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.93%. Comparing base (b6c5b47) to head (5166d83).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/stack/aliyunStack/ossResource.ts 9.09% 90 Missing ⚠️
src/common/aliyunClient/ossOperations.ts 3.52% 82 Missing ⚠️
src/stack/aliyunStack/ossExecutor.ts 10.00% 36 Missing ⚠️
src/stack/aliyunStack/ossPlanner.ts 91.66% 2 Missing and 1 partial ⚠️
src/stack/aliyunStack/ossTypes.ts 95.65% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #145      +/-   ##
==========================================
- Coverage   52.80%   50.93%   -1.88%     
==========================================
  Files         120      126       +6     
  Lines        3613     3907     +294     
  Branches      881      982     +101     
==========================================
+ Hits         1908     1990      +82     
- Misses       1502     1712     +210     
- Partials      203      205       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines +50 to +63
export const extractOssBucketDefinition = (config: OssBucketConfig): ResourceAttributes => {
return {
bucketName: config.BucketName,
acl: config.ACL ?? null,
websiteConfiguration: config.WebsiteConfiguration
? {
indexDocument: config.WebsiteConfiguration.IndexDocument,
errorDocument: config.WebsiteConfiguration.ErrorDocument ?? null,
}
: {},
storageClass: config.StorageClass ?? null,
domain: config.Domain ?? null,
};
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oss and cos should have same bucket defination, refactor to make oss and cos to reuse same logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored OssBucketConfig to use CommonBucketConfig from shared src/stack/bucketTypes.ts. OSS and COS now share the same base bucket configuration structure. Commit: 5166d83

Comment on lines +50 to +52
beforeEach(() => {
jest.clearAllMocks();
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

afterEach

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to afterEach. Commit: 5166d83

…and expand bucket info

Co-authored-by: Blankll <28639911+Blankll@users.noreply.github.com>
Copilot AI requested a review from Blankll January 5, 2026 13:43
@Blankll Blankll marked this pull request as ready for review January 5, 2026 14:08
@Blankll Blankll merged commit 8f409a5 into master Jan 5, 2026
3 of 5 checks passed
@Blankll Blankll deleted the copilot/migrate-aliyun-oss-bucket branch January 5, 2026 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[MIGRATION] Migrate Aliyun OSS Bucket Resource to Terraform-like State Engine

2 participants