- Step 1. Create key pairs
- Step 2. Create a security group
- Step 3. Launching an EC2 instance
- Step 4. Connect to EC2 instance
- Step 5. Install the Pipelines agent
- Step 6. Add the new instance to Pipelines
- Step 7. Deploy your application
Amazon Elastic Compute Cloud (EC2) is a virtual server that can be scaled up and down to meet app traffic demands. This tutorial walks through the steps to configure and launch AWS EC2 Instance.
To complete this tutorial, you need register a free account with AWS (the AWS Free-Tier gives you access to AWS’s basic services, which are sufficient to complete this tutorial), and Pipelines. Save your login credentials as you will need them for this tutorial.
Step 1. Create key pairs
Amazon EC2 uses public–key cryptography to encrypt and decrypt login information and we will have to create a Key Pair to log into our instance.
- Navigate to the AWS Console, then click on EC2.
- On the left pane, click on Key Pairs, then click on Create Key Pair
- Enter a name for your key, then click Create. The Key Pair will be automatically downloaded. You should move this key to a perminent location.
- To use SSH client on Mac or Linux you will need to change the permissions of this key to ready-only.
chmod 400 youKeyName.pem
Step 2. Create a security group
Security Group is a traffic control layer to your instance. You can specify which IP address is welcome for a particular protocal. For example, HTTP and SSH.
- Navigate to the left pane of your EC2, and click on Security Groups, then click Create Security Group.
- Fill out the **Security group name** and give it a **Description**. On the **Inbound** tab, click **Add Rules** create the following 3 rules:
- Rule 1. Seletect HTTP under Type, make sure Source is set to *Anywhere.
- Rule 2. Select HTTPS, make sure Source is set to Anywhere.
- Rule 3. Select SSH, make sure Source is set to My IP.
Step 3. Launching an EC2 instance
We are now ready to launch our EC2 instance. There are only a few steps left until your EC2 instance is up and running and ready for code to be deployed!
- On the left pane, click on EC2 Dashboard, then click on Launch Instance
- Choose your server operating system and proceed.
- Select Configure Security Group on top of the page.
- Check the option Select an existing security group, then seleted the name of your group.
- Click Review and Launch.
- Click Launch. Select the key pair you created, then select Launch Instances.
To make sure you have successfully launched your instance, navigate to the left pane of the EC2 page, and click on Instances. Check out Instance State, and make sure that it is running. You will need your instance IP address to connect to your instance. Your instance IP address can be found in the instance’s details. Refer to the image below:
Step 4. Connect to EC2 instance
With your running instance, let’s connect to your it using SSH.
- Open your terminal. Navigate to the directory where your Key Pairs are saved. Enter this command:
ssh -i "YOUR_KEY_PAIR_NAME.pem" [email protected]_INSTANCE_IP_ADDRESS
- Enter the following command to update your instance:
sudo apt-get update
Congratulations, you now have access your server!
Step 5. Install the Pipelines agent
The Pipelines agent facilitates the auto deploy process. Install the Pipelines agent with the following command:
Linux and macOS X
To install on Linux or macOS X you can use either curl or wget with one of the following syntaxes.
wget -qO- https://pipelines.puppet.com/download/client | sh
curl -sSL https://pipelines.puppet.com/download/client | sh
To install on Windows, copy and paste the following PowerShell command into a command (cmd) window.
powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://pipelines.puppet.com/download/client.ps1'))" & SET PATH=%PATH%;%ProgramFiles%/Distelli
Complete the install
After downloading the agent, you must run the install command to install the agent. To do so use the
agent install command.
Note: This installation requires root (administrator) permissions.
[email protected]:~$ <b>wget -qO- https://pipelines.puppet.com/download/client | sh</b> This script requires superuser privileges to install packages Please enter your password at the sudo prompt [sudo] password for jdoe: Installing Distelli CLI 3.55 for architecture 'Linux-x86_64'... Downloading https://s3.amazonaws.com/download.distelli.com/distelli.Linux-x86_64/distelli.Linux-x86_64-3.55.gz To install the agent, run: sudo /usr/local/bin/distelli agent install [email protected]:~$ <b>sudo /usr/local/bin/distelli agent install</b> Distelli Email: <b>[email protected]</b> Password: 1: User: jdoe 2: Team: janedoe/teamjane Team : <b>1</b> Server Info: https://www.distelli.com/jdoe/servers/d0c4b300-9fcf-2846-ba90-080027c8277c Starting upstart daemon with name: dtk-supervise-cc1233c06f7ad94a8d34ac610381242f9ae28bb8 [email protected]:~$
Verify the install
To validate the agent is installed and working use the
agent status command.
/usr/local/bin/distelli agent status Distelli Agent (serverA) is Running with id 766b88c8-e925-11e4-ae8b-080027cc07f7
Step 6. Add the new instance to Pipelines
You installed the Pipelines agent to your server. The agent will allow Pipelines to communicate with your server, and facilitate the auto deploy process. Let’s add the server to Pipelines.
- Login to your Pipelines account
- At the top menu, click Servers
- In the top right on the page, click Add Server
- Click Add existing server
- Next, click Install complete since you have already installed the Pipelines Agent.
- In step 3 of adding server, Pipelines makes connection with the Pipelines Agent. In the final step of the process, select BETA environment, then click Add Environments.
Note: You can save this EC2 instance as an Amazon Machine Image. This will allow you to launch identical EC2 instances without going through the entire set up process.
Step 7. Deploy your application
Now that our AWS EC2 Instance is launched and the Pipelines agent is installed on our server, we are now ready to deploy our application. See the Deployment tutorials section for information on deployments.