Skip to content

Commit be9aee2

Browse files
committed
Merge branch 'feature/refactor-publish-deploy' into 'develop'
Consolidated publish and headless deploy into idp-cli See merge request genaiic-reusable-assets/engagement-artifacts/genaiic-idp-accelerator!592
2 parents 0d4fe04 + c35427b commit be9aee2

28 files changed

Lines changed: 5122 additions & 4715 deletions

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ SPDX-License-Identifier: MIT-0
55

66
## [Unreleased]
77

8+
### Added
9+
10+
- **Consolidated publish and headless deploy into `idp-cli`** — All build/publish/deploy functionality now available through the CLI, deprecating standalone scripts:
11+
- `publish.py` and `publish.sh` are deprecated — use `idp-cli publish` instead. `publish.py` remains as a thin backward-compatibility wrapper. `publish.sh` has been removed.
12+
- `scripts/generate_govcloud_template.py` is deprecated — use `idp-cli publish --headless` or `idp-cli deploy --headless` instead. The script remains as a thin wrapper.
13+
- New `--template-file` option on `idp-cli deploy` for deploying from a local CloudFormation template file produced by a previous `idp-cli publish`.
14+
- `idp-cli deploy --headless` (without `--from-code`) now downloads the published template, transforms to headless with GovCloud config defaults, uploads to S3, and deploys — all in one command.
15+
816
## [0.5.3]
917

1018
### Added

CLAUDE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ python3 publish.py idp-1234567890 idp us-east-1
2424
# With verbose output for debugging build failures
2525
python3 publish.py idp-1234567890 idp us-east-1 --verbose
2626

27-
# Legacy build script
28-
./publish.sh <cfn_bucket_basename> <cfn_prefix> <region>
2927
```
3028

3129
The build process:
@@ -91,8 +89,10 @@ pytest -m "integration"
9189
The IDP CLI is used for programmatic deployment and batch processing:
9290

9391
```bash
94-
# Install CLI
92+
# Install all packages into current Python environment
9593
make setup
94+
# Or create an isolated .venv first
95+
make setup-venv
9696

9797
# Deploy a new stack
9898
idp-cli deploy \

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ The project uses `make` to simplify common development tasks. Run `make` or `mak
127127

128128
| Command | Description |
129129
|---------|-------------|
130-
| `make setup` | Create virtual environment and install all packages in development mode |
130+
| `make setup` | Install all packages into your current Python environment (no venv) |
131+
| `make setup-venv` | Create `.venv` virtual environment and install all packages into it |
131132

132133
### Code Quality
133134

Makefile

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,33 @@ help: ## Show this help message
4343
all: lint test ## Run lint + test (default)
4444

4545
##@ Setup
46-
setup: ## Create venv and install all packages in development mode
46+
setup: ## Install all packages into current Python environment (no venv)
47+
@# Always use the current shell's pip, ignoring .venv even if it exists
48+
@SETUP_PIP=$$(python3 -m pip --version >/dev/null 2>&1 && echo "python3 -m pip" || echo "pip3"); \
49+
SETUP_PYTHON=$$(command -v python3 2>/dev/null || echo python); \
50+
echo "Installing packages into current Python environment..."; \
51+
echo "Python: $$($$SETUP_PYTHON --version) at $$(which $$SETUP_PYTHON)"; \
52+
echo "Pip: $$SETUP_PIP"; \
53+
echo ""; \
54+
echo "Upgrading pip..."; \
55+
$$SETUP_PIP install --upgrade pip && \
56+
echo "Installing idp_common package with all dependencies (including test)..." && \
57+
$$SETUP_PIP install -e "lib/idp_common_pkg[all,dev,test]" && \
58+
echo "Installing idp-cli package..." && \
59+
$$SETUP_PIP install -e lib/idp_cli_pkg && \
60+
echo "Installing idp_sdk package..." && \
61+
$$SETUP_PIP install -e lib/idp_sdk && \
62+
echo "Installing idp_mcp_connector package..." && \
63+
$$SETUP_PIP install -e lib/idp_mcp_connector_pkg && \
64+
echo "Installing capacity planning test dependencies..." && \
65+
$$SETUP_PIP install -r src/lambda/calculate_capacity/requirements-test.txt && \
66+
echo "Installing cfn-lint for CloudFormation template validation..." && \
67+
$$SETUP_PIP install cfn-lint && \
68+
echo "" && \
69+
echo -e "$(GREEN)✅ Setup complete! idp_common, idp-cli, idp_sdk, idp_mcp_connector, and test dependencies are now installed.$(NC)" && \
70+
echo -e "$(YELLOW) Tip: Use 'make setup-venv' instead to install into an isolated virtual environment.$(NC)"
71+
72+
setup-venv: ## Create .venv and install all packages into it
4773
@echo "Creating virtual environment in $(VENV_DIR)..."
4874
@PYENV_PYTHON=$$(pyenv which python 2>/dev/null); \
4975
SYS_PYTHON=$$(command -v python3 2>/dev/null); \
@@ -66,6 +92,8 @@ setup: ## Create venv and install all packages in development mode
6692
$(VENV_DIR)/bin/pip install -e lib/idp_mcp_connector_pkg
6793
@echo "Installing capacity planning test dependencies..."
6894
$(VENV_DIR)/bin/pip install -r src/lambda/calculate_capacity/requirements-test.txt
95+
@echo "Installing cfn-lint for CloudFormation template validation..."
96+
$(VENV_DIR)/bin/pip install cfn-lint
6997
@echo ""
7098
@echo -e "$(GREEN)✅ Setup complete! Virtual environment created at $(VENV_DIR)$(NC)"
7199
@echo -e "$(GREEN) idp_common, idp-cli, idp_sdk, idp_mcp_connector, and test dependencies are now installed.$(NC)"

docs/deployment.md

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ For programmatic deployment, updates, and batch processing, use the IDP CLI.
4545
#### Install the CLI
4646

4747
```bash
48-
cd lib/idp_cli_pkg
49-
pip install -e .
48+
make setup-venv
49+
source .venv/bin/activate
5050
```
5151

5252
#### Deploy a New Stack
@@ -132,13 +132,13 @@ Copy the repo to your computer. Either:
132132

133133
### Option A: IDP CLI `--from-code` (Recommended)
134134

135-
The easiest way to build, publish, and deploy from source in a single command is using the IDP CLI with the `--from-code` option. This builds all artifacts using `publish.py`, publishes them to S3, and deploys the CloudFormation stack — all in one step.
135+
The easiest way to build, publish, and deploy from source in a single command is using the IDP CLI with the `--from-code` option. This builds all artifacts, publishes them to S3, and deploys the CloudFormation stack — all in one step.
136136

137137
#### Install the CLI
138138

139139
```bash
140-
cd lib/idp_cli_pkg
141-
pip install -e .
140+
make setup-venv
141+
source .venv/bin/activate
142142
```
143143

144144
#### Deploy a New Stack from Source
@@ -161,7 +161,7 @@ idp-cli deploy \
161161
```
162162

163163
**What `--from-code` does:**
164-
- Runs `publish.py` to build SAM templates, Lambda layers, container images, and the UI
164+
- Builds SAM templates, Lambda layers, container images, and the UI
165165
- Publishes all artifacts to an S3 bucket in your account
166166
- Creates or updates the CloudFormation stack with the newly published template
167167
- With `--wait`, monitors the deployment until completion
@@ -174,37 +174,45 @@ idp-cli deploy \
174174

175175
### Option B: Publish Templates + Deploy Separately
176176

177-
If you prefer to publish artifacts first and then deploy as a separate step, use `publish.py` to build and publish, then deploy using the AWS CloudFormation console or CLI.
177+
If you prefer to publish artifacts first and then deploy as a separate step, use `idp-cli publish` to build and publish, then deploy using the AWS CloudFormation console or CLI.
178178

179-
#### Step 1: Build and Publish with publish.py
179+
#### Step 1: Build and Publish with `idp-cli publish`
180180

181181
```bash
182-
python3 publish.py <cfn_bucket_basename> <cfn_prefix> <region> [--verbose] [--no-validate] [--clean-build] [--max-workers N]
182+
idp-cli publish --source-dir . --region <region> [--bucket-basename <bucket>] [--prefix <prefix>] [--verbose] [--no-validate] [--clean-build] [--max-workers N]
183183
```
184184

185185
**Parameters:**
186186

187-
- `cfn_bucket_basename`: A prefix for the S3 bucket name (e.g., `idp-1234567890` to ensure global uniqueness)
188-
- `cfn_prefix`: S3 prefix for artifacts (e.g., `idp` or `idp-dev`)
189-
- `region`: AWS region for deployment (e.g., `us-east-1`)
187+
- `--source-dir`: Path to the IDP project root directory (default: `.`)
188+
- `--region`: AWS region for deployment (e.g., `us-east-1`)
189+
- `--bucket-basename`: (Optional) S3 bucket basename for artifacts (auto-generated if not provided)
190+
- `--prefix`: (Optional) S3 key prefix for artifacts (default: `idp-cli`)
190191
- `--verbose` or `-v`: (Optional) Enable detailed error output for debugging build failures
191192
- `--clean-build`: (Optional) Force a clean rebuild of all artifacts
192193
- `--max-workers N`: (Optional) Number of parallel build workers
194+
- `--headless`: (Optional) Also generate a headless (no-UI) template variant for GovCloud
193195

194196
**Example:**
195197

196198
```bash
197-
python3 publish.py idp-1234567890 idp us-east-1
199+
idp-cli publish --source-dir . --region us-east-1
198200
```
199201

200-
The publish script:
202+
With custom bucket and prefix:
203+
204+
```bash
205+
idp-cli publish --source-dir . --bucket-basename idp-1234567890 --prefix idp --region us-east-1
206+
```
207+
208+
The publish command:
201209

202210
- Checks your system dependencies for required packages
203211
- Builds SAM templates, Lambda layers, and container images
204212
- Packages and uploads the UI
205-
- Publishes all templates and assets to an S3 bucket (`<cfn_bucket_basename>-<region>`, created if it doesn't exist)
213+
- Publishes all templates and assets to an S3 bucket (auto-created if it doesn't exist)
206214

207-
When completed, the script displays:
215+
When completed, the command displays:
208216

209217
- The CloudFormation template's S3 URL
210218
- A 1-click URL for launching the stack creation in the CloudFormation console
@@ -215,7 +223,7 @@ When completed, the script displays:
215223
If the build fails, use the `--verbose` flag to see detailed error messages:
216224

217225
```bash
218-
python3 publish.py idp-1234567890 idp us-east-1 --verbose
226+
idp-cli publish --source-dir . --region us-east-1 --verbose
219227
```
220228

221229
This will show:
@@ -257,13 +265,7 @@ aws cloudformation update-stack \
257265
--parameters ParameterKey=AdminEmail,ParameterValue="<your-email>"
258266
```
259267

260-
#### Using publish.sh (Legacy)
261-
262-
`publish.sh` is a Bash wrapper around `publish.py`. Use `publish.py` directly for new deployments.
263-
264-
```bash
265-
./publish.sh <cfn_bucket_basename> <cfn_prefix> <region>
266-
```
268+
> **Note**: The legacy `publish.py` script is deprecated. Use `idp-cli publish` for all new deployments.
267269
268270
---
269271

@@ -282,7 +284,7 @@ The solution **automatically** deploys all Lambda functions as container images
282284

283285
### Prerequisites
284286

285-
- **Docker** must be running on your build machine (for local builds via `publish.py` or `idp-cli --from-code`)
287+
- **Docker** must be running on your build machine (for local builds via `idp-cli publish` or `idp-cli deploy --from-code`)
286288
- Your AWS credentials must have **ECR permissions**
287289

288290
### How It Works

docs/govcloud-deployment.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,24 @@ You need to have the following packages installed on your computer:
5050
5. Node.js >=22.12.0
5151
6. npm >=10.0.0
5252
7. A local Docker daemon
53-
8. Python packages for publish.py. You are encouraged to configure a virtual environment for dependency management, ie. `python -m venv .venv`. Activate the environment (`. .venv/bin/activate`) and then install dependencies via `pip install boto3 rich PyYAML botocore setuptools docker ruff build`
53+
8. Python packages for the IDP CLI and SDK. Run `make setup-venv` from the project root to create a `.venv` and install all required packages (idp-cli, idp-sdk, idp_common). Activate with `source .venv/bin/activate`.
5454

55-
### Step 1: Generate GovCloud Template
55+
### Step 1: Build and Generate Headless Template
5656

57-
First, generate the GovCloud-compatible template - this run the standard build process first to create all Lambda functions and artifacts, and then creates a stripped down version for GovCloud:
57+
First, build and generate the GovCloud-compatible headless template using `idp-cli publish --headless`. This runs the standard build process to create all Lambda functions and artifacts, and then creates a stripped-down version for GovCloud:
5858

5959
```bash
60-
# Note: The Python script will create an S3 bucket automatically by concatenating the provided bucket name and region, ie. my-govcloud-bucket-us-gov-west-1. You can change the bucket base name as desired. Files will be placed under [my-prefix] prefix within the generated bucket.
61-
# Build for GovCloud region
62-
python scripts/generate_govcloud_template.py my-bucket-govcloud my-prefix us-gov-west-1
60+
# Build for GovCloud region with headless template
61+
idp-cli publish --source-dir . --region us-gov-west-1 --headless
6362

6463
# Or build for commercial region first (for testing)
65-
python scripts/generate_govcloud_template.py my-bucket my-prefix us-east-1
64+
idp-cli publish --source-dir . --region us-east-1 --headless
6665
```
6766

67+
> **Note**: The CLI will create an S3 bucket automatically. You can customize the bucket name with `--bucket-basename` and the prefix with `--prefix`. The `--headless` flag generates a template with UI, AppSync, Cognito, and WAF resources removed.
68+
69+
> **Legacy**: The `scripts/generate_govcloud_template.py` script is deprecated. Use `idp-cli publish --headless` instead.
70+
6871
### Step 2: Deploy to GovCloud
6972

7073
Deploy the generated template to GovCloud using the AWS CloudFormation console (recommended) or deploy using AWS CLI e.g:

docs/idp-cli.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ https://github.com/user-attachments/assets/3d448a74-ba5b-4a4a-96ad-ec03ac0b4d7d
7474
### Install from source
7575

7676
```bash
77-
cd lib/idp_cli_pkg
78-
pip install -e .
77+
make setup-venv
78+
source .venv/bin/activate
7979
```
8080

8181
### Install with test dependencies
@@ -156,7 +156,7 @@ idp-cli deploy [OPTIONS]
156156
- `--admin-email`: Admin user email
157157

158158
**Optional Parameters:**
159-
- `--from-code`: Deploy from local code by building with publish.py (path to project root)
159+
- `--from-code`: Deploy from local code by building and publishing artifacts (path to project root)
160160
- `--template-url`: URL to CloudFormation template in S3 (optional, auto-selected based on region)
161161
- `--custom-config`: Path to local config file or S3 URI
162162
- `--max-concurrent`: Maximum concurrent workflows (default: 100)

docs/idp-sdk.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ The IDP SDK provides programmatic Python access to all IDP Accelerator capabilit
1010

1111
```bash
1212
# Install from local development
13-
pip install -e ./lib/idp_sdk
13+
# Recommended: install everything at once
14+
make setup-venv
15+
source .venv/bin/activate
1416

15-
# Or with uv
17+
# Or install just the SDK with pip/uv
1618
uv pip install -e ./lib/idp_sdk
1719
```
1820

docs/setup-development-env-WSL.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,22 +84,29 @@ sam --version (Example: SAM CLI, version 1.143.0)
8484
node --version (Example: v22.12.0)
8585
npm --version (Example: 11.0.0)
8686
```
87-
### 4.2 Test Build Process
87+
### 4.2 Install the IDP CLI
8888
```
89-
cd accelerated-intelligent-document-processing-on-aws
89+
cd accelerated-intelligent-document-processing-on-aws/lib/idp_cli_pkg
90+
pip install -e .
91+
cd ../..
92+
```
93+
94+
### 4.3 Test Build Process
9095
```
96+
cd accelerated-intelligent-document-processing-on-aws
9197
```
92-
# Test publish script help
93-
python3 publish.py --help
98+
```bash
99+
# Test CLI help
100+
idp-cli publish --help
94101

95-
# Test build (replace with your S3 bucket name)
96-
python3 publish.py your-bucket-name build-test us-east-1
102+
# Test build
103+
idp-cli publish --source-dir . --region us-east-1
97104
```
98105

99-
### 4.3 Troubleshooting Build Issues
106+
### 4.4 Troubleshooting Build Issues
100107
If the build fails, use the `--verbose` flag:
101108
```bash
102-
python3 publish.py your-bucket-name build-test us-east-1 --verbose
109+
idp-cli publish --source-dir . --region us-east-1 --verbose
103110
```
104111

105112
The verbose flag shows:
@@ -108,6 +115,8 @@ The verbose flag shows:
108115
- Python version compatibility issues
109116
- Missing dependencies or configuration problems
110117

118+
> **Note**: The legacy `publish.py` script is deprecated. Use `idp-cli publish` for all new builds.
119+
111120
## Step 5: Install Visual Studio Code on Local Machine for using WSL as a terminal
112121
### Visit the official website: Go to [https://code.visualstudio.com/](https://code.visualstudio.com/)
113122
Download: Click the "Download for Windows" button

0 commit comments

Comments
 (0)