Skip to content

Instantly share code, notes, and snippets.

@anna-geller
Created September 29, 2021 13:29
Show Gist options
  • Save anna-geller/2d1fd20e9c1ede937a86408a19a68ae1 to your computer and use it in GitHub Desktop.
Save anna-geller/2d1fd20e9c1ede937a86408a19a68ae1 to your computer and use it in GitHub Desktop.
import prefect
from prefect.storage import S3
from prefect.run_configs import ECSRun
from prefect import task, Flow
FLOW_NAME = "ecs_demo"
STORAGE = S3(
bucket="prefect-datasets",
key=f"flows/{FLOW_NAME}.py",
stored_as_script=True,
# this will ensure to upload the Flow script to S3 during registration
local_script_path=f"{FLOW_NAME}.py",
)
RUN_CONFIG = ECSRun(
labels=["prod"],
task_role_arn="arn:aws:iam::123456:role/prefectTaskRole",
run_task_kwargs=dict(cluster="prefectEcsCluster", launchType="FARGATE",),
)
@task
def say_hi():
logger = prefect.context.get("logger")
logger.info("Hi from Prefect %s", prefect.__version__)
with Flow(FLOW_NAME, storage=STORAGE, run_config=RUN_CONFIG,) as flow:
say_hi()
if __name__ == "__main__":
flow.register("ECS_Flows")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment