Skip to main content

No project description provided

Project description

Made with pop, a Python implementation of Plugin Oriented Programming Made with idem, a Python implementation of Plugin Oriented Programming Documentation is published with Sphinx on docs.idemproject.io Made with Python

Idem plugin to manage Azure cloud resources

About

idem-azure helps manage Azure with idem.

What is POP?

This project is built with pop, a Python-based implementation of Plugin Oriented Programming (POP). POP seeks to bring together concepts and wisdom from the history of computing in new ways to solve modern computing problems.

For more information:

What is Idem?

This project is built with idem, an idempotent, imperatively executed, declarative programming language written in Python. This project extends idem!

For more information:

Getting Started

Prerequisites

  • Python 3.7+

  • git (if installing from source, or contributing to the project)

Installation

If wanting to use idem-azure, you can do so by either installing from PyPI or from source.

Install from PyPI

pip install idem-azure

Install from source

# clone repo
git clone git@<your-project-path>/idem-azure.git
cd idem-azure

# Setup venv
python3 -m venv .venv
source .venv/bin/activate
pip install -e .

Usage

Credentials Setup

After installation, the Azure Idem execution and state modules will be accessible to the pop hub. In order to use them, we need to set up our credentials.

Create a new file called credentials.yaml and populate it with credentials. The default profile will be picked up automatically by idem.

There are multiple authentication backends for idem-azure which each have their own unique set of parameters. The following examples show the parameters that can be used to define credential profiles.

credentials.yaml:

azure:
   default:
      client_id: "12345678-1234-1234-1234-aaabc1234aaa"
      secret: "76543210-4321-4321-4321-bbbb3333aaaa"
      subscription_id: "ZzxxxXXXX11xx-aaaaabbbb-k3xxxxxx"
      tenant: "bbbbbca-3333-4444-aaaa-cddddddd6666"

Next step is to encrypt the credentials file, and add the encryption key and encrypted file path to the ENVIRONMENT.

Encrypt the credential file:

Idem encrypt credentials.yaml

This will generate a credentials.yaml.fernet file and a command line output token:

-AXFSEFSSEjsfdG_lb333kVhCVSCDyOFH4eABCDEFNwI=

Add these to your environment:

export ACCT_KEY="-AXFSEFSSEjsfdG_lb333kVhCVSCDyOFH4eABCDEFNwI="
export ACCT_FILE=$PWD/credentials.yaml.fernet

You are ready to use idem-azure!!!

STATES

Idem states are used to make sure resources are in a desired state. The desired state of a resource can be specified in sls file. In Idem-azure, three states are supported: present, absent, describe

present state

present state makes sure a resource exists in a desired state. If a resource does not exist, running present will create the resource on the provider. If a resource exists, running present will update the resource on the provider. (Only the values that the Azure REST api supports can be updated.)

absent state

absent state makes sure a resource does not exist. If a resource exits, running absent will delete the resource. If a resource does not exist, running absent is a no-operation.

describe state

describe state lists all the current resources of the same resource type under the subscription id specified in the credential profile.

States can be accessed by their relative location in idem-azure/idem_azure/states. For example, in the state sls yaml file below, Azure resource group state can be created with the present function.

my_resource_group_state.sls:

my-azure-resource-group:
  azure.resource_management.resource_groups.present:
  - resource_group_name: my-azure-resource-group
  - location: eastus

The state sls file can be executed with:

idem state $PWD/my_resource_group_state.sls

Example of creating an Azure virtual network:

my-virtual-network:
  azure.network.virtual_networks.present:
  - resource_group_name: my-azure-resource-group
  - virtual_network_name: my-virtual-network
  - location: eastus
  - address_space:
        - 10.0.0.0/16

The resource parameters in an sls yaml file follow the exact structure as what’s in the Azure REST api doc . URI Parameters should be specified in snake case with “- “ in front. All parameters of the api request body should be specified in exactly the same way as what’s in the Azure REST api.

Current Supported Resources states

authorization

role_definitions, role_assignments

resource_management

resource_groups

policy

policy_definitions, policy_assignments

management_groups

management_groups

subscription

subscription

network

firewall, firewall_policies, network_interfaces, network_security_groups, public_ip_addresses, route_tables, routes, security_rules, subnets, virtual_networks

compute

virtual_machines, log_analytics_workspace

storage_resource_provider

storage_accounts

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

idem-azure-0.3.3.tar.gz (93.0 kB view details)

Uploaded Source

Built Distribution

idem_azure-0.3.3-py3-none-any.whl (172.6 kB view details)

Uploaded Python 3

File details

Details for the file idem-azure-0.3.3.tar.gz.

File metadata

  • Download URL: idem-azure-0.3.3.tar.gz
  • Upload date:
  • Size: 93.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/37.3 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/2.0.2 tqdm/4.65.0 importlib-metadata/6.6.0 keyring/23.13.1 rfc3986/2.0.0 colorama/0.4.6 CPython/3.9.16

File hashes

Hashes for idem-azure-0.3.3.tar.gz
Algorithm Hash digest
SHA256 f88d93426cdb2ee6c3bd7c353e5cbb3873312927140447ec45b8408a4dfde4d1
MD5 b68a1fd0eb1d9a3b270b6f9ff9282a38
BLAKE2b-256 564064508079750eec4d1b84d1bf52c5a75e9e8dbae76de689818ca6683e737e

See more details on using hashes here.

File details

Details for the file idem_azure-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: idem_azure-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 172.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/37.3 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/2.0.2 tqdm/4.65.0 importlib-metadata/6.6.0 keyring/23.13.1 rfc3986/2.0.0 colorama/0.4.6 CPython/3.9.16

File hashes

Hashes for idem_azure-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 292f046c297b4acb71feaad4890ccdc10e74910d37082135fc194d2075e1cf42
MD5 362de9a15ef1fd333598454a8dfefbe6
BLAKE2b-256 b4a96d8cdd631fbd6bd772f43e716caf539ad5979d9c6c1efc3044c20c217860

See more details on using hashes here.

Supported by

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