Skip to content

Instantly share code, notes, and snippets.

@anna-geller
Created January 22, 2022 12:29
Show Gist options
  • Save anna-geller/331a60b86d09826a40d33d48574fe64a to your computer and use it in GitHub Desktop.
Save anna-geller/331a60b86d09826a40d33d48574fe64a to your computer and use it in GitHub Desktop.
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