create_cluster_and_fargate_profile = EksCreateClusterOperator( task_id='create_eks_cluster_and_fargate_profile', cluster_name=CLUSTER_NAME, cluster_role_arn=ROLE_ARN, resources_vpc_config=VPC_CONFIG, compute='fargate', fargate_profile_name=FARGATE_PROFILE_NAME, # Opting to use the same ARN for the cluster and the pod here, # but a different ARN could be configured and passed if desired. fargate_pod_execution_role_arn=ROLE_ARN, ) # [END howto_operator_eks_create_cluster_with_fargate_profile] await_create_fargate_profile = EksFargateProfileStateSensor( task_id='wait_for_create_fargate_profile', cluster_name=CLUSTER_NAME, fargate_profile_name=FARGATE_PROFILE_NAME, target_state=FargateProfileStates.ACTIVE, ) start_pod = EksPodOperator( task_id="run_pod", pod_name="run_pod", cluster_name=CLUSTER_NAME, image="amazon/aws-cli:latest", cmds=["sh", "-c", "echo Test Airflow; date"], labels={"demo": "hello_world"}, get_logs=True, # Delete the pod when it reaches its final state, or the execution is interrupted. is_delete_operator_pod=True, )
task_id='wait_for_create_cluster', target_state=ClusterStates.ACTIVE, ) # [START howto_operator_eks_create_fargate_profile] create_fargate_profile = EksCreateFargateProfileOperator( task_id='create_eks_fargate_profile', pod_execution_role_arn=ROLE_ARN, fargate_profile_name=FARGATE_PROFILE_NAME, selectors=SELECTORS, ) # [END howto_operator_eks_create_fargate_profile] await_create_fargate_profile = EksFargateProfileStateSensor( task_id='wait_for_create_fargate_profile', fargate_profile_name=FARGATE_PROFILE_NAME, target_state=FargateProfileStates.ACTIVE, ) start_pod = EksPodOperator( task_id="run_pod", pod_name="run_pod", image="amazon/aws-cli:latest", cmds=["sh", "-c", "echo Test Airflow; date"], labels={"demo": "hello_world"}, get_logs=True, # Delete the pod when it reaches its final state, or the execution is interrupted. is_delete_operator_pod=True, ) # [START howto_operator_eks_delete_fargate_profile]