amplify-excel-migrator 1.2.9__tar.gz
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.
- amplify_excel_migrator-1.2.9/LICENSE +21 -0
- amplify_excel_migrator-1.2.9/MANIFEST.in +4 -0
- amplify_excel_migrator-1.2.9/PKG-INFO +314 -0
- amplify_excel_migrator-1.2.9/README.md +273 -0
- amplify_excel_migrator-1.2.9/amplify_client.py +193 -0
- amplify_excel_migrator-1.2.9/amplify_excel_migrator.egg-info/PKG-INFO +314 -0
- amplify_excel_migrator-1.2.9/amplify_excel_migrator.egg-info/SOURCES.txt +23 -0
- amplify_excel_migrator-1.2.9/amplify_excel_migrator.egg-info/dependency_links.txt +1 -0
- amplify_excel_migrator-1.2.9/amplify_excel_migrator.egg-info/entry_points.txt +2 -0
- amplify_excel_migrator-1.2.9/amplify_excel_migrator.egg-info/requires.txt +17 -0
- amplify_excel_migrator-1.2.9/amplify_excel_migrator.egg-info/top_level.txt +3 -0
- amplify_excel_migrator-1.2.9/migrator.py +490 -0
- amplify_excel_migrator-1.2.9/model_field_parser.py +392 -0
- amplify_excel_migrator-1.2.9/requirements.txt +19 -0
- amplify_excel_migrator-1.2.9/setup.cfg +4 -0
- amplify_excel_migrator-1.2.9/setup.py +48 -0
- amplify_excel_migrator-1.2.9/tests/__init__.py +1 -0
- amplify_excel_migrator-1.2.9/tests/test_amplify_client.py +717 -0
- amplify_excel_migrator-1.2.9/tests/test_cli_commands.py +269 -0
- amplify_excel_migrator-1.2.9/tests/test_cognito_auth.py +363 -0
- amplify_excel_migrator-1.2.9/tests/test_config_manager.py +347 -0
- amplify_excel_migrator-1.2.9/tests/test_migrator_class.py +670 -0
- amplify_excel_migrator-1.2.9/tests/test_model_field_parser.py +615 -0
- amplify_excel_migrator-1.2.9/tests/test_mutation_builder.py +391 -0
- amplify_excel_migrator-1.2.9/tests/test_query_builder.py +384 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Eyal Politansky
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: amplify-excel-migrator
|
|
3
|
+
Version: 1.2.9
|
|
4
|
+
Summary: A CLI tool to migrate Excel data to AWS Amplify
|
|
5
|
+
Home-page: https://github.com/EyalPoly/amplify-excel-migrator
|
|
6
|
+
Author: Eyal Politansky
|
|
7
|
+
Author-email: 10eyal10@gmail.com
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.8
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: pandas>=1.3.0
|
|
15
|
+
Requires-Dist: requests>=2.26.0
|
|
16
|
+
Requires-Dist: boto3>=1.18.0
|
|
17
|
+
Requires-Dist: pycognito>=2023.5.0
|
|
18
|
+
Requires-Dist: PyJWT>=2.0.0
|
|
19
|
+
Requires-Dist: aiohttp>=3.8.0
|
|
20
|
+
Requires-Dist: openpyxl>=3.0.0
|
|
21
|
+
Requires-Dist: inflect>=7.0.0
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
24
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
|
|
25
|
+
Requires-Dist: pytest-mock>=3.12.0; extra == "dev"
|
|
26
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
27
|
+
Requires-Dist: setuptools>=80.0.0; extra == "dev"
|
|
28
|
+
Requires-Dist: wheel>=0.40.0; extra == "dev"
|
|
29
|
+
Requires-Dist: twine>=4.0.0; extra == "dev"
|
|
30
|
+
Dynamic: author
|
|
31
|
+
Dynamic: author-email
|
|
32
|
+
Dynamic: classifier
|
|
33
|
+
Dynamic: description
|
|
34
|
+
Dynamic: description-content-type
|
|
35
|
+
Dynamic: home-page
|
|
36
|
+
Dynamic: license-file
|
|
37
|
+
Dynamic: provides-extra
|
|
38
|
+
Dynamic: requires-dist
|
|
39
|
+
Dynamic: requires-python
|
|
40
|
+
Dynamic: summary
|
|
41
|
+
|
|
42
|
+
# Amplify Excel Migrator
|
|
43
|
+
|
|
44
|
+
[](https://badge.fury.io/py/amplify-excel-migrator)
|
|
45
|
+
[](https://pypi.org/project/amplify-excel-migrator/)
|
|
46
|
+
[](https://pepy.tech/project/amplify-excel-migrator)
|
|
47
|
+
[](https://opensource.org/licenses/MIT)
|
|
48
|
+
|
|
49
|
+
A CLI tool to migrate data from Excel files to AWS Amplify GraphQL API.
|
|
50
|
+
Developed for the MECO project - https://github.com/sworgkh/meco-observations-amplify
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
### From PyPI (Recommended)
|
|
55
|
+
|
|
56
|
+
Install the latest stable version from PyPI:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pip install amplify-excel-migrator
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### From Source
|
|
63
|
+
|
|
64
|
+
Clone the repository and install:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
git clone https://github.com/EyalPoly/amplify-excel-migrator.git
|
|
68
|
+
cd amplify-excel-migrator
|
|
69
|
+
pip install .
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Usage
|
|
73
|
+
|
|
74
|
+
The tool has three subcommands:
|
|
75
|
+
|
|
76
|
+
### 1. Configure (First Time Setup)
|
|
77
|
+
|
|
78
|
+
Save your AWS Amplify configuration:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
amplify-migrator config
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
This will prompt you for:
|
|
85
|
+
- Excel file path
|
|
86
|
+
- AWS Amplify API endpoint
|
|
87
|
+
- AWS Region
|
|
88
|
+
- Cognito User Pool ID
|
|
89
|
+
- Cognito Client ID
|
|
90
|
+
- Admin username
|
|
91
|
+
|
|
92
|
+
Configuration is saved to `~/.amplify-migrator/config.json`
|
|
93
|
+
|
|
94
|
+
### 2. Show Configuration
|
|
95
|
+
|
|
96
|
+
View your current saved configuration:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
amplify-migrator show
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### 3. Run Migration
|
|
103
|
+
|
|
104
|
+
Run the migration using your saved configuration:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
amplify-migrator migrate
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
You'll only be prompted for your password (for security, passwords are never cached).
|
|
111
|
+
|
|
112
|
+
### Quick Start
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
# First time: configure the tool
|
|
116
|
+
amplify-migrator config
|
|
117
|
+
|
|
118
|
+
# View current configuration
|
|
119
|
+
amplify-migrator show
|
|
120
|
+
|
|
121
|
+
# Run migration (uses saved config)
|
|
122
|
+
amplify-migrator migrate
|
|
123
|
+
|
|
124
|
+
# View help
|
|
125
|
+
amplify-migrator --help
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Example: Configuration
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
╔════════════════════════════════════════════════════╗
|
|
132
|
+
║ Amplify Migrator - Configuration Setup ║
|
|
133
|
+
╚════════════════════════════════════════════════════╝
|
|
134
|
+
|
|
135
|
+
📋 Configuration Setup:
|
|
136
|
+
------------------------------------------------------
|
|
137
|
+
Excel file path [data.xlsx]: my-data.xlsx
|
|
138
|
+
AWS Amplify API endpoint: https://xxx.appsync-api.us-east-1.amazonaws.com/graphql
|
|
139
|
+
AWS Region [us-east-1]:
|
|
140
|
+
Cognito User Pool ID: us-east-1_xxxxx
|
|
141
|
+
Cognito Client ID: your-client-id
|
|
142
|
+
Admin Username: admin@example.com
|
|
143
|
+
|
|
144
|
+
✅ Configuration saved successfully!
|
|
145
|
+
💡 You can now run 'amplify-migrator migrate' to start the migration.
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Example: Migration
|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
╔════════════════════════════════════════════════════╗
|
|
152
|
+
║ Migrator Tool for Amplify ║
|
|
153
|
+
╠════════════════════════════════════════════════════╣
|
|
154
|
+
║ This tool requires admin privileges to execute ║
|
|
155
|
+
╚════════════════════════════════════════════════════╝
|
|
156
|
+
|
|
157
|
+
🔐 Authentication:
|
|
158
|
+
------------------------------------------------------
|
|
159
|
+
Admin Password: ********
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Requirements
|
|
163
|
+
|
|
164
|
+
- Python 3.8+
|
|
165
|
+
- AWS Amplify GraphQL API
|
|
166
|
+
- AWS Cognito User Pool
|
|
167
|
+
- Admin access to the Cognito User Pool
|
|
168
|
+
|
|
169
|
+
## Features
|
|
170
|
+
|
|
171
|
+
### Data Processing & Conversion
|
|
172
|
+
- **Automatic type parsing** - Smart field type detection for all GraphQL types including scalars, enums, and custom types
|
|
173
|
+
- **Custom types and enums** - Full support for Amplify custom types with automatic conversion
|
|
174
|
+
- **Duplicate detection** - Automatically skips existing records to prevent duplicates
|
|
175
|
+
- **Foreign key resolution** - Automatic relationship handling with pre-fetching for performance
|
|
176
|
+
|
|
177
|
+
### AWS Integration
|
|
178
|
+
- **Configuration caching** - Save your setup, reuse it for multiple migrations
|
|
179
|
+
- **MFA support** - Works with multi-factor authentication
|
|
180
|
+
- **Admin group validation** - Ensures proper authorization before migration
|
|
181
|
+
|
|
182
|
+
### Performance
|
|
183
|
+
- **Async uploads** - Fast parallel uploads with configurable batch size
|
|
184
|
+
- **Connection pooling** - Efficient HTTP connection reuse for better performance
|
|
185
|
+
- **Pagination support** - Handles large datasets efficiently
|
|
186
|
+
|
|
187
|
+
### User Experience
|
|
188
|
+
- **Interactive prompts** - Easy step-by-step configuration
|
|
189
|
+
- **Progress reporting** - Real-time feedback on migration status
|
|
190
|
+
- **Detailed error messages** - Clear context for troubleshooting failures
|
|
191
|
+
|
|
192
|
+
## Excel File Format
|
|
193
|
+
|
|
194
|
+
The Excel file should have:
|
|
195
|
+
- One sheet per Amplify model (sheet name must match model name)
|
|
196
|
+
- Column names matching the model field names
|
|
197
|
+
- First row as headers
|
|
198
|
+
|
|
199
|
+
### Basic Structure
|
|
200
|
+
|
|
201
|
+
**Sheet: User**
|
|
202
|
+
|
|
203
|
+
| name | email | age |
|
|
204
|
+
|------|-------|-----|
|
|
205
|
+
| John | john@example.com | 30 |
|
|
206
|
+
| Jane | jane@example.com | 25 |
|
|
207
|
+
|
|
208
|
+
**Sheet: Post**
|
|
209
|
+
|
|
210
|
+
| title | content | userId |
|
|
211
|
+
|-------|---------|--------|
|
|
212
|
+
| First Post | Hello World | john@example.com |
|
|
213
|
+
|
|
214
|
+
### Relationships (Foreign Keys)
|
|
215
|
+
|
|
216
|
+
To reference related records, use the primary key value of the related model:
|
|
217
|
+
|
|
218
|
+
**Sheet: Comment**
|
|
219
|
+
|
|
220
|
+
| content | postId | userId |
|
|
221
|
+
|--------------|----------|------------------|
|
|
222
|
+
| Great post! | post-123 | john@example.com |
|
|
223
|
+
|
|
224
|
+
The tool automatically resolves foreign keys by looking up the related records.
|
|
225
|
+
|
|
226
|
+
### Array/List Fields
|
|
227
|
+
|
|
228
|
+
Array fields support multiple input formats:
|
|
229
|
+
|
|
230
|
+
- **JSON format:** `["tag1", "tag2", "tag3"]`
|
|
231
|
+
- **Semicolon-separated:** `tag1; tag2; tag3`
|
|
232
|
+
- **Comma-separated:** `tag1, tag2, tag3`
|
|
233
|
+
|
|
234
|
+
## Advanced Features
|
|
235
|
+
|
|
236
|
+
- **Foreign Key Resolution** - Automatically resolves relationships between models with pre-fetching for optimal performance
|
|
237
|
+
- **Schema Introspection** - Dynamically queries your GraphQL schema to understand model structures and field types
|
|
238
|
+
- **Configurable Batch Processing** - Tune upload performance with adjustable batch sizes (default: 20 records per batch)
|
|
239
|
+
- **Progress Reporting** - Real-time batch progress with per-sheet confirmation prompts before upload
|
|
240
|
+
|
|
241
|
+
## Error Handling & Recovery
|
|
242
|
+
|
|
243
|
+
When records fail to upload, the tool provides a robust recovery mechanism to help you identify and fix issues without starting over.
|
|
244
|
+
|
|
245
|
+
### How It Works
|
|
246
|
+
|
|
247
|
+
1. **Automatic Error Capture** - Each failed record is logged with detailed error messages explaining what went wrong
|
|
248
|
+
2. **Failed Records Export** - After migration completes, you'll be prompted to export failed records to a new Excel file with a timestamp (e.g., `data_failed_records_20251201_143022.xlsx`)
|
|
249
|
+
3. **Easy Retry** - Fix the issues in the exported file and run the migration again using only the failed records
|
|
250
|
+
4. **Progress Visibility** - Detailed summary shows success/failure counts, percentages, and specific error reasons for each failed record
|
|
251
|
+
|
|
252
|
+
### Recovery Workflow Example
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
# Run initial migration
|
|
256
|
+
amplify-migrator migrate
|
|
257
|
+
|
|
258
|
+
# Migration completes with some failures:
|
|
259
|
+
# ✅ Successfully uploaded: 95 records (95%)
|
|
260
|
+
# ❌ Failed to upload: 5 records (5%)
|
|
261
|
+
#
|
|
262
|
+
# Export failed records? (y/n): y
|
|
263
|
+
# Failed records exported to: data_failed_records_20251201_143022.xlsx
|
|
264
|
+
|
|
265
|
+
# Fix the errors in the exported Excel file
|
|
266
|
+
# Then re-run migration with the failed records file
|
|
267
|
+
|
|
268
|
+
amplify-migrator migrate
|
|
269
|
+
# Excel file path: data_failed_records_20251201_143022.xlsx
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
The tool tracks which records succeeded and failed, providing row-level context to help you quickly identify and resolve issues.
|
|
273
|
+
|
|
274
|
+
## Troubleshooting
|
|
275
|
+
|
|
276
|
+
### Authentication Errors
|
|
277
|
+
|
|
278
|
+
**Error: Unable to authenticate with Cognito**
|
|
279
|
+
- Verify your Cognito User Pool ID and Client ID are correct
|
|
280
|
+
- Ensure your username and password are valid
|
|
281
|
+
- Check that your user is in the ADMINS group
|
|
282
|
+
|
|
283
|
+
### MFA Issues
|
|
284
|
+
|
|
285
|
+
**Error: MFA required but not configured**
|
|
286
|
+
- Enable MFA in your Cognito User Pool settings
|
|
287
|
+
- Ensure your user has MFA set up (SMS or software token)
|
|
288
|
+
|
|
289
|
+
### AWS Credentials
|
|
290
|
+
|
|
291
|
+
**Error: AWS credentials not found**
|
|
292
|
+
- Set up AWS credentials in `~/.aws/credentials`
|
|
293
|
+
- Or set environment variables: `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_DEFAULT_REGION`
|
|
294
|
+
- Or use `aws configure` to set up your default profile
|
|
295
|
+
|
|
296
|
+
### Excel File Format
|
|
297
|
+
|
|
298
|
+
**Error: Sheet name does not match any model**
|
|
299
|
+
- Ensure sheet names exactly match your Amplify GraphQL model names (case-sensitive)
|
|
300
|
+
- Check for extra spaces or special characters in sheet names
|
|
301
|
+
|
|
302
|
+
**Error: Required field missing**
|
|
303
|
+
- Verify all required fields in your GraphQL schema have corresponding columns in Excel
|
|
304
|
+
- Check column names match field names (case-sensitive)
|
|
305
|
+
|
|
306
|
+
### Permission Errors
|
|
307
|
+
|
|
308
|
+
**Error: User is not in ADMINS group**
|
|
309
|
+
- Add your user to the ADMINS group in Cognito User Pool
|
|
310
|
+
- Contact your AWS administrator if you don't have permission
|
|
311
|
+
|
|
312
|
+
## License
|
|
313
|
+
|
|
314
|
+
MIT
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
# Amplify Excel Migrator
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/py/amplify-excel-migrator)
|
|
4
|
+
[](https://pypi.org/project/amplify-excel-migrator/)
|
|
5
|
+
[](https://pepy.tech/project/amplify-excel-migrator)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
A CLI tool to migrate data from Excel files to AWS Amplify GraphQL API.
|
|
9
|
+
Developed for the MECO project - https://github.com/sworgkh/meco-observations-amplify
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
### From PyPI (Recommended)
|
|
14
|
+
|
|
15
|
+
Install the latest stable version from PyPI:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install amplify-excel-migrator
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### From Source
|
|
22
|
+
|
|
23
|
+
Clone the repository and install:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
git clone https://github.com/EyalPoly/amplify-excel-migrator.git
|
|
27
|
+
cd amplify-excel-migrator
|
|
28
|
+
pip install .
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
The tool has three subcommands:
|
|
34
|
+
|
|
35
|
+
### 1. Configure (First Time Setup)
|
|
36
|
+
|
|
37
|
+
Save your AWS Amplify configuration:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
amplify-migrator config
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
This will prompt you for:
|
|
44
|
+
- Excel file path
|
|
45
|
+
- AWS Amplify API endpoint
|
|
46
|
+
- AWS Region
|
|
47
|
+
- Cognito User Pool ID
|
|
48
|
+
- Cognito Client ID
|
|
49
|
+
- Admin username
|
|
50
|
+
|
|
51
|
+
Configuration is saved to `~/.amplify-migrator/config.json`
|
|
52
|
+
|
|
53
|
+
### 2. Show Configuration
|
|
54
|
+
|
|
55
|
+
View your current saved configuration:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
amplify-migrator show
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### 3. Run Migration
|
|
62
|
+
|
|
63
|
+
Run the migration using your saved configuration:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
amplify-migrator migrate
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
You'll only be prompted for your password (for security, passwords are never cached).
|
|
70
|
+
|
|
71
|
+
### Quick Start
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# First time: configure the tool
|
|
75
|
+
amplify-migrator config
|
|
76
|
+
|
|
77
|
+
# View current configuration
|
|
78
|
+
amplify-migrator show
|
|
79
|
+
|
|
80
|
+
# Run migration (uses saved config)
|
|
81
|
+
amplify-migrator migrate
|
|
82
|
+
|
|
83
|
+
# View help
|
|
84
|
+
amplify-migrator --help
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Example: Configuration
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
╔════════════════════════════════════════════════════╗
|
|
91
|
+
║ Amplify Migrator - Configuration Setup ║
|
|
92
|
+
╚════════════════════════════════════════════════════╝
|
|
93
|
+
|
|
94
|
+
📋 Configuration Setup:
|
|
95
|
+
------------------------------------------------------
|
|
96
|
+
Excel file path [data.xlsx]: my-data.xlsx
|
|
97
|
+
AWS Amplify API endpoint: https://xxx.appsync-api.us-east-1.amazonaws.com/graphql
|
|
98
|
+
AWS Region [us-east-1]:
|
|
99
|
+
Cognito User Pool ID: us-east-1_xxxxx
|
|
100
|
+
Cognito Client ID: your-client-id
|
|
101
|
+
Admin Username: admin@example.com
|
|
102
|
+
|
|
103
|
+
✅ Configuration saved successfully!
|
|
104
|
+
💡 You can now run 'amplify-migrator migrate' to start the migration.
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Example: Migration
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
╔════════════════════════════════════════════════════╗
|
|
111
|
+
║ Migrator Tool for Amplify ║
|
|
112
|
+
╠════════════════════════════════════════════════════╣
|
|
113
|
+
║ This tool requires admin privileges to execute ║
|
|
114
|
+
╚════════════════════════════════════════════════════╝
|
|
115
|
+
|
|
116
|
+
🔐 Authentication:
|
|
117
|
+
------------------------------------------------------
|
|
118
|
+
Admin Password: ********
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Requirements
|
|
122
|
+
|
|
123
|
+
- Python 3.8+
|
|
124
|
+
- AWS Amplify GraphQL API
|
|
125
|
+
- AWS Cognito User Pool
|
|
126
|
+
- Admin access to the Cognito User Pool
|
|
127
|
+
|
|
128
|
+
## Features
|
|
129
|
+
|
|
130
|
+
### Data Processing & Conversion
|
|
131
|
+
- **Automatic type parsing** - Smart field type detection for all GraphQL types including scalars, enums, and custom types
|
|
132
|
+
- **Custom types and enums** - Full support for Amplify custom types with automatic conversion
|
|
133
|
+
- **Duplicate detection** - Automatically skips existing records to prevent duplicates
|
|
134
|
+
- **Foreign key resolution** - Automatic relationship handling with pre-fetching for performance
|
|
135
|
+
|
|
136
|
+
### AWS Integration
|
|
137
|
+
- **Configuration caching** - Save your setup, reuse it for multiple migrations
|
|
138
|
+
- **MFA support** - Works with multi-factor authentication
|
|
139
|
+
- **Admin group validation** - Ensures proper authorization before migration
|
|
140
|
+
|
|
141
|
+
### Performance
|
|
142
|
+
- **Async uploads** - Fast parallel uploads with configurable batch size
|
|
143
|
+
- **Connection pooling** - Efficient HTTP connection reuse for better performance
|
|
144
|
+
- **Pagination support** - Handles large datasets efficiently
|
|
145
|
+
|
|
146
|
+
### User Experience
|
|
147
|
+
- **Interactive prompts** - Easy step-by-step configuration
|
|
148
|
+
- **Progress reporting** - Real-time feedback on migration status
|
|
149
|
+
- **Detailed error messages** - Clear context for troubleshooting failures
|
|
150
|
+
|
|
151
|
+
## Excel File Format
|
|
152
|
+
|
|
153
|
+
The Excel file should have:
|
|
154
|
+
- One sheet per Amplify model (sheet name must match model name)
|
|
155
|
+
- Column names matching the model field names
|
|
156
|
+
- First row as headers
|
|
157
|
+
|
|
158
|
+
### Basic Structure
|
|
159
|
+
|
|
160
|
+
**Sheet: User**
|
|
161
|
+
|
|
162
|
+
| name | email | age |
|
|
163
|
+
|------|-------|-----|
|
|
164
|
+
| John | john@example.com | 30 |
|
|
165
|
+
| Jane | jane@example.com | 25 |
|
|
166
|
+
|
|
167
|
+
**Sheet: Post**
|
|
168
|
+
|
|
169
|
+
| title | content | userId |
|
|
170
|
+
|-------|---------|--------|
|
|
171
|
+
| First Post | Hello World | john@example.com |
|
|
172
|
+
|
|
173
|
+
### Relationships (Foreign Keys)
|
|
174
|
+
|
|
175
|
+
To reference related records, use the primary key value of the related model:
|
|
176
|
+
|
|
177
|
+
**Sheet: Comment**
|
|
178
|
+
|
|
179
|
+
| content | postId | userId |
|
|
180
|
+
|--------------|----------|------------------|
|
|
181
|
+
| Great post! | post-123 | john@example.com |
|
|
182
|
+
|
|
183
|
+
The tool automatically resolves foreign keys by looking up the related records.
|
|
184
|
+
|
|
185
|
+
### Array/List Fields
|
|
186
|
+
|
|
187
|
+
Array fields support multiple input formats:
|
|
188
|
+
|
|
189
|
+
- **JSON format:** `["tag1", "tag2", "tag3"]`
|
|
190
|
+
- **Semicolon-separated:** `tag1; tag2; tag3`
|
|
191
|
+
- **Comma-separated:** `tag1, tag2, tag3`
|
|
192
|
+
|
|
193
|
+
## Advanced Features
|
|
194
|
+
|
|
195
|
+
- **Foreign Key Resolution** - Automatically resolves relationships between models with pre-fetching for optimal performance
|
|
196
|
+
- **Schema Introspection** - Dynamically queries your GraphQL schema to understand model structures and field types
|
|
197
|
+
- **Configurable Batch Processing** - Tune upload performance with adjustable batch sizes (default: 20 records per batch)
|
|
198
|
+
- **Progress Reporting** - Real-time batch progress with per-sheet confirmation prompts before upload
|
|
199
|
+
|
|
200
|
+
## Error Handling & Recovery
|
|
201
|
+
|
|
202
|
+
When records fail to upload, the tool provides a robust recovery mechanism to help you identify and fix issues without starting over.
|
|
203
|
+
|
|
204
|
+
### How It Works
|
|
205
|
+
|
|
206
|
+
1. **Automatic Error Capture** - Each failed record is logged with detailed error messages explaining what went wrong
|
|
207
|
+
2. **Failed Records Export** - After migration completes, you'll be prompted to export failed records to a new Excel file with a timestamp (e.g., `data_failed_records_20251201_143022.xlsx`)
|
|
208
|
+
3. **Easy Retry** - Fix the issues in the exported file and run the migration again using only the failed records
|
|
209
|
+
4. **Progress Visibility** - Detailed summary shows success/failure counts, percentages, and specific error reasons for each failed record
|
|
210
|
+
|
|
211
|
+
### Recovery Workflow Example
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
# Run initial migration
|
|
215
|
+
amplify-migrator migrate
|
|
216
|
+
|
|
217
|
+
# Migration completes with some failures:
|
|
218
|
+
# ✅ Successfully uploaded: 95 records (95%)
|
|
219
|
+
# ❌ Failed to upload: 5 records (5%)
|
|
220
|
+
#
|
|
221
|
+
# Export failed records? (y/n): y
|
|
222
|
+
# Failed records exported to: data_failed_records_20251201_143022.xlsx
|
|
223
|
+
|
|
224
|
+
# Fix the errors in the exported Excel file
|
|
225
|
+
# Then re-run migration with the failed records file
|
|
226
|
+
|
|
227
|
+
amplify-migrator migrate
|
|
228
|
+
# Excel file path: data_failed_records_20251201_143022.xlsx
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
The tool tracks which records succeeded and failed, providing row-level context to help you quickly identify and resolve issues.
|
|
232
|
+
|
|
233
|
+
## Troubleshooting
|
|
234
|
+
|
|
235
|
+
### Authentication Errors
|
|
236
|
+
|
|
237
|
+
**Error: Unable to authenticate with Cognito**
|
|
238
|
+
- Verify your Cognito User Pool ID and Client ID are correct
|
|
239
|
+
- Ensure your username and password are valid
|
|
240
|
+
- Check that your user is in the ADMINS group
|
|
241
|
+
|
|
242
|
+
### MFA Issues
|
|
243
|
+
|
|
244
|
+
**Error: MFA required but not configured**
|
|
245
|
+
- Enable MFA in your Cognito User Pool settings
|
|
246
|
+
- Ensure your user has MFA set up (SMS or software token)
|
|
247
|
+
|
|
248
|
+
### AWS Credentials
|
|
249
|
+
|
|
250
|
+
**Error: AWS credentials not found**
|
|
251
|
+
- Set up AWS credentials in `~/.aws/credentials`
|
|
252
|
+
- Or set environment variables: `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_DEFAULT_REGION`
|
|
253
|
+
- Or use `aws configure` to set up your default profile
|
|
254
|
+
|
|
255
|
+
### Excel File Format
|
|
256
|
+
|
|
257
|
+
**Error: Sheet name does not match any model**
|
|
258
|
+
- Ensure sheet names exactly match your Amplify GraphQL model names (case-sensitive)
|
|
259
|
+
- Check for extra spaces or special characters in sheet names
|
|
260
|
+
|
|
261
|
+
**Error: Required field missing**
|
|
262
|
+
- Verify all required fields in your GraphQL schema have corresponding columns in Excel
|
|
263
|
+
- Check column names match field names (case-sensitive)
|
|
264
|
+
|
|
265
|
+
### Permission Errors
|
|
266
|
+
|
|
267
|
+
**Error: User is not in ADMINS group**
|
|
268
|
+
- Add your user to the ADMINS group in Cognito User Pool
|
|
269
|
+
- Contact your AWS administrator if you don't have permission
|
|
270
|
+
|
|
271
|
+
## License
|
|
272
|
+
|
|
273
|
+
MIT
|