Skip to main content

ReactBucketDeployment for AWS CDK

A custom AWS CDK construct that integrates node for building react projects, automating the process of dependency resolution, packaging, and deployment preparation to AWS S3.

Features

  • Automates the build process of React applications using npm.
  • Deploys the built React application to an AWS S3 bucket for hosting.
  • Handles dependency resolution and packaging with npm ci and npm run build.
  • Easily integrates with AWS CDK projects, providing a seamless deployment workflow.

Prerequisites

Installation

To use ReactBucketDeployment in your CDK project, install it via pip:

pip install cdk-react-bucket-deployment

Usage

Here's a basic example of how to use ReactBucketDeployment in your AWS CDK stack:

from aws_cdk import Stack
from aws_cdk.aws_s3 import Bucket
from constructs import Construct
from react_bucket_deployment import ReactBucketDeployment

class MyReactAppStack(Stack):
    def __init__(self, scope: Construct, id: str, **kwargs):
        super().__init__(scope, id, **kwargs)

        bucket = Bucket(self, "MyReactAppBucket")

        ReactBucketDeployment(
            self, "DeployReactApp",
            react_project_path="./path/to/react/project",
            destination_bucket=bucket
        )

Replace ./path/to/react/project with the path to your React project directory.

Configuration

The ReactBucketDeployment construct accepts the following parameters:

  • scope: The scope in which to define this construct (usually self in the context of a stack).
  • id: The scoped construct ID.
  • react_project_path: The file system path to the React project directory.
  • destination_bucket: The S3 bucket instance where the React application will be deployed.

Additional AWS CDK BucketDeployment options can be passed through **kwargs to customize the deployment behavior further.

Local Development

This project uses Poetry for dependency management and packaging, and it's recommended to use Poetry to run local development tasks to ensure consistency with the project's dependencies.

Running tests

All the tests are based on pytest so running them boils down to executing one command:

poetry run pytest

Running Pre-commit Hooks

The project uses pre-commit hooks to ensure code quality and formatting standards. To set up pre-commit hooks within the Poetry environment, which ensures that the hooks are run automatically before each commit, execute the following command:

poetry run pre-commit install

This command installs pre-commit hooks as Git pre-commit hooks, so they are automatically executed before you commit changes. It's a convenient way to ensure your changes adhere to the project's standards without needing to manually run checks before each commit.

If you prefer to run pre-commit hooks manually, perhaps to check files before committing, you can use the following command:

poetry run pre-commit run --all-files

This will manually execute all configured pre-commit hooks on all files in the repository. It's useful for performing a one-time check or for scenarios where you haven't set up automatic pre-commit hooks with pre-commit install.

Running Pyright

Pyright is used for static type checking to catch errors early in development. To run Pyright through Poetry, use the following command:

bash

poetry run pyright

This will execute Pyright type checking based on the project's pyrightconfig.json configuration. Running Pyright helps ensure type consistency and can catch common errors.

Contributing

  • Submitting bug reports and feature requests in the Issues section.
  • Opening pull requests with improvements to code or documentation.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Acknowledgments

  • Thanks to the AWS CDK team for providing the framework.
  • Thanks to the Poetry team for simplifying Python package management.

Metadata

Release files for cdk-react-bucket-deployment 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cdk-react-bucket-deployment 0.1.1
File Size Uploaded Provenance Actions
cdk_react_bucket_deployment-0.1.1.tar.gz 4.4 kB Without provenance Details for cdk_react_bucket_deployment-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cdk-react-bucket-deployment 0.1.1
File Interpreter ABI Platform Actions
cdk_react_bucket_deployment-0.1.1-py3-none-any.whl Python 3 none any Details for cdk_react_bucket_deployment-0.1.1-py3-none-any.whl

Total release size: 9.2 kB

Release files / cdk_react_bucket_deployment-0.1.1.tar.gz

Download URL cdk_react_bucket_deployment-0.1.1.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
656714cc4c69daae527a6228fd5ed4e7d634fe5bb3f5c981aedfefacacbee668
BLAKE2b-256 checksum
How to use checksums
5797acf8082adad4e31c8f020dfbb0f99e496b6c3f031fb3bab8d9f56f14b2cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.2

Release files / cdk_react_bucket_deployment-0.1.1-py3-none-any.whl

Download URL cdk_react_bucket_deployment-0.1.1-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3317171afd994a7abc29be1e1251d8459f4a1a4666147df94635869e81f24050
BLAKE2b-256 checksum
How to use checksums
6abe3680528fedf275f67c5757b530127dd094c62a60bda79630b3340e57df40
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.2

Security for cdk-react-bucket-deployment 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page