Skip to main content

Package contains functions and classes that can be utilized in the automation of pulumi python deployments

Project description

pulumi-automation-utils

Collection of utilities useful for deploying pulumi Infrastructure as Code. These utilities aid in configuration and creation of resource dependencies needed by pulumi.

Files

Below is a list of all of the files and an inclination for how each can be used within your project.

certs_and_keys.py

This file contains two functions. These are create_key_pair and create_signed_certificate. The create_key_pair function allows for the creation of an RSA 4096 bit public/private key pair. The create_signed_certificate function allows the user to create a signed certificate using an existing CA key pair. It is possible to create the CA key pair using the create_key_pair and use it as the basis for creating a self-signed certificate.

common.py

This file contains any and all generic function definitions that are utilized when setting up the development environment to support pulumi deployments. These functions include:

  • parse_yaml_file - read from a YAML file
  • sending commands to the OS
  • retrieving information from Azure

environment.py

This file contains an Enum class representing each of the possible environment types.

login_config.py

This file contains two classes. The first is the LoginMode class that is an Enum used to represent the options one could use for logging into Azure. The second is a class by the name LoginConfig; this class is responsible for maintaining all configuration associated with the deployment user including login status, and providing a function for allowing the user to login. The LoginConfig class takes in a single variable, the yaml_vars retrieved from the result of the parse_yaml_file function in common.py.

The following keys can be at the root of the YAML file to be consumed by LoginConfig:

  • subscription
    • (optional) The ID of the subscription in which to deploy infrastructure
  • app_id
    • (optional) The Application Client ID for the service principal to login to Azure
  • client_secret
    • (optional) The Service Principal Client Secret to login to Azure
    • Recommend keeping the YAML configuration file safe if any sensitive information is stored within
  • login_mode
    • (optional) The mode for logging into Azure. Currently supported options are: "interactive", "service_principal", or "managed_identity".
  • tenand_id
    • (optional) The Tenant ID for the Service Principal to login to Azure

Use the is_logged_in function to test whether the user is currently logged in. The login_to_azure function is used to login to Azure via the login_mode specified. Interactive is the default login mode if one is not supplied. In interactive login, a URL and device code are supplied where the user can login from another machine to provide authorization.

pulumi_config.py

This file is used for managing pulumi in a semi-automated fashion. The PulumiConfig class takes in the LoginConfig and the yaml_vars output via the parse_yaml_file function in common.py. The PulumiConfig object sorts through the YAML to get all of the configuration parameters necessary to deploy infrastructure via pulumi.

This class expects the following resources to be defined within the YAML configuration:

  • storage_account
    • Houses storage container used for backend state management
  • storage_container
    • Houses the blobs that manage backend state
  • key_vault
    • Manages encryption key used for securing pulumi sensitive information

These resources are required to be configured and available at the time the user issues the pulumi login and pulumi stack select commands.

YAML Configuration

The YAML configuration is used as the basis for deploying the resources necessary to support deploying any pulumi project or stack in your Azure subscription. This YAML configuration has some rules to smoothly configure resources accordingly. The following lays out the structure of the overall YAML configuration file.

  • environment
    • (required) The name of the environment (one of sandbox, zonec, zoneb, zonea, or prod)
  • stack_name
    • (required) The name of the stack to deploy. Anything you want
  • project_location
    • (required) The full filepath to the directory of the pulumi project.
  • storage_account
    • (required) The configuration object that specifies information about the storage account used with pulumi
    • resource_group
      • (optional) The name of the resource group that the Azure Key Vault resides in
    • storage_container
      • (required) The configuration block of the Storage Account Blob Container that is used with pulumi
      • name
        • (required) The name of the Storage Account Blob Container
    • sas_token
      • (optional) The configuration block of the SAS token to be created/used with pulumi to access Storage Account Blob Container
      • name
        • (required) If this block is declared, the name of the SAS token must be declared
  • key_vault
    • (required) The configuration object that specifies information about the Azure Key Vault used with pulumi
    • resource_group
      • (optional) The name of the resource group that the Azure Key Vault resides in
  • pulumi
    • (required) Configuration block that contains a dictionary of all the configuration parameters required by your pulumi scripts
    • If no resource_group_name is specified, the first resource group returned in the list from the subscription will be used for resource_group_name and resource_group_id config items
    • If no storage_account_name is specified, the storage account from the config above will be used for the storage_account_name and storage_account_id config items
    • If no key_vault_name is specified, the key vault name and ID from the config above will be used for the key_vault_name and key_vault_id config items
  • pulumi-secrets
    • (optional) Configuration block that contains key/value pairs of all the secret configuration parameters required by your pulumi scripts

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

pulumi_automation_utils-1.0.0.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

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

pulumi_automation_utils-1.0.0-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file pulumi_automation_utils-1.0.0.tar.gz.

File metadata

  • Download URL: pulumi_automation_utils-1.0.0.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for pulumi_automation_utils-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c469d33ca022cdaa48e2b53eb25a5075a1b02691cca2e1890007fcec21adc2e0
MD5 2a8605e739998c7cb4abeb07b9462a1a
BLAKE2b-256 eb972f1cf6cf260317789b958987cb4196cc10aec73253ef0296ccf787fd5cd1

See more details on using hashes here.

File details

Details for the file pulumi_automation_utils-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pulumi_automation_utils-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 97b9b0dfe660e5e879f026d9fdc3e2d97acc38ea3ccb7bd56aedc9609c911fd7
MD5 f1792217062abaf2fa935c7a370bfc02
BLAKE2b-256 15e77cd7c352350173c751805051a340ebd19159deef452d71a253dc6f0c357b

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