ebizboy commented on issue #50742:
URL: https://github.com/apache/airflow/issues/50742#issuecomment-2942560102
@o-nikolas
Here's the sample DAG file you requested. It works when reattach is set to
False, but it throws an error when set to True.
I've also attached the sample ECS cluster and task definition that I used
for testing.
sample dag
```python
from airflow import DAG
from datetime import timedelta
from airflow.providers.amazon.aws.operators.ecs import EcsRunTaskOperator
import pendulum
from textwrap import dedent
with DAG(
dag_id="ztest_ecs_fargate_example_dag",
start_date=pendulum.today('UTC').add(days=-1),
schedule=None,
catchup=False,
description="EcsRunTaskOperator example DAG",
tags=["example"],
doc_md=dedent(
"""
EcsRunTaskOperator example DAG
"""
)
):
EcsRunTaskOperator(
task_id="ecs_fargate_task_1",
cluster="test",
task_definition="arn:aws:ecs:ap-northeast-2:xxxxxxxxxx:task-definition/test-ecs-task:3",
overrides={
"containerOverrides": [],
},
network_configuration={
'awsvpcConfiguration': {
'securityGroups': ['sg-0xxxxxxxxx'],
'subnets': ['subnet-0xxxxxxxxx'],
'assignPublicIp': "ENABLED",
}
},
reattach=True,
awslogs_group="TestAirflowStack-testecstaskdefinitiontestecscontainerLogGroupC0613075-xxxxxxx",
awslogs_region="ap-northeast-2",
awslogs_stream_prefix="ecs-test/test-ecs-container",
awslogs_fetch_interval=timedelta(seconds=1),
launch_type="FARGATE",
)
```
cdk typescript code snippet
```typescript
const testEcsCluster = new ecs.Cluster(this, "test_ecs_cluster", {
vpc: vpc,
clusterName: "test",
enableFargateCapacityProviders: true,
});
const testEcsTaskDefinition = new ecs.FargateTaskDefinition(
this,
"test_ecs_task_definition",
{
cpu: 256,
memoryLimitMiB: 1024,
runtimePlatform: {
operatingSystemFamily: ecs.OperatingSystemFamily.LINUX,
cpuArchitecture: ecs.CpuArchitecture.ARM64,
},
family: "test-ecs-task",
}
);
testEcsTaskDefinition.addContainer("test-ecs-container", {
image: ecs.ContainerImage.fromRegistry("alpine:latest"),
command: ["sh", "-c", "for i in 1 2 3 4 5; do echo \"Hello from ECS Task -
iteration $i\"; sleep 1; done"],
logging: ecs.LogDriver.awsLogs({
streamPrefix: "ecs-test",
logRetention: logs.RetentionDays.ONE_DAY,
}),
});
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]