Scales ASGs and authorises CodePipeline
Project description
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-lambda
project.
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for asg_scaler_lambda-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4107af6a2e329c7b441b43405397b63627e9ec1ace022ceb73bfa6ed78aa6363 |
|
MD5 | a024d06689805019f5e1b8c1bae0d03d |
|
BLAKE2b-256 | a8b557bf813b39d4be8754f44e1b76c39f4ec36a954225c8e301f2949f6c37d4 |