Emma Rizzi
06/11/2021, 12:59 PMJenny
06/11/2021, 1:33 PMJenny
06/11/2021, 1:36 PMEmma Rizzi
06/11/2021, 1:38 PMEmma Rizzi
06/11/2021, 1:59 PMJenny
06/11/2021, 3:57 PMJenny
06/11/2021, 4:23 PMBen Muller
06/11/2021, 11:45 PMcdk deploy
and once you register all the other things from the tutorial you should have a stack that is working.Ben Muller
06/11/2021, 11:45 PMBen Muller
06/11/2021, 11:46 PMimport prefect
from prefect.storage import S3, Docker
from prefect.run_configs import ECSRun
from prefect import task, Flow, Parameter
RUN_CONFIG = ECSRun(
run_task_kwargs={
"cluster": "prefect-agent-cluster",
"networkConfiguration":{'awsvpcConfiguration': {'assignPublicIp': 'ENABLED', 'subnets': ['subnet-0a8725c8a7e43f884', 'subnet-0dc09bddb5e1274e0'], 'securityGroups': []}}
},
labels=['s3-flow-storage'],
task_role_arn="arn:aws:iam::***:role/ECSTaskS3ECRRole",
execution_role_arn='arn:aws:iam::****:role/ECSFullyLoaded',
# image='prefecthq/prefect:latest-python3.8',
# memory=512,
# cpu=256
)
# STORAGE = Docker(
# registry_url='****.<http://dkr.ecr.ap-southeast-2.amazonaws.com/|dkr.ecr.ap-southeast-2.amazonaws.com/>',
# image_name='prefect-tutorial',
# image_tag='latest',
# dockerfile='./Dockerfile'
# )
STORAGE = S3(
bucket="prefect-tutorial",
stored_as_script=True,
local_script_path='./ecs_flow.py'
)
@task
def say_something(words):
logger = prefect.context.get("logger")
<http://logger.info|logger.info>(f'I printed {words}')
with Flow(
"fargate-task-please",
storage=STORAGE,
run_config=RUN_CONFIG
) as flow:
message = Parameter('message', default='default')
say_something(words=message)
flow.register(project_name="aws-flow")
Emma Rizzi
06/12/2021, 12:34 PMEmma Rizzi
06/14/2021, 8:53 AMprefecthq/prefect:latest
image for my flow, and see that PREFECT__CLOUD__API
is set to localhost in environment variables on AWS console. As i deployed Prefect server on another instance than the one running the tasks, I guess it breaks the communication. I tried to set it in the env parameter of ECSRun but it seems to get overriden to localhost afterward.
Do you know if I have to make a custom image with the correct Prefect adress, or do i have to change it somewhere else ?Emma Rizzi
06/14/2021, 9:37 AM[cloud]
api = "<http://XXX:4200>"
To the config file, I had to look at the source code to find where and how PREFECT__CLOUD__API
is overriden. I think its worth adding this to the docs, as its required to run Prefect Server with other agents than Local and it doesn't seem obvious to look at cloud config when running server 🙂Jenny
06/15/2021, 1:12 PMEmma Rizzi
06/15/2021, 1:30 PMprefect backend server
so I guess it is set properly. I find it very strange too but i found this line that suggested me to use cloud.api to configure the backend addressEmma Rizzi
06/15/2021, 1:39 PMJenny
06/15/2021, 1:46 PMEmma Rizzi
06/15/2021, 1:48 PMJenny
06/16/2021, 11:44 AMMarvin
06/16/2021, 11:44 AMEmma Rizzi
06/16/2021, 11:58 AM