Skip to main content

Apache Airflow Pulumi provider containing Operators & Hooks.

Project description

Pulumi Airflow Provider

An airflow provider to:

  • preview infrastructure resources before deployment
  • deploy infrastructure resources via Pulumi
  • destroy infrastructure resources

This package currently contains

1 hook :

  • airflow_provider_pulumi.hooks.automation.PulumiAutoHook - a hook to setup the Pulumi backend connection.

4 operators :

  • airflow_provider_pulumi.operators.base.BasePulumiOperator - the base operator for Pulumi.
  • airflow_provider_pulumi.operators.preview.PulumiPreviewOperator - an operator that previews the deployment of infrastructure resources with Pulumi.
  • airflow_provider_pulumi.operators.up.PulumiUpOperator - an operator that deploys infrastructure resources with Pulumi.
  • airflow_provider_pulumi.operators.destroy.PulumiDestroyOperator - an operator that destroys infrastructure resources with Pulumi.

Requirements

These operators require the Pulumi client to be installed. Use the following script to install the Pulumi client in your Airflow environment:

curl -fsSL https://get.pulumi.com | sh
export PATH="$HOME/.pulumi/bin:$PATH"

Quick start

pip install airflow-provider-pulumi

# example_pulumi_dag.py
from datetime import datetime

from airflow.decorators import dag
from airflow_provider_pulumi.operators.destroy import PulumiDestroyOperator
from airflow_provider_pulumi.operators.preview import PulumiPreviewOperator
from airflow_provider_pulumi.operators.up import PulumiUpOperator


@dag(
    schedule_interval=None,
    start_date=datetime(2022, 1, 1),
    tags=["example"],
)
def example_pulumi():
    def create_s3_bucket():
        import pulumi
        import pulumi_aws as aws

        # Creates an AWS resource (S3 Bucket)
        bucket = aws.s3.Bucket("my-bucket")

        # Exports the DNS name of the bucket
        pulumi.export("bucket_name", bucket.bucket_domain_name)

    preview_s3_create_task = PulumiPreviewOperator(
        task_id="preview_s3_create",
        pulumi_program=create_s3_bucket,
        stack_config={"aws:region": "us-west-2"},
        plugins={"aws": "v5.0.0"},
    )

    s3_create_task = PulumiUpOperator(
        task_id="s3_create",
        pulumi_program=create_s3_bucket,
        stack_config={"aws:region": "us-west-2"},
        plugins={"aws": "v5.0.0"},
    )

    s3_destroy_task = PulumiDestroyOperator(
        task_id="s3_destroy",
        pulumi_program=create_s3_bucket,
        stack_config={"aws:region": "us-west-2"},
        plugins={"aws": "v5.0.0"},
    )

    preview_s3_create_task >> s3_create_task >> s3_destroy_task


example_pulumi_dag = example_pulumi()

Development

Unit Tests

Unit tests are located at tests, the Pulumi client is required to run these tests. Execute with pytest.

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

airflow-provider-pulumi-0.1.2.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

airflow_provider_pulumi-0.1.2-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file airflow-provider-pulumi-0.1.2.tar.gz.

File metadata

File hashes

Hashes for airflow-provider-pulumi-0.1.2.tar.gz
Algorithm Hash digest
SHA256 578cca56d643d29416aabe0e55c861c9204c49a4defbb39c2792632d6184e0a0
MD5 39165ad5a3ee992a617c64aa07064bf9
BLAKE2b-256 97bfac58a9ceb3f3ef1701f3e6ba3bcdaa84c65e607424080fcb2f8aa54e7f36

See more details on using hashes here.

Provenance

File details

Details for the file airflow_provider_pulumi-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for airflow_provider_pulumi-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1c49fe41e9c70f287d902b574db8a7caf1ad37d247d91b2418c92f6846e096d9
MD5 de05b8cb04688bc5c400d56cec9ce8b9
BLAKE2b-256 b037e43a358b7243ae3d47290321d9724963cf2b20043e52266956092db14074

See more details on using hashes here.

Provenance

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