Example #1
0
    def execute(self, context: 'Context'):
        hook = StepFunctionHook(aws_conn_id=self.aws_conn_id, region_name=self.region_name)

        execution_arn = hook.start_execution(self.state_machine_arn, self.name, self.input)

        if execution_arn is None:
            raise AirflowException(f'Failed to start State Machine execution for: {self.state_machine_arn}')

        self.log.info('Started State Machine execution for %s: %s', self.state_machine_arn, execution_arn)

        return execution_arn
Example #2
0
    def test_start_execution(self):
        hook = StepFunctionHook(aws_conn_id='aws_default',
                                region_name='us-east-1')
        state_machine = hook.get_conn().create_state_machine(
            name='pseudo-state-machine',
            definition='{}',
            roleArn='arn:aws:iam::000000000000:role/Role')

        state_machine_arn = state_machine.get('stateMachineArn', None)

        execution_arn = hook.start_execution(
            state_machine_arn=state_machine_arn,
            name=None,
            state_machine_input={})

        assert execution_arn is not None