Skip to main content
Version: 9 - Germknödel

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

  • aws_access_key_id

    The AWS access key to authenticate.

    Type: string

  • aws_secret_access_key

    The AWS secret access key to authenticate.

    Type: string

  • aws_session_token

    The AWS temporary session token to authenticate.

    Type: anyOf

  • region

    The region in which to operate.

    Type: anyOf

  • client

    The name of the boto3 client to use. E.g. "ec2".

    Type: string

  • mode

    The mode to operate in.

    Type: anyOf

  • service

    DEPRECATED. Replaced my mode.service. Will be removed with Cloudomation version 10.

  • waiter

    DEPRECATED. Replaced by mode.waiter. Will be removed with Cloudomation version 10.

  • parameters

    DEPRECATED. Replaced by mode.parameters. Will be removed with Cloudomation version 10.

Output Schema

  • result

    Data

Constants

ssl_context_inputs = ['check_hostname', 'client_cert', 'client_key', 'server_ca']

Example

import flow_api

def handler(system: flow_api.System, this: flow_api.Execution, inputs: dict):
# 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, inputs: dict):
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 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',
region='eu-central-1',
client='s3',
service='upload_fileobj',
parameters={
'Fileobj': {
'file': 'the Engine 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, inputs: dict):
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')