Skip to main content
Version: 7 - Gugelhupf

ConnectorTypeAWS

class connector_types.connector_type_aws.ConnectorTypeAWS

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. Either "service" or "waiter" is required.
waiterstrNoneThe waiter of the selected client to use. Either "service" or "waiter" is required.

Outputs

NameTypeDefaultDescription
resultdictThe result dictionary returned by boto3

Constants

input_list = ['aws_access_key_id', 'aws_secret_access_key', 'client', 'parameters', 'region', 'service', 'waiter'] output_list = ['result'] ssl_context_inputs = ['check_hostname', 'client_cert', 'client_key', 'server_ca'] version = 1

Methods

execute

log

one_of_inputs

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 connection which talks with AWS
run_instance = this.connect(
connector_type='AWS',
region='eu-central-1',
client='ec2',
service='run_instances',
parameters={
'ImageId': 'ami-0f5dbc86dd9cbf7a8',
'InstanceType': 't2.micro',
'MaxCount': 1,
'MinCount': 1,
},
**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.connect(
connector_type='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')

More

File Upload

To upload files to s3 please use one of the following methods.

Uploading Strings

Use the following format for the Fileobj parameter:

import flow_api

def handler(system: flow_api.System, this: flow_api.Execution):
this.connect(
connector_type='AWS',
region='eu-central-1',
client='s3',
service='upload_fileobj',
parameters={
'Fileobj': {
'string': 'the file content',
},
'Bucket': 'the name of the bucket to upload to',
'Key': 'the name of the key to upload to',
},
**credentials
)
return this.success('all done')
Uploading Cloudomation Files

Use the following format for the Fileobj parameter:

import flow_api

def handler(system: flow_api.System, this: flow_api.Execution):
this.connect(
connector_type='AWS',
region='eu-central-1',
client='s3',
service='upload_fileobj',
parameters={
'Fileobj': {
'file': 'the Cloudomation filename',
},
'Bucket': 'the name of the bucket to upload to',
'Key': 'the name of the key to upload to',
},
**credentials
)
return this.success('all done')
Uploading Binary Data

Use the following format for the media_body parameter:

import flow_api

def handler(system: flow_api.System, this: flow_api.Execution):
this.connect(
connector_type='AWS',
region='eu-central-1',
client='s3',
service='upload_fileobj',
parameters={
'Fileobj': {
'base64': 'cmVhZGluZyB0aGlzPyBhcHBseSBub3cgYXQgaHR0cHM6Ly9jbG91ZG9tYXRpb24uY29tL2pvYnMvICE=',
},
'Bucket': 'the name of the bucket to upload to',
'Key': 'the name of the key to upload to',
},
**credentials
)
return this.success('all done')