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
Name | Type | Default | Description |
---|---|---|---|
aws_access_key_id | str | The AWS access key to authenticate | |
aws_secret_access_key | str | The AWS secret access key to authenticate | |
client | str | The name of the boto3 client to use. E.g. "ec2" | |
parameters | dict | None | Any parameters to pass to the service or waiter call |
region | str | None | The region in which to operate |
service | str | None | The service of the selected client to call |
waiter | str | None | The waiter of the selected client to use |
Outputs
Name | Type | Default | Description |
---|---|---|---|
result | dict | The result dictionary returned by boto3 | |
execution_id | int | The ID of the task execution | |
message | str | The ended message for the task. If the task ended with an error, the message will contain information about what went wrong | |
status | str | The 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 = 1Methods
run ()
Example
import flow_apidef handler(system: flow_api.System, this: flow_api.Execution):# get AWS credentials from settingcredentials = system.setting('aws credentials').get('value')# create a child execution task which talks with AWSrun_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 callerrun_instance_outputs = run_instance.get('output_value')this.log(run_instance_outputs=run_instance_outputs)# wait until the instance is runninginstance_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 callerwait_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