feluelle commented on a change in pull request #6824: [AIRFLOW-6258] add CloudFormation operators to AWS providers URL: https://github.com/apache/airflow/pull/6824#discussion_r371219387
########## File path: airflow/providers/amazon/aws/operators/cloud_formation.py ########## @@ -0,0 +1,102 @@ +# -*- coding: utf-8 -*- +# +# 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. +""" +This module contains CloudFormation create/delete stack operators. +""" +from typing import List + +from airflow.models import BaseOperator +from airflow.providers.amazon.aws.hooks.cloud_formation import AWSCloudFormationHook +from airflow.utils.decorators import apply_defaults + + +class CloudFormationCreateStackOperator(BaseOperator): + """ + An operator that creates a CloudFormation stack. + + :param stack_name: stack name (templated) + :type params: str + :param params: parameters to be passed to CloudFormation. + + .. seealso:: + https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/cloudformation.html#CloudFormation.Client.create_stack + :type params: dict + :param aws_conn_id: aws connection to uses + :type aws_conn_id: str + """ + template_fields: List[str] = ['stack_name'] + template_ext = () + ui_color = '#6b9659' + + @apply_defaults + def __init__( + self, + stack_name, + params, + aws_conn_id='aws_default', + *args, **kwargs): + super().__init__(*args, **kwargs) + self.stack_name = stack_name + self.params = params + self.aws_conn_id = aws_conn_id + + def execute(self, context): + self.log.info('Parameters: %s', self.params) + + cloudformation_hook = AWSCloudFormationHook(aws_conn_id=self.aws_conn_id) + cloudformation_hook.create_stack(self.stack_name, self.params) + + +class CloudFormationDeleteStackOperator(BaseOperator): + """ + An operator that deletes a CloudFormation stack. + + :param stack_name: stack name (templated) + :type params: str Review comment: ```suggestion :type stack_name: str ``` ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services