ASG Scaler
Blue/Green CodeDeployments for Frugal Architects
Developed with the software and tools below.
Quick Links
Overview
asg-scaler simplifies AWS Auto Scaling Groups (ASGs) management for CodePipeline CodeDeploy deployments, enabling efficient blue/green deployment strategies without requiring excess instances. Traditionally, ASGs aim to maintain a fixed capacity, complicating blue/green deployments as they necessitate doubling the instance count temporarily. asg-scaler resolves this by dynamically adjusting ASG capacities to match the deployment phase, increasing for new deployments and reverting once stability is achieved.
Features
| Feature | Description | |
|---|---|---|
| ⚙️ | Architecture | This project utilises AWS Lambda for auto-scaling AWS ASGs. It's designed to dynamically adjust ASG sizes and integrates with AWS CodePipeline for deployment automation. |
| 🔩 | Code Quality | Adheres to PEP8 guidelines, enforced by flake8 and pylint. The code is structured around modular Python scripts, enhancing readability and maintainability. |
| 📄 | Documentation | Each main script and workflow is well-documented, explaining their roles within the auto-scaling and CI/CD process, though additional user guides or API docs could enhance usability. |
| 🔌 | Integrations | Integrates with AWS services like Lambda, Auto Scaling Groups, and CodePipeline. GitHub Actions is used for CI/CD, ensuring automated testing and deployment. |
| 🧩 | Modularity | The project is modular, with distinct components for ASG management, CodePipeline interaction, and CI/CD automation, allowing for easy updates and scalability. |
| 🧪 | Testing | Uses pytest and pytest-cov for running tests and measuring code coverage, ensuring reliability and functionality across updates. |
| 📦 | Dependencies | Depends on boto3 for AWS interactions, pytest, pytest-cov, and coverage for testing, and flake8 for linting. Managed with poetry for dependency resolution. |
| 🚀 | Scalability | Highly scalable, leveraging AWS Lambda and ASG capabilities to dynamically adjust infrastructure based on demand, within the architectural limits of those services. |
Repository Structure
└── asg-scaler-lambda/
├── .github
│ ├── scripts
│ │ └── update_version.py
│ └── workflows
│ ├── build.yml
│ ├── dry-run-release.yml
│ └── release.yml
├── LICENSE
├── README.md
├── asg_scaler_lambda
│ ├── asg_helper.py
│ ├── asg_scaler.py
│ └── codepipeline_event.py
├── poetry.lock
├── pylintrc
├── pyproject.toml
├── sonar-project.properties
└── tests
├── test_asg_helper.py
├── test_asg_scaler.py
└── test_codepipeline_event.py
Modules
.
| File | Summary |
|---|---|
| pylintrc | The pylintrc file defines linting rules for the asg-scaler repository, aiming to enforce code quality standards and error prevention across the Python modules. |
| pyproject.toml | This pyproject.toml configures the asg-scaler-lambda project, defining dependencies, build settings, and test configurations. |
| poetry.lock | A record of all the exact versions of the dependencies used in asg-scaler |
asg_scaler_lambda
| File | Summary |
|---|---|
| asg_scaler.py | The asg_scaler.py is the entrypoint of asg-scaler, aimed at handling AWS events to dynamically adjust Auto Scaling Group (ASG) parameters and manage CodePipeline approvals. It processes CodePipeline job events to update ASG configurations based on user parameters and handles EventBridge events to automate CodePipeline approvals. |
| asg_helper.py | asg_helper.py provides utility functions to update and validate Auto Scaling Group capacities in AWS. It chiefly transforms capacity parameters, ensures their logical consistency, and interfaces with AWS to adjust ASG settings. |
| codepipeline_event.py | codepipeline_event.py interfaces with AWS CodePipeline for managing job states and approvals. It provides functions to report job success or failure, approve deployment actions automatically, and retrieve necessary tokens for approvals. |
.github.scripts
| File | Summary |
|---|---|
| update_version.py | update_version.py automates version updates in the project's pyproject.toml, ensuring consistent versioning across the asg-scaler-lambda repository. |
.github.workflows
| File | Summary |
|---|---|
| build.yml | .github/workflows/build.yml automates build tests. |
| release.yml | release.yml automates versioning and deployment of the asg-scaler-lambda project. |
| dry-run-release.yml | This YAML file automates pre-release verifications for the asg-scaler-lambda repository. |
Getting Started
Requirements
Ensure you have the following dependencies installed on your system:
- Python:
version 3.8+ - Poetry:
version 1.8.2+
Installation
- Clone the asg-scaler-lambda repository:
git clone https://github.com/XargsUK/asg-scaler-lambda
- Change to the project directory:
cd asg-scaler-lambda
- Install the dependencies with Poetry:
poetry install
Running asg-scaler
Use the following command to run asg-scaler:
poetry run python asg_scaler.py
Tests
Use the following command to run tests:
poetry run pytest
Contributing
Contributions are welcome! Here are several ways you can contribute:
- Submit Pull Requests: Review open PRs, and submit your own PRs.
- Report Issues: Submit bugs found or log feature requests for the
asg-scaler-lambdaproject.
Contributing Guidelines
- Fork the Repository: Start by forking the project repository to your github account.
- Clone Locally: Clone the forked repository to your local machine using a git client.
git clone https://github.com/XargsUK/asg-scaler-lambda
- Create a New Branch: Always work on a new branch, giving it a descriptive name.
git checkout -b new-feature-x
- Make Your Changes: Develop and test your changes locally.
- Commit Your Changes: Commit with a clear message describing your updates.
git commit -m 'Implemented new feature x.'
- Push to GitHub: Push the changes to your forked repository.
git push origin new-feature-x
- Submit a Pull Request: Create a PR against the original project repository. Clearly describe the changes and their motivations.
Once your PR is reviewed and approved, it will be merged into the main branch.
License
This project is protected under the MIT License.
Metadata
Release files for asg-scaler-lambda 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| asg_scaler_lambda-0.1.1.tar.gz | 13.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| asg_scaler_lambda-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.4 kB
Release files / asg_scaler_lambda-0.1.1.tar.gz
| Download URL | asg_scaler_lambda-0.1.1.tar.gz |
|---|---|
| Size | 13.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
926640b069dbcefdb9c2186f701a13f6b0752a805096faa7ce3040390fff7acc
|
|
BLAKE2b-256 checksum How to use checksums |
d0399af4cd07401ffde050a10c1e0da4019492e61f4cab6b63bc97a74c8fe959
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.8.18
|
Release files / asg_scaler_lambda-0.1.1-py3-none-any.whl
| Download URL | asg_scaler_lambda-0.1.1-py3-none-any.whl |
|---|---|
| Size | 9.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4107af6a2e329c7b441b43405397b63627e9ec1ace022ceb73bfa6ed78aa6363
|
|
BLAKE2b-256 checksum How to use checksums |
a8b557bf813b39d4be8754f44e1b76c39f4ec36a954225c8e301f2949f6c37d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.8.18
|