Dagster AWS

0.28.22 · active · verified Thu Apr 09

Dagster-aws provides a collection of integrations for common AWS services, enabling Dagster to orchestrate workloads involving S3, ECS, Lambda, EMR, and more. It offers resources, run launchers, and IO managers to seamlessly connect Dagster assets and operations with your AWS infrastructure. The current version is 0.28.22, and it typically releases monthly, in conjunction with major Dagster core updates.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to define a Dagster asset that interacts with Amazon S3 using `S3Resource`. It writes a simple string to a specified S3 bucket and key. Ensure you have AWS credentials configured in your environment or via IAM roles for this example to run successfully.

import os
from dagster import Definitions, asset, Config
from dagster_aws.s3 import S3Resource

class MyS3Config(Config):
    bucket: str
    key: str

@asset
def my_s3_asset(context, s3: S3Resource, config: MyS3Config):
    """
    Writes a simple string to an S3 object.
    """
    s3.get_client().put_object(
        Bucket=config.bucket,
        Key=config.key,
        Body="Hello from Dagster S3!"
    )
    context.log.info(f"Wrote to s3://{config.bucket}/{config.key}")

defs = Definitions(
    assets=[my_s3_asset],
    resources={
        "s3": S3Resource(
            region_name=os.environ.get("AWS_REGION", "us-east-1"),
            # For local testing, ensure these are set as env vars or use other AWS auth methods
            aws_access_key_id=os.environ.get("AWS_ACCESS_KEY_ID", ""),
            aws_secret_access_key=os.environ.get("AWS_SECRET_ACCESS_KEY", "")
        )
    }
)

# To run:
# 1. Ensure AWS credentials and AWS_REGION are set in your environment variables.
# 2. dagster dev -f your_file.py
# 3. In the UI, launch a run for 'my_s3_asset' with a config like:
#    {"ops": {"my_s3_asset": {"inputs": {"config": {"bucket": "your-bucket-name", "key": "my-dagster-object.txt"}}}}}}

view raw JSON →