josh-fell commented on a change in pull request #18645: URL: https://github.com/apache/airflow/pull/18645#discussion_r719668970
########## File path: airflow/providers/amazon/aws/example_dags/example_eks_with_fargate_in_one_step.py ########## @@ -0,0 +1,100 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +from os import environ + +from airflow.models.dag import DAG +from airflow.providers.amazon.aws.hooks.eks import ClusterStates, FargateProfileStates +from airflow.providers.amazon.aws.operators.eks import ( + EKSCreateClusterOperator, + EKSDeleteClusterOperator, + EKSPodOperator, +) +from airflow.providers.amazon.aws.sensors.eks import EKSClusterStateSensor, EKSFargateProfileStateSensor +from airflow.utils.dates import days_ago + +CLUSTER_NAME = 'fargate-all-in-one' +FARGATE_PROFILE_NAME = f'{CLUSTER_NAME}-profile' + +ROLE_ARN = environ.get('EKS_DEMO_ROLE_ARN', 'arn:aws:iam::123456789012:role/role_name') +SUBNETS = environ.get('EKS_DEMO_SUBNETS', 'subnet-12345ab subnet-67890cd').split(' ') +VPC_CONFIG = { + 'subnetIds': SUBNETS, + 'endpointPublicAccess': True, + 'endpointPrivateAccess': False, +} + + +with DAG( + dag_id='example-create-cluster-and-fargate-all-in-one', + schedule_interval=None, + start_date=days_ago(2), + max_active_runs=1, + tags=['example'], +) as dag: + + # [START howto_operator_eks_create_cluster_with_fargate_profile] + # Create an Amazon EKS cluster control plane and an AWS Fargate compute platform in one step. + create_cluster_and_fargate_profile = EKSCreateClusterOperator( + task_id='create_eks_cluster_and_fargate_profile', + cluster_name=CLUSTER_NAME, Review comment: Since `cluster_name` is used in every operator with the same value in this DAG, would be a great use case to add the arg to `default_args`. You may need to include a comment that this arg is set in `default_args` of the DAG so it's known while reading the operator doc. ########## File path: airflow/providers/amazon/aws/example_dags/example_eks_with_fargate_in_one_step.py ########## @@ -0,0 +1,100 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +from os import environ + +from airflow.models.dag import DAG +from airflow.providers.amazon.aws.hooks.eks import ClusterStates, FargateProfileStates +from airflow.providers.amazon.aws.operators.eks import ( + EKSCreateClusterOperator, + EKSDeleteClusterOperator, + EKSPodOperator, +) +from airflow.providers.amazon.aws.sensors.eks import EKSClusterStateSensor, EKSFargateProfileStateSensor +from airflow.utils.dates import days_ago + +CLUSTER_NAME = 'fargate-all-in-one' +FARGATE_PROFILE_NAME = f'{CLUSTER_NAME}-profile' + +ROLE_ARN = environ.get('EKS_DEMO_ROLE_ARN', 'arn:aws:iam::123456789012:role/role_name') +SUBNETS = environ.get('EKS_DEMO_SUBNETS', 'subnet-12345ab subnet-67890cd').split(' ') +VPC_CONFIG = { + 'subnetIds': SUBNETS, + 'endpointPublicAccess': True, + 'endpointPrivateAccess': False, +} + + +with DAG( + dag_id='example-create-cluster-and-fargate-all-in-one', + schedule_interval=None, + start_date=days_ago(2), + max_active_runs=1, + tags=['example'], +) as dag: Review comment: We should have new example DAGs use a static `start_date` value. There is an ongoing cleanup effort across all example DAGs to transition away from using `days_ago(n)`. ########## File path: airflow/providers/amazon/aws/example_dags/example_eks_with_fargate_profile.py ########## @@ -0,0 +1,129 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +from os import environ + +from airflow.models.dag import DAG +from airflow.providers.amazon.aws.hooks.eks import ClusterStates, FargateProfileStates +from airflow.providers.amazon.aws.operators.eks import ( + EKSCreateClusterOperator, + EKSCreateFargateProfileOperator, + EKSDeleteClusterOperator, + EKSDeleteFargateProfileOperator, + EKSPodOperator, +) +from airflow.providers.amazon.aws.sensors.eks import EKSClusterStateSensor, EKSFargateProfileStateSensor +from airflow.utils.dates import days_ago + +CLUSTER_NAME = 'fargate-demo' +FARGATE_PROFILE_NAME = f'{CLUSTER_NAME}-profile' +SELECTORS = environ.get('FARGATE_SELECTORS', [{'namespace': 'default'}]) + +ROLE_ARN = environ.get('EKS_DEMO_ROLE_ARN', 'arn:aws:iam::123456789012:role/role_name') +SUBNETS = environ.get('EKS_DEMO_SUBNETS', 'subnet-12345ab subnet-67890cd').split(' ') +VPC_CONFIG = { + 'subnetIds': SUBNETS, + 'endpointPublicAccess': True, + 'endpointPrivateAccess': False, +} + + +with DAG( Review comment: Same `start_date` and `cluster_name` comments are also applicable here. -- 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]
