Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
from ecsruntask import ECSRunTask # import wherever your task lives
from prefect import task, Flow
ecs = ECSRunTask(
task_definition="stockdata",
cluster="ecsDemo",
network_configuration={
"awsvpcConfiguration": {
"subnets": ["subnet-xxx", "subnet-xxx", "subnet-xxx"],
"assignPublicIp": "ENABLED", # if disabled, it won't be able to pull image from ECR
}
},
)
@task(log_stdout=True)
def print_response(boto3_response: str):
print(boto3_response)
with Flow("ecs_run_task") as flow:
ecs_task = ecs()
print_response(ecs_task)
# https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/logs.html#CloudWatchLogs.Client.describe_log_streams
# https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/logs.html#CloudWatchLogs.Client.get_log_events
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment