Skip to main content

Cloud Custodian - Huawei Cloud Support

Project description

Cloud Custodian - Huawei Cloud Support

This is a plugin to Cloud Custodian that adds Huawei Cloud support.

Install Cloud Custodian and Huawei Cloud Plugin

The Huawei Cloud provider must be installed as a separate package in addition to c7n.

$ pip install c7n_huaweicloud

Write your first policy

Cloud Custodian policies are expressed in YAML and include the following:

  • The type of resource to run the policy against
  • Filters to narrow down the set of resources
  • Actions to take on the filtered set of resources

Our first policy filters compute instance of a specific name, then adds the tag mark_deletion: true.

Create a file named custodian.yml with the following content.

policies:
    - name: filter-for-encrypted-volume
      resource: huaweicloud.evs-volume
      filters:
        - type: value
          key: metadata.__system__encrypted
          value: "0"
      actions:
        - delete

Run your policy

export HUAWEI_ACCESS_KEY_ID="YOUR_ACCESS_KEY_ID"
export HUAWEI_SECRET_ACCESS_KEY="YOUR_SECRET_ACCESS_KEY"
export HUAWEI_DEFAULT_REGION="YOUR_REGION"

custodian run --output-dir=. custodian.yml

If successful, you should see output like the following on the command line::

2025-03-14 16:44:00,553 - custodian.policy - INFO - policy:filter-for-encrypted-volume resource:huaweicloud.volume region: count:1 time:0.92
2025-03-14 16:44:00,771 - custodian.huaweicloud.resources.volume - INFO - Received Job ID:90f0aed1b4ee443d80dc3faddc543ad9
2025-03-14 16:44:00,771 - custodian.policy - INFO - policy:filter-for-encrypted-volume action:volumedelete resources:1 execution_time:0.22

You can find a new filter-for-encrypted-volume under --output-dir option value directory with a log and a resources.json file.

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

c7n_huaweicloud-0.1.1.tar.gz (88.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

c7n_huaweicloud-0.1.1-py3-none-any.whl (117.2 kB view details)

Uploaded Python 3

File details

Details for the file c7n_huaweicloud-0.1.1.tar.gz.

File metadata

  • Download URL: c7n_huaweicloud-0.1.1.tar.gz
  • Upload date:
  • Size: 88.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/6.8.0-49-generic

File hashes

Hashes for c7n_huaweicloud-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a706810b662b816840e16b106d2c4764607a69654f237b4136537d71dd1a090d
MD5 a6d951599ce8b6fb237d25d72c055338
BLAKE2b-256 82d2cbfb02d5d423c1daecb1661682b157e1a88ac336246ac0ae8a4316c50b84

See more details on using hashes here.

File details

Details for the file c7n_huaweicloud-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: c7n_huaweicloud-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 117.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/6.8.0-49-generic

File hashes

Hashes for c7n_huaweicloud-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 01687cce272853334144bb5865bc590453c6068ddb53db481e86eb3d4343e499
MD5 ef389bffb22471e2595814f8ad28192e
BLAKE2b-256 8e5d9a825f74b09b38984197d04b565f7f854f224c7e18164f16c3c0cae57765

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page