This example demonstrates building AWS ECS plugins with patches for code fixes and embedded packages for additional dependencies.
This example builds the frontend and backend ECS plugins from the awslabs/backstage-plugins-for-aws repository. It includes the following configurations:
- Patches: Small, targeted code changes applied via diff files
- Embed Packages: Including additional dependency packages in the dynamic plugin export
example-config-aws-ecs/
├── backstage.json # Backstage configuration
├── patches/
│ └── 1-avoid-double-wildcards.patch # Path File
├── plugins-list.yaml # Plugins with embed-package arguments
└── source.json # Source repository configurationsource.json: Specifies the AWS plugins repository and git reference to clone from. Therepo-reffield is optional; when omitted, the repository's default branch is used. Theworkspace-pathfield can also be set here instead of using--workspace-path.plugins-list.yaml: Lists plugins with--embed-packagearguments for shared dependenciesbackstage.json: Backstage configuration filepatches/: Contains patch files
Patches are diff files that apply small, targeted changes to the source code. Unlike overlays (which replace/adds entire files), patches modify specific lines.
Patches use the standard unified diff format:
--- a/path/to/file
+++ b/path/to/file
@@ -line,count +line,count @@
context line
-removed line
+added line
context line- The factory clones the source repository
- Before building, it applies all
.patchfiles fromconfig/patches/in alphabetical order - Each patch modifies specific lines in the source files
- The patched source is then built and exported
Warning: Patches are destructive - they permanently modify files in the workspace directory. Please make sure to have source control if using a local repository.
To create your own patch:
-
Make changes to files in your workspace
-
Generate a patch file:
git diff > my-fix.patch -
Place the patch in
config/patches/ -
Prefix with a number for ordering (e.g.,
01-my-fix.patch)
The --embed-package argument bundles shared dependencies directly into the dynamic plugin.
In this example, the ECS backend plugin embeds common AWS packages so that the backend application functions correctly.
plugins/ecs/backend: --embed-package @aws/aws-core-plugin-for-backstage-common --embed-package @aws/aws-core-plugin-for-backstage-nodeFrom the repository root, run:
podman run --rm -it \
--device /dev/fuse \
-v ./examples/example-config-aws-ecs:/config:z \
-v ./outputs:/outputs:z \
quay.io/rhdh-community/dynamic-plugins-factory:latest \Note: workspace-path is set to . in source.json because this repository does not follow the backstage community plugins (BCP) repository structure where there are multiple yarn workspaces. Instead the plugins are stored in the main workspace, so root of the workspace is also the root of the repository in this example.
From the repository root, run:
python -m src.rhdh_dynamic_plugin_factory \
--config-dir ./examples/example-config-aws-ecs \
--repo-path ./source \
--output-dir ./outputsOr using CLI args instead of source.json:
python -m src.rhdh_dynamic_plugin_factory \
--source-repo https://github.com/awslabs/backstage-plugins-for-aws \
--source-ref 78df9399a81cfd95265cab53815f54210b1d7f50 \
--config-dir ./examples/example-config-aws-ecs \
--workspace-path . \
--repo-path ./source \
--output-dir ./outputsThis will do the following:
- The factory clones the AWS plugins repository to
./source - The
1-avoid-double-wildcards.patchis applied to fix workspace configuration - Dependencies are installed at the repository root
- Frontend and backend ECS plugins are compiled
- Shared AWS packages are embedded in the backend plugin
- Plugins are exported as dynamic plugins using the RHDH CLI
- Plugin tarballs and integrity files are created in
./outputs
After successful execution, you'll find these files in ./outputs:
outputs/
├── aws-ecs-plugin-for-backstage-0.2.0.tgz
├── aws-ecs-plugin-for-backstage-0.2.0.tgz.integrity
├── aws-ecs-plugin-for-backstage-backend-0.3.0.tgz
└── aws-ecs-plugin-for-backstage-backend-0.3.0.tgz.integrityNote: Version numbers may vary depending on the plugin versions in the source repository.
If you want to publish the package, you will need to add a --push-image argument and provide the following environmental variables in the /config/.env file:
REGISTRY_URL="quay.io"
REGISTRY_USERNAME="your-username"
REGISTRY_PASSWORD="your-password"
REGISTRY_NAMESPACE="your-namespace"
REGISTRY_INSECURE="false"- Try the GitLab example to learn about overlays
- Review the TODO example for a simpler use case
- Read the main README for more configuration options
- Explore other AWS plugins in the repository