cloud-detect
About
cloud-detect is a Python module that determines a host's cloud provider. Highly inspired by the Go based Satellite, cloud-detect uses the same techniques (file systems and provider metadata) to properly identify cloud providers.
Features
- Supports identification of Alibaba, AWS, Azure, Digital Ocean, GCP, Oracle Cloud and Vultr hosts.
- Fast and supports asyncio
- Logging integration.
- Small and extensible.
Usage
>>> from cloud_detect import provider
>>> provider()
'aws'
>>> provider() # when tested in local/non-supported cloud env
'unknown'
Right now the only possible responses are: 'alibaba', 'aws', 'azure', 'do', 'gcp', 'oci', 'vultr' or 'unknown'
You can get the list of supported providers using
>>> from cloud_detect import SUPPORTED_PROVIDERS
Installation
Via pip:
pip install cloud-detect
Examples
Termination-handler uses cloud-detect to keep the handling of termination notices on spot/preemptible instances cloud-agnostic, making easier to operate the same tooling in various distinct environments.
How to contribute
- Check for open issues or open a fresh issue to start a discussion around a feature idea or a bug.
- Fork the repository on GitHub to start making your changes to the master branch (or branch off of it).
- Set up a local dev environment:
python -m venv .venv && source .venv/bin/activate && pip install -U pip && pip install -e '.[dev]', then run tests withpytestand lint withruff check .. - Write a test which shows that the bug was fixed or that the feature works as expected.
- Send a pull request and bug me until it gets merged and published.
Some things that would be great to have:
- Add more cloud providers
- Add codecov
Publishing a release
Requires maintainer access to the project on PyPI (authenticate with an API token: username __token__, password pypi-...).
- Bump
versioninpyproject.toml. - Build and upload from the dev virtualenv (see "How to contribute" above), so nothing is installed into the system Python:
source .venv/bin/activate
rm -rf dist
pip install -U build twine
python -m build
twine upload dist/*
Metadata
Release files for cloud-detect 0.0.15
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cloud_detect-0.0.15.tar.gz | 8.8 kB | Without provenance | Details for cloud_detect-0.0.15.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cloud_detect-0.0.15-py3-none-any.whl | Python 3 | none | any | Details for cloud_detect-0.0.15-py3-none-any.whl |
Total release size: 20.2 kB
Release files / cloud_detect-0.0.15.tar.gz
| Download URL | cloud_detect-0.0.15.tar.gz |
|---|---|
| Size | 8.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4777d73d96c2c07514a3ead8e236f9bdbcbafe0b3a07a5c1012dd28b36b75ef2
|
|
BLAKE2b-256 checksum How to use checksums |
29083ad530fce24e3784d89ebc1e5bb65476313451bce57f80d9105386c5d65d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / cloud_detect-0.0.15-py3-none-any.whl
| Download URL | cloud_detect-0.0.15-py3-none-any.whl |
|---|---|
| Size | 11.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d4e1778c99b28a54940a7475eae33685332956343dca5d8f7a64473d583c62a4
|
|
BLAKE2b-256 checksum How to use checksums |
d69aa9080f290d5cfe027b10b495c7d18e904dcdcd033a0c6e12ddf3b49521cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for cloud-detect 0.0.15
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.