Skip to main content

Cloud Custodian - Azure Support

Project description

Cloud Custodian - Azure Support

This a plugin to Cloud Custodian that adds Azure support.

Install Cloud Custodian and Azure Plugin

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

$ virtualenv custodian
$ source custodian/bin/activate
(custodian) $ pip install c7n
(custodian) $ pip install c7n_azure

Write your first policy

A policy specifies the following items:

  • 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

For this tutorial we will add a tag to all virtual machines with the name "Hello" and the value "World".

Create a file named custodian.yml with this content:

policies:
    - name: my-first-policy
      description: |
        Adds a tag to all virtual machines
      resource: azure.vm
      actions:
        - type: tag
          tag: Hello
          value: World

Run your policy

First, choose one of the supported authentication mechanisms and either log in to Azure CLI or set environment variables as documented in Authentication.

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

If successful, you should see output similar to the following on the command line

2016-12-20 08:35:06,133: custodian.policy:INFO Running policy my-first-policy resource: azure.vm
2016-12-20 08:35:07,514: custodian.policy:INFO policy: my-first-policy resource:azure.vm has count:1 time:1.38
2016-12-20 08:35:08,188: custodian.policy:INFO policy: my-first-policy action: tag: 1 execution_time: 0.67

You should also find a new my-first-policy directory with a log and other files (subsequent runs will append to the log by default rather than overwriting it).

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_azure-0.5.tar.gz (46.0 kB view details)

Uploaded Source

File details

Details for the file c7n_azure-0.5.tar.gz.

File metadata

  • Download URL: c7n_azure-0.5.tar.gz
  • Upload date:
  • Size: 46.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for c7n_azure-0.5.tar.gz
Algorithm Hash digest
SHA256 c4ff3a90df4c727d49c456f6e80415b0d469efc2d7b553ec3a0dc306403a14e5
MD5 9e23b714109d8a4a283bf4362da6c5b0
BLAKE2b-256 1a4d586f871fbf00969bc67515bf2b9f9d1f0d1bb0a30eb60757beb33f8af41c

See more details on using hashes here.

Supported by

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