Skip to content

Commit a26a0fb

Browse files
authored
Merge pull request #801 from h-kopalle/main
Apigee Edge to X Migration Tool
2 parents 1a52340 + dfd6fa4 commit a26a0fb

File tree

131 files changed

+12078
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+12078
-1
lines changed

.github/workflows/devrel-static-checks.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ jobs:
7575
GROOVY_NPM_GROOVY_LINT_FILTER_REGEX_EXCLUDE: "Jenkinsfile"
7676
MARKDOWN_MARKDOWN_LINK_CHECK_DISABLE_ERRORS: true
7777
PYTHON_MYPY_DISABLE_ERRORS: true
78+
FILTER_REGEX_EXCLUDE: ".*apigee-edge-to-x-migration-tool.*"
7879

7980
commit-messages:
8081
name: Conventional Commits Lint

CODEOWNERS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@
4040
/tools/proxy-endpoint-unifier @anaik91
4141
/tools/sf-dependency-list @yuriylesyuk
4242
/tools/target-server-validator @anaik91
43-
tools/apigee-proxy-modifier-validator @anaik91
43+
/tools/apigee-proxy-modifier-validator @anaik91
44+
/tools/apigee-edge-to-x-migration-tool @h-kopalle

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ Apigee products.
113113
Generate gateways to expose gRPC services with HTTP API management.
114114
- [Apigee Proxy Bundle Modifier & Validator](tools/apigee-proxy-modifier-validator) -
115115
A tool to do batch modifications of API proxies when migrating to newer Apigee variants.
116+
- [Apigee Edge to X Migration Accelerator](/tools/apigee-edge-to-x-migration-tool) - A tool built on node.js to accelerate Apigee Edge to X migration.
117+
116118
## Labs
117119

118120
This folder contains raw assets used to generate content to teach a particular
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"env": {
3+
"es2022": true,
4+
"node": true
5+
},
6+
"parserOptions": {
7+
"ecmaVersion": 2022,
8+
"sourceType": "module"
9+
}
10+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.DS_Store
2+
.env
3+
.vscode
4+
node_modules
5+
data
Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
# Apigee Edge to X Migration Tool
2+
3+
## Introduction
4+
The **Apigee Edge to X Migration Tool** is designed to facilitate the seamless transition of entities from Apigee Edge to the new Apigee X platform. This tool streamlines the migration process, ensuring minimal disruption and optimal performance during the transition.
5+
6+
## Features
7+
- **Automated Migration:** Effortlessly migrate your entities from Edge to X.
8+
- **Custom Module Support:** Extend functionality by adding custom modules.
9+
- **User-Friendly Interface:** Navigate through the migration tool with an intuitive prompts menu.
10+
- **Comprehensive Logging:** Track the migration process with detailed logs for troubleshooting and analysis.
11+
12+
## Prerequisites
13+
- **Node.js:** Ensure Node.js is installed on your system.
14+
- **Git:** Required for cloning repositories and managing version control.
15+
- **Access:**
16+
- Edge credentials with atleast Read-Only privileges
17+
- Apigee X Service Account Key
18+
19+
## Setup Instructions
20+
21+
1. **Clone the Repository**
22+
- Clone the `apigee/devrel` repository to your local machine:
23+
```bash
24+
git clone <git-repo-url>
25+
```
26+
27+
2. **Checkout the Relevant Branch**
28+
- For the release version, checkout the `main` branch:
29+
```bash
30+
git checkout main
31+
```
32+
33+
3. **Custom Modules**
34+
- Custom Modules built in-line to the framework can be used to extend the features.
35+
- If there are any custom modules, add the code base under `src/modules`.
36+
37+
4. **Environment Setup**
38+
- `.env` file is required with below information
39+
```bash
40+
# Configure the source gateway type:
41+
# - apigee_edge
42+
# - apigee_x
43+
source_gateway_type="apigee_edge"
44+
45+
# Configure the base URL for the source gateway's management APIs
46+
source_gateway_base_url="https://api.enterprise.apigee.com/v1/organizations/"
47+
48+
# When source gateway is Apigee, configure the name of the Apigee org
49+
source_gateway_org="<edge-org>"
50+
51+
# When source gateway is Apigee X, configure the service account
52+
# used to connect to management APIs. Base64 encode the service account JSON.
53+
# Ignore if source_gateway_type="apigee_edge"
54+
source_gateway_service_account = ""
55+
56+
# Configure the destination gateway type:
57+
# - apigee_edge
58+
# - apigee_x
59+
destination_gateway_type="apigee_x"
60+
61+
# Configure the base URL for the destination gateway's management APIs
62+
destination_gateway_base_url="https://apigee.googleapis.com/v1/organizations/"
63+
64+
# When destination gateway is Apigee, configure the name of the Apigee org
65+
destination_gateway_org="<apigee-x-org>"
66+
67+
# When destination gateway is Apigee X, configure the service account
68+
# used to connect to management APIs. Base64 encode the service account JSON.
69+
destination_gateway_service_account = ""
70+
71+
# When source and destination gateways are both Apigee, configure the mapping
72+
# between source gateway environment names to destination gateway environment names.
73+
apigee_environment_map='{"edge-env":"x-env"}'
74+
75+
# Configure whether to auto-npm-install plugins placed in the ~/src/modules folder
76+
install_modules = 1
77+
```
78+
- Load Apigee Edge credentials into environment variables
79+
```bash
80+
export source_gateway_username="<edge_username>"
81+
export source_gateway_password="<edge_password>"
82+
```
83+
- For building the value for `destination_gateway_service_account`, you need to build a JSON file in below structure and must base64encode. Copy the final result as value for `destination_gateway_service_account`
84+
```json
85+
{"instance_type":"hybrid","organization":"<YOUR_PROJECT_ID>","account_json_key":<SERVICE_ACCOUNT_KEY_JSON>}
86+
```
87+
88+
```bash
89+
base64 <<< 'above_json_value'
90+
```
91+
92+
93+
## Execution Instructions
94+
95+
1. **Open Terminal**
96+
- Open the terminal or command line interface in the `apigee-edge-to-x-migration-tool` directory.
97+
98+
2. **Launch the Tool**
99+
- The tool features a setup helper `tool-setup.sh`. Provide execute permissions to the file.
100+
```bash
101+
chmod +x tool-setup.sh
102+
```
103+
- Use the same for the initial set up and auto launch
104+
```bash
105+
./tool-setup.sh
106+
```
107+
108+
3. **Run the Program**
109+
- After the initial launch, tool presents the Menu options.
110+
- Whenever you need to launch the tool without the setup helper, in your terminal use the command
111+
```bash
112+
apigee-migration-tool
113+
```
114+
4. **Selecting from Menu**
115+
- Navigate through the program using the arrow keys.
116+
- Follow the instructions in the menu, user helper text for understanding the option.
117+
- Press `<enter>` to proceed with your selection.
118+
- At any time, use `Back` menu option to return to previous menu.
119+
- At any time, use `Exit` menu option to exit the tool.
120+
- Primary Action in tool.
121+
```bash
122+
apigee-migration-tool
123+
? Choose a tool (Use arrow keys)
124+
❯ Apigee Edge to X
125+
```
126+
- Features available in the tool
127+
```bash
128+
apigee-e2x
129+
✔ Choose a tool Apigee Edge to X
130+
? Action (Use arrow keys)
131+
❯ Migrate
132+
View Logs
133+
```
134+
135+
## Migrate
136+
- Menu option to be selected for migrating entities from Apigee Edge to X.
137+
### Supported Apigee Entities
138+
The tool currently features options to migrate
139+
- API Proxies (All revisions included)
140+
- Shared Flows (All revisions included)
141+
- API Products
142+
- Developers
143+
- Developer Apps
144+
- Key Value Maps (Encrypted KVMs excluded)
145+
- Resource Files (Enviroment Level Only)
146+
147+
### Execution Model:
148+
- Once a supported Entity is selected for migration, the tool presents you the options to select an execution model.
149+
- Recommendation is to select one appropriate to the migration stage.
150+
1. **Migrate**
151+
152+
- Description:
153+
- `Migrates entities` only if they do not already exist in the `target environment`.
154+
- Use When:
155+
- You're running the migration for the first time or want to avoid overwriting `any existing resources`.
156+
- Effect:
157+
- `Skips already existing entities` and `logs them as duplicates` in the `migration summary`.
158+
159+
2. **Synchronize**
160+
161+
- Description:
162+
- Compares existing entities between `Apigee Edge (source) and Apigee X (target)`. Only entities with differences are updated.
163+
- Use When:
164+
- You want to sync environments safely, ensuring only updated content is migrated.
165+
- Effect:
166+
- Identical entities are skipped, and only changed ones are updated. No unnecessary overwrites.
167+
- For any conflicting values , data in `Apigee X (target)` is considered as final value.
168+
- Only net new values from `Apigee Edge (source)` will be synchronized.
169+
170+
3. **Overwrite**
171+
172+
- Description:
173+
- `Deletes and fully replaces` existing entities in the target environment with those from the source.
174+
- Use When:
175+
- You want to fully `refresh or replace` outdated entities in the target system.
176+
- Effect:
177+
- Only when entity name matches on both source and target
178+
- Matched entities in `Apigee X (target)` are `deleted and re-created/migrated` from the source. This is a `destructive operation`, so use with caution.
179+
180+
## View Logs
181+
182+
- Menu Option to View Status, Summary, Delta Information and Logs.
183+
- Menu Option, `All Entities` collects information of supported Entities.
184+
- All the logs are printed to console only. Adjust the console for a better visibility.
185+
- Any additonal lookup can be done using the data available.
186+
187+
1. **Stats**
188+
189+
- Select to view migration status of one/all entities.
190+
- In the sub-menu, select to view by status of migration
191+
192+
2. **Summary**
193+
194+
- Select to view migration summary of one/all entities.
195+
196+
3. **Delta**
197+
198+
- Select to view the delta information identified by comparing source and target entity
199+
200+
4. **Logs**
201+
202+
- Select to view transaction logs.
203+
- Paginated by 200 records at a time, multiple tables of logs will be provided
204+
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env node
2+
/**
3+
* Copyright 2025 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
19+
import { select } from '@inquirer/prompts';
20+
import getSupportedModules from './src/modules/index.js';
21+
22+
const modules = await getSupportedModules();
23+
24+
if (modules.length == 0) {
25+
console.log('No tools are available for migrating between your configured source and destination gateway types.');
26+
process.exit();
27+
}
28+
29+
const moduleId = await select({
30+
message: 'Choose a tool',
31+
choices: modules.map((module, idx) => ({
32+
name: module.name,
33+
value: idx
34+
}))
35+
});
36+
37+
const actions = modules[moduleId].actions();
38+
39+
const actionId = await select({
40+
message: 'Action',
41+
choices: actions.map((action, idx) => ({
42+
name: action.name,
43+
value: idx
44+
}))
45+
});
46+
47+
await actions[actionId].execute();
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import path from 'path'
18+
import fs from 'fs'
19+
import child_process from 'child_process'
20+
import dotenv from 'dotenv';
21+
22+
dotenv.config();
23+
24+
if ((process.env.install_modules ?? null) !== "1") {
25+
process.exit();
26+
}
27+
28+
const modulesPath = `${process.cwd()}/src/modules`;
29+
30+
for (let moduleName of fs.readdirSync(modulesPath)) {
31+
const modulePath = path.join(modulesPath, moduleName);
32+
const packageJsonPath = path.join(modulePath, 'package.json');
33+
34+
if (!fs.statSync(modulePath).isDirectory() || !fs.existsSync(packageJsonPath)) {
35+
continue;
36+
}
37+
38+
console.log(`Installing module ${moduleName}`);
39+
child_process.execSync('npm install', { cwd: modulePath, env: process.env, stdio: 'inherit' })
40+
}

0 commit comments

Comments
 (0)