Giter VIP home page Giter VIP logo

mwaah's Introduction

AWS MWAA (Managed Workflows for Apache Airflow) Helper - Go

Go Client for running Apache Airflow CLI commands on AWS MWAA (Managed Workflows for Apache Airflow) instances.
Built to give a client like experience for MWAA, utilizing the Apache Go Client objects. https://docs.aws.amazon.com/mwaa/latest/userguide/airflow-cli-command-reference.html

Running CLI on a private VPC instance

Test locally using the following env and ssh tunnel configuration

export HTTPS_PROXY="socks5://0:8080"
ssh -D 8080 -C -N  [email protected]

Setting up a new CLI session

Create a mwaa service session and pass it to the NewCLI constructor

sess := session.Must(session.NewSession())
// Create a MWAA client with additional configuration
svc := mwaah.New(sess, aws.NewConfig().WithRegion("example-region-1"))
mwaaName := "MWAA_ENVIRONMENT_NAME"
// create a new client without autoRefresh = false; lazily refresh cli token
cli := mwaah.NewClient(*svc, &mwaaName, false)

Examples

Triggering a New DAG Run

dagRun := airflow.NewDAGRun()
newRunId := "example-run-id"
targetDagId := "example-dag-id"
dagRun.SetDagRunId(newRunId)
dagRun.SetConf(map[string]interface{}{"foo": "bar", "blah": 1234})
dagRun.SetDagId(targetDagId)
newDagRun, err := cli.NewDagRun(*dagRun)
if err != nil {
    panic(err)
} else {
    d, _ := json.Marshal(newDagRun)
    dst := &bytes.Buffer{}
    err := json.Indent(dst, d, "", "  ")
    if err != nil {
        panic(err)
    }
    fmt.Printf("newDagRun:\n %v\n", newDagRun)
}
newDagRun:
{
  "conf": {
    "blah": 1234,
    "foo": "bar"
  },
  "dag_id": "example-dag-id",
  "dag_run_id": "example-run-id",
  "execution_date": "2022-11-17T16:08:12Z",
  "external_trigger": true
}

Getting DAGRun State

	dagState, err := cli.GetDagState(newDagRun.GetDagId(), newDagRun.GetExecutionDate())
    if err != nil {
        panic(err)
    }
	fmt.Printf("dagState: %+s", &dagState)
dagState: running

Currently Supported Apache Airflow CLI commands

Version Command
v2.0+ connections add
v2.0+ connections delete
v2.0+ dags delete
v2.2.2 dags list
v2.0+ dags list-jobs
v2.2.2 dags list-runs
v2.0+ dags pause
v2.0+ dags report
v2.0+ dags show
v2.0+ dags state
v2.0+ dags trigger
v2.0+ dags unpause
v2.0+ providers behaviours
v2.0+ providers get
v2.0+ providers hooks
v2.0+ providers links
v2.0+ providers list
v2.0+ roles list
v2.0+ tasks clear
v2.0+ tasks failed-deps
v2.0+ tasks list
v2.0+ tasks state
v2.0+ tasks states-for-dag-run
v2.0+ variables delete
v2.0+ variables get
v2.0+ variables set
v2.0+ variables list
v2.0+ version

About

Copyright (c) Warner Media, LLC. All rights reserved. Licensed under the MIT license. See the LICENSE file for license information.

mwaah's People

Contributors

gregorywiltshire avatar

Stargazers

Richard Vannauker avatar  avatar

Watchers

Kostas Georgiou avatar

Forkers

ngamradt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.