Skip to main content
Version: 11 - TBD

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.

Input Schema

  • schema_version

    Type: string

  • authentication

    Type: anyOf

  • mode

    Type: anyOf

  • region

    The region in which to operate.

    See https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services/ for a list of services offered in a region.

    Type: string

Output Schema

  • result

    Data

Example

import flow_api

def handler(system: flow_api.System, this: flow_api.Execution, inputs: dict):
# create a child execution connection which talks with AWS
run_instance = this.connect(
connector_type='AWS',
authentication={
'authentication_method': 'aws_access_key',
'aws_access_key_id': '...',
'aws_secret_access_key': '...',
},
mode={
'mode_name': 'call_service',
'client': 'ec2',
'service': 'run_instances',
'kwargs': {
'ImageId': 'ami-0f5dbc86dd9cbf7a8',
'InstanceType': 't2.micro',
'MaxCount': 1,
'MinCount': 1,
},
},
region='eu-central-1',
)
# 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',
authentication={
'authentication_method': 'aws_access_key',
'aws_access_key_id': '...',
'aws_secret_access_key': '...',
},
mode={
'mode_name': 'call_waiter',
'client': 'ec2',
'waiter': 'instance_running',
'kwargs': {
'InstanceIds': [
instance_id,
]
},
},
region='eu-central-1',
)
# 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, inputs: dict):
this.connect(
connector_type='AWS',
authentication={
'authentication_method': 'aws_access_key',
'aws_access_key_id': '...',
'aws_secret_access_key': '...',
},
mode={
'mode_name': 'call_service',
'client': 's3',
'service': 'upload_fileobj',
'kwargs': {
'Fileobj': {
'string': 'the file content',
},
'Bucket': 'the name of the bucket to upload to',
'Key': 'the name of the key to upload to',
},
},
region='eu-central-1',
)
return this.success('all done')
Uploading Cloudomation Engine Files

Use the following format for the Fileobj parameter:

import flow_api

def handler(system: flow_api.System, this: flow_api.Execution, inputs: dict):
this.connect(
connector_type='AWS',
authentication={
'authentication_method': 'aws_access_key',
'aws_access_key_id': '...',
'aws_secret_access_key': '...',
},
mode={
'mode_name': 'call_service',
'client': 's3',
'service': 'upload_fileobj',
'kwargs': {
'Fileobj': {
'file': 'the Engine filename',
},
'Bucket': 'the name of the bucket to upload to',
'Key': 'the name of the key to upload to',
},
},
region='eu-central-1',
)
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, inputs: dict):
this.connect(
connector_type='AWS',
authentication={
'authentication_method': 'aws_access_key',
'aws_access_key_id': '...',
'aws_secret_access_key': '...',
},
mode={
'mode_name': 'call_service',
'client': 's3',
'service': 'upload_fileobj',
'kwargs': {
'Fileobj': {
'base64': 'cmVhZGluZyB0aGlzPyBhcHBseSBub3cgYXQgaHR0cHM6Ly9jbG91ZG9tYXRpb24uY29tL2pvYnMvICE=',
},
'Bucket': 'the name of the bucket to upload to',
'Key': 'the name of the key to upload to',
},
},
region='eu-central-1',
)
return this.success('all done')