Close
    logoCloudomation Docs

    TaskAWS

    class tasks.task_aws.TaskAWS

    Call the AWS API using the Boto3 low-level clients. Consult the Boto3 documentation for details on clients/services/waiters and results.

    Inputs

    NameTypeDefaultDescription
    aws_access_key_idstrThe AWS access key to authenticate
    aws_secret_access_keystrThe AWS secret access key to authenticate
    clientstrThe name of the boto3 client to use. E.g. "ec2"
    parametersdictNoneAny parameters to pass to the service or waiter call
    regionstrNoneThe region in which to operate
    servicestrNoneThe service of the selected client to call
    waiterstrNoneThe waiter of the selected client to use

    Outputs

    NameTypeDefaultDescription
    resultdictThe result dictionary returned by boto3
    execution_idintThe ID of the task execution
    messagestrThe ended message for the task. If the task ended with an error, the message will contain information about what went wrong
    statusstrThe ended status for the task. Either "success" or "error".

    Constants

    input_list = ['aws_access_key_id', 'aws_secret_access_key', 'client', 'parameters', 'region', 'service', 'waiter']output_list = ['result']version = 1

    Methods

    run ()

    Example

    import flow_api
    def handler(system: flow_api.System, this: flow_api.Execution):
    # get AWS credentials from setting
    credentials = system.setting('aws credentials').get('value')
    # create a child execution task which talks with AWS
    run_instance = this.task(
    'AWS',
    region='eu-central-1',
    client='ec2',
    service='run_instances',
    parameters={
    'ImageId': 'ami-0f5dbc86dd9cbf7a8',
    'InstanceType': 't2.micro',
    'MaxCount': 1,
    'MinCount': 1,
    },
    init={
    'protect_inputs': [
    'aws_access_key_id',
    'aws_secret_access_key',
    ],
    },
    **credentials
    )
    # provide the response back to the caller
    run_instance_outputs = run_instance.get('output_value')
    this.log(run_instance_outputs=run_instance_outputs)
    # wait until the instance is running
    instance_id = run_instance_outputs['result']['Instances'][0]['InstanceId']
    wait_available = this.task(
    'AWS',
    region='eu-central-1',
    client='ec2',
    waiter='instance_running',
    parameters={
    'InstanceIds': [
    instance_id,
    ]
    },
    **credentials
    )
    # provide the response back to the caller
    wait_available_outputs = wait_available.get('output_value')
    this.log(wait_available_outputs=wait_available_outputs)
    return this.success('all done')

    An extended example can be found in the library: Example Task AWS

    Previous
    Task
    Next
    TaskGIT