EC2

Prerequisites

EC2 agents rely on the boto3 and botocore packages. These require you to set up authentication credentials for your AWS account. More information can be found here.

In addition, you'll need to make sure your account has the necessary privileges to create EC2 instances, security groups, and key-pairs. Contact your account administrator to help out with this.

Configuring your EC2 agent

Docker agents are configured using a YML file:

# ec2_agent.yml

agent:
  type: ec2
  instance_type: # instance type, e.g., t2.micro
  requirements:  # path to requirements.txt, relative to this file
  env:
    <env var 1>: 'env var 1 value'

The YML file has a single top-level key, agent. This key contains all the configurations needed for your agent. Specifically:

  • type: this will always be ec2 for EC2 agents

  • instance_type: the EC2 instance type. Note that different instance types are optimized for different use cases. The full list of EC2 instance types can be found here.

  • requirements: path to the requirements.txt file. This path must be relative to the path of the agent YML file.

  • env: {key,value} pairs representing environment variables to add to your Docker image

Example agent

For the remainder of this guide, let's assume that we have the following project.

And, let's assume that we defined our ec2_agent.yml as follows:

Note the way we specified the requirements key. We can do this because ec2_agent.yml and requirements.txt are in the same directory.

Creating your EC2 agent

You can build your EC2 agent using the command: prism agent apply -f <path to agent YML> (note: logs are truncated for visibility):

If you check your EC2 console, you'll see an EC2 instance called etl_project_ec2_agent!

Running your Docker agent

There are two commands you can use to run your Docker agent.

prism agent run

The prism agent run command streams your project onto your EC2 instance:

prism agent build

The prism agent build command updates your project files within your EC2 instance and executes the project onto it.

Last updated