@payfit/iac 1.0.3-ephemeral-migration-scripts-cleanup-pr.0 โ 1.0.4-ephemeral-iac-migration-docs.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/executors/stack-migration/README.md +71 -115
- package/dist/executors/stack-migration/lib/migration-tool.d.ts +1 -5
- package/dist/executors/stack-migration/lib/migration-tool.js +213 -211
- package/dist/executors/stack-migration/lib/migration-tool.js.map +1 -1
- package/dist/executors/stack-migration/lib/templates/index.d.ts +1 -0
- package/dist/executors/stack-migration/lib/templates/index.js +1 -0
- package/dist/executors/stack-migration/lib/templates/index.js.map +1 -1
- package/dist/executors/stack-migration/lib/templates/mermaid-diagram.d.ts +13 -0
- package/dist/executors/stack-migration/lib/templates/mermaid-diagram.js +46 -0
- package/dist/executors/stack-migration/lib/templates/mermaid-diagram.js.map +1 -0
- package/dist/executors/stack-migration/lib/templates/message-templates.d.ts +15 -20
- package/dist/executors/stack-migration/lib/templates/message-templates.js +34 -93
- package/dist/executors/stack-migration/lib/templates/message-templates.js.map +1 -1
- package/dist/executors/stack-migration/lib/templates/pr-templates.d.ts +16 -9
- package/dist/executors/stack-migration/lib/templates/pr-templates.js +77 -121
- package/dist/executors/stack-migration/lib/templates/pr-templates.js.map +1 -1
- package/dist/executors/stack-migration/lib/templates/procedure-template.d.ts +1 -0
- package/dist/executors/stack-migration/lib/templates/procedure-template.js +37 -118
- package/dist/executors/stack-migration/lib/templates/procedure-template.js.map +1 -1
- package/dist/executors/stack-migration/schema.d.ts +2 -3
- package/dist/executors/stack-migration/schema.json +2 -3
- package/dist/executors/stack-migration/stack-migration.js +2 -5
- package/dist/executors/stack-migration/stack-migration.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,125 +1,81 @@
|
|
|
1
1
|
# Stack Migration Executor
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
3
|
+
Migrate Spacelift stacks from iac-deploy to repository-level metastacks.
|
|
4
|
+
|
|
5
|
+
## Migration Flow
|
|
6
|
+
|
|
7
|
+
```mermaid
|
|
8
|
+
flowchart TD
|
|
9
|
+
subgraph Phase1["๐ฆ 1: Setup"]
|
|
10
|
+
A[init] --> B[Create PRs + Scripts]
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
subgraph Phase2["๐ 2: Safety & Enrollment"]
|
|
14
|
+
B --> C[Merge Safety Net PR]
|
|
15
|
+
C --> D[Merge Domain Enrollment PR]
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
subgraph Phase3["๐งน 3: State Management"]
|
|
19
|
+
D --> E[Run State Removal]
|
|
20
|
+
E --> F[Merge iac-deploy Cleanup PR]
|
|
21
|
+
F --> G[Run migrate-spaces]
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
subgraph Phase4["โ
4: Complete"]
|
|
25
|
+
G --> H[Merge Service Repo PR]
|
|
26
|
+
H --> I[Run Cleanup]
|
|
27
|
+
I --> J[Merge Post-Migration Cleanup PR]
|
|
28
|
+
end
|
|
19
29
|
```
|
|
20
30
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
You can also run each step independently. This is useful if you need to pause the migration or re-run specific steps.
|
|
31
|
+
## Quick Start
|
|
24
32
|
|
|
25
33
|
```bash
|
|
26
|
-
#
|
|
27
|
-
nx run <project>:stack-migration --command=
|
|
28
|
-
|
|
29
|
-
# 2. Check migration state
|
|
30
|
-
nx run <project>:stack-migration --command=state
|
|
31
|
-
|
|
32
|
-
# 3. Create domain enrollment PR
|
|
33
|
-
nx run <project>:stack-migration --command=enroll
|
|
34
|
-
|
|
35
|
-
# 4. Create service repository PR and generate state removal commands
|
|
36
|
-
nx run <project>:stack-migration --command=generate-tf-migration
|
|
37
|
-
|
|
38
|
-
# 5. Create cleanup PR (iac-deploy)
|
|
39
|
-
nx run <project>:stack-migration --command=cleanup-pr
|
|
40
|
-
|
|
41
|
-
# 6. Generate migration procedure documentation
|
|
42
|
-
nx run <project>:stack-migration --command=generate-procedure
|
|
43
|
-
|
|
44
|
-
# 7. Update stack spaces (move to domain space) - RUN MANUALLY ONLY
|
|
45
|
-
nx run <project>:stack-migration --command=migrate-spaces
|
|
34
|
+
# Full migration (recommended)
|
|
35
|
+
nx run <project>:stack-migration --command=run
|
|
46
36
|
|
|
47
|
-
#
|
|
48
|
-
nx run <project>:stack-migration --command=
|
|
37
|
+
# Preview changes first
|
|
38
|
+
nx run <project>:stack-migration --command=run --dry-run
|
|
49
39
|
```
|
|
50
40
|
|
|
51
|
-
##
|
|
52
|
-
|
|
53
|
-
The migration follows a specific sequence. Here's the required flow:
|
|
54
|
-
|
|
55
|
-
### Phase 1: Setup and Configuration
|
|
56
|
-
|
|
57
|
-
1. **init** - Clones required repos, validates auth, collects service info
|
|
58
|
-
- Creates `.migration-state.json` to track progress
|
|
59
|
-
- Clones: `domain-enrollment`, `iac-deploy`
|
|
60
|
-
- Loads stack configuration
|
|
61
|
-
|
|
62
|
-
### Phase 2: Safety and Enrollment
|
|
63
|
-
|
|
64
|
-
2. **enroll** - Creates domain enrollment PR
|
|
65
|
-
- Adds repository to domain's `spacelift.yaml`
|
|
66
|
-
- PR must be merged before continuing
|
|
67
|
-
- Deploys the metastack for your repository
|
|
68
|
-
|
|
69
|
-
3. **generate-tf-migration** - Creates service repository PR and state removal script
|
|
70
|
-
- Copies `spacelift.yaml` from iac-deploy
|
|
71
|
-
- Generates `.metastack/import.tf` with import blocks
|
|
72
|
-
- Generates `METASTACK_STATE_REMOVAL_COMMANDS.sh`
|
|
73
|
-
- DO NOT MERGE THIS PR YET
|
|
74
|
-
|
|
75
|
-
### Phase 3: Cleanup and State Management
|
|
76
|
-
|
|
77
|
-
4. **cleanup-pr** - Creates cleanup PR
|
|
78
|
-
- iac-deploy: Removes stack configuration file
|
|
79
|
-
- DO NOT MERGE THIS PR YET
|
|
80
|
-
|
|
81
|
-
5. **generate-procedure** - Generates migration documentation
|
|
82
|
-
- Creates `METASTACK_MIGRATION_PROCEDURE.md`
|
|
83
|
-
- Provides complete overview of migration steps
|
|
84
|
-
|
|
85
|
-
6. **migrate-spaces** - Updates stack spaces (MANUAL STEP)
|
|
86
|
-
- Moves stacks from old space to `domain-{domain}` space
|
|
87
|
-
- **IMPORTANT**: Run MANUALLY after state removal commands
|
|
88
|
-
- Run AFTER state removal, BEFORE merging cleanup PRs
|
|
89
|
-
- NOT included in full `run` workflow for safety
|
|
90
|
-
|
|
91
|
-
### Phase 4: Completion
|
|
92
|
-
|
|
93
|
-
7. After all steps complete:
|
|
94
|
-
- Merge cleanup PR (iac-deploy)
|
|
95
|
-
- Merge service repository PR
|
|
96
|
-
- Run **migration-cleanup** to remove temporary files
|
|
97
|
-
|
|
98
|
-
## Important Notes
|
|
99
|
-
|
|
100
|
-
### State Management
|
|
101
|
-
|
|
102
|
-
- Migration state is saved in `.migration-state.json`
|
|
103
|
-
- You can resume migration from any step
|
|
104
|
-
- Configuration (stacks) is preserved in state
|
|
105
|
-
- You can run steps in any order after `init`, but follow the recommended flow
|
|
106
|
-
|
|
107
|
-
### Order Requirements
|
|
108
|
-
|
|
109
|
-
While steps can be run independently, they should generally follow this sequence:
|
|
110
|
-
|
|
111
|
-
1. `init` must be run first (loads configuration)
|
|
112
|
-
2. `enroll` should be merged before running `generate-tf-migration`
|
|
113
|
-
3. `generate-tf-migration` creates the service repo PR and state removal script
|
|
114
|
-
4. Run state removal commands from `METASTACK_STATE_REMOVAL_COMMANDS.sh` before merging cleanup PR
|
|
115
|
-
5. Run `migrate-spaces` MANUALLY after state removal but before merging cleanup PR
|
|
116
|
-
6. Merge cleanup PR before merging service repository PR
|
|
117
|
-
7. The full `run` command skips `migrate-spaces` for safety - you must run it manually
|
|
118
|
-
|
|
119
|
-
### Files Generated
|
|
41
|
+
## Commands
|
|
120
42
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
43
|
+
| Command | Description |
|
|
44
|
+
| ----------------------- | --------------------------------------------- |
|
|
45
|
+
| `init` | Clone repos, load config |
|
|
46
|
+
| `state` | Show migration state |
|
|
47
|
+
| `enroll` | Create domain enrollment PR |
|
|
48
|
+
| `generate-tf-migration` | Create service PR + state removal script |
|
|
49
|
+
| `iac-deploy-cleanup` | Create iac-deploy cleanup PR |
|
|
50
|
+
| `generate-procedure` | Generate procedure doc |
|
|
51
|
+
| `migrate-spaces` | Move stacks to domain space (manual) |
|
|
52
|
+
| `cleanup` | Create post-migration PR + remove local files |
|
|
53
|
+
|
|
54
|
+
## Execution Order
|
|
55
|
+
|
|
56
|
+
| Step | Action | Type |
|
|
57
|
+
| ---- | ----------------------------------- | --------- |
|
|
58
|
+
| 1 | Merge **Safety Net** PR | ๐ PR |
|
|
59
|
+
| 2 | Merge **Domain Enrollment** PR | ๐ PR |
|
|
60
|
+
| 3 | Run state removal script | ๐ง Manual |
|
|
61
|
+
| 4 | Merge **iac-deploy Cleanup** PR | ๐ PR |
|
|
62
|
+
| 5 | Run migrate-spaces | ๐ง Manual |
|
|
63
|
+
| 6 | Merge **Service Repo** PR | ๐ PR |
|
|
64
|
+
| 7 | Run cleanup | ๐ง Manual |
|
|
65
|
+
| 8 | Merge **Post-Migration Cleanup** PR | ๐ PR |
|
|
66
|
+
|
|
67
|
+
## Files Generated
|
|
68
|
+
|
|
69
|
+
| File | Purpose |
|
|
70
|
+
| ------------------------------------- | -------------------------------- |
|
|
71
|
+
| `.migration-state.json` | Migration state (resume anytime) |
|
|
72
|
+
| `METASTACK_MIGRATION_PROCEDURE.md` | Checklist & instructions |
|
|
73
|
+
| `METASTACK_STATE_REMOVAL_COMMANDS.sh` | State removal commands |
|
|
74
|
+
| `.metastack/import.tf` | Terraform import blocks |
|
|
75
|
+
| `spacelift.yaml` | Stack definitions |
|
|
76
|
+
|
|
77
|
+
## Notes
|
|
78
|
+
|
|
79
|
+
- State saved in `.migration-state.json`, you can resume at any time
|
|
80
|
+
- `migrate-spaces` must be run manually (not in `run` workflow)
|
|
81
|
+
- Run state removal before merging iac-deploy cleanup PR to avoid actually deleting the stacks
|
|
@@ -66,13 +66,9 @@ export declare class MigrationTool extends MigrationHelper {
|
|
|
66
66
|
*/
|
|
67
67
|
checkMigrationState(): Promise<void>;
|
|
68
68
|
/**
|
|
69
|
-
* Clean up migration files
|
|
69
|
+
* Clean up migration (creates PR + removes local files)
|
|
70
70
|
*/
|
|
71
71
|
cleanupMigration(): Promise<void>;
|
|
72
|
-
/**
|
|
73
|
-
* Create Final Cleanup PR (remove import.tf and spacelift provider from version.tf)
|
|
74
|
-
*/
|
|
75
|
-
createFinalCleanupPR(): Promise<void>;
|
|
76
72
|
/**
|
|
77
73
|
* Full migration workflow
|
|
78
74
|
*/
|