UiPath – How to Copy Files to AWS S3

This tutorial will walk you through how to copy files from the local drive to an AWS S3 bucket during a UiPath RPA process. One use case is creating a feed where data is scraped from a website, the data is stored in a .csv file during the process and then the .csv file is copied to an S3 bucket for use by another system.

Pre-requisites:

  1. Create an S3 user for the process in AWS IAM see this article
  2. Download the public and secret access keys for the user for use in the AWS CLI tool
  3. Download, install and configure the AWS CLI tool, see this article
    • This needs to be done in all environments where the process will be used – e.g. development, production etc.
  4. Write the process to extract the data and create the .csv file in UIPath Studio

Method:

  1. Use the Invoke Power Shell activity
    • UIPath.Core.Activities.InvokePowerShell<System.String>
  2. In the Properties panel, add the CLI CommandText to copy the file from its current location to the S3 bucket
    • "aws s3 cp YOURFILEPATH s3://YOURBUCKETNAME/YOURFILENAME"
  3. Check the IsScript checkbox
  4. Change the TypeArgument to String
UiPath AWS S3 Power Shell Activity
UiPath AWS S3 Power Shell Activity
UiPath AWS S3 Power Shell Activity Properties Panel
UiPath AWS S3 Power Shell Activity Properties Panel

How to Point Your Domain Name to Your AWS Lightsail Bitnami WordPress Website

This tutorial will teach you how to point a domain name purchased from a domain name registrar other than AWS Route 53 to your Bitnami WordPress site created through AWS Lightsail.

Prerequisites

  1. You have the public IP address for your website from the AWS Lightsail console – see How to Create a WordPress Blog using AWS Lightsail
  2. You have purchased a domain name for the site and you have access to the domain registrar’s admin area to change Domain Name System (DNS) settings

Pointing your domain to your website

Step 1 – Login to AWS Console and go to Route 53

Step 2 – Click on Hosted Zones and create a hosted zone with the domain name you have purchased – enter it without the www

Step 3 – Select the type as a public hosted zone

Step 4 – You will see a type NS with four entries like ns-95-awsdns-11.com in the Value column, make a note of them

Step 5 – Create a subdomain for the www prefix by entering the following in the Create Record Set area on the right-hand side:

  • Type: A – IPv4 address
  • Alias: Yes
  • Alias Target:  select your domain name
  • Routing Policy: Simple
  • Evaluate target health: No

Step 6 – Login into the domain registrar’s admin panel i.e. where you bought your domain name

Step 7 – Select the domain you want to manage

Step 8 – Go to Manage DNS Settings or similar

Step 9 – Change the Name Servers to the AWS name servers noted in Step 4.  There may be two default settings but you need to overwrite them and add two more so it shows the four namespace servers from AWS

Step 10 – Save the settings and wait for a few minutes, your website should now appear when you put its URL in the browser.

How to Configure the AWS CLI

In this tutorial, I will show you how to set up and configure the AWS CLI on a AWS Linux AMI.

Prerequisites

  1. You have created your AWS EC2 instance using the standard Linux AMI and can get access to it using SSH
  2. You have set up security credentials in IAM and have downloaded your access keys

Configuring the AWS CLI

Step 1 – SSH into the instance and login as ec2-user

Step 2 – Type the following at the prompt

$ aws configure

Step 3 – Enter your Access Key ID

Step 4 – Enter your Secret Access Key

Step 5 – Enter the Default region name

Step 6 – Enter the Default output format

$ aws configure
AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None]: us-west-2
Default output format [None]: json

How to Create an AWS IAM User and Role for Programmatic AWS S3 Access

In this tutorial I am going to show you how to create an AWS IAM role so you can create access keys to use to copy files to and from AWS S3 buckets via the AWS Command Line Interface (CLI).

This is useful if you need to transfer files from S3 to an EC2 instance using the CLI.

Prerequisites

  1. You have an AWS account
  2. You have an EC2 instance created
  3. You have access to IAM within the AWS Console

Creating an IAM Role

Step 1 – Open the IAM Console

Step 2 – Click on Users

How to Create an AWS IAM User and Role for Programmatic AWS S3 Access
Click on Users



Step 3 – Click ‘Add user’

How to Create an AWS IAM User and Role for Programmatic AWS S3 Access
Click ‘Add User’

 

Step 4 – Enter a unique user name

Step 5 – Check Programmatic Access

How to Create an AWS IAM User and Role for Programmatic AWS S3 Access
Enter a user name and check programmatic access

Step 6 – Click Next: Permissions

How to Create an AWS IAM User and Role for Programmatic AWS S3 Access

Step 7 – Click ‘Attach existing policies directly’

How to Create an AWS IAM User and Role for Programmatic AWS S3 Access
Click ‘Attach existing policies directly’

 

Step 8 – Enter S3 in the’ Filter policies’ field

Step 9 – Check ‘AmazonS3FullAccess’ or ‘AmazonS3ReadOnlyAccess’ depending on your requirements

How to Create an AWS IAM User and Role for Programmatic AWS S3 Access
Enter S3 in ‘Filter policies’ and check S3FullAccess or AmazonS3ReadOnlyAccess

Step 10 – Click Next: Review

How to Create an AWS IAM User and Role for Programmatic AWS S3 Access

Step 11 – Review and Click ‘Create user’

How to Create an AWS IAM User and Role for Programmatic AWS S3 Access
Review and click ‘Create user’

Step 12 – Download the key pair and store securely – don’t email, share them outside your organization – keep the keys confidential.  You can only download them once.

How to Create an AWS IAM User and Role for Programmatic AWS S3 Access
View and download the key pair

 

 

 

 

 

How to Copy Files from AWS S3 to an Amazon Web Services (AWS) EC2 Instance

In this tutorial I will show you how you can copy files from S3 to an Amazon Web Services EC2 instance using the AWS Command Line Interface (CLI).

The basic concept of the AWS CLI S3 commands is that you have two types of path arguments: LocalPath and S3Uri.

The LocalPath is the local file or directory. The S3Uri is the location of a S3 object or bucket written in the form S3://mybucket/myobjectkey.

In each command, one path argument represents the source and the other the destination.

Prerequisites

  1. You have an EC2 instance running and can get access to it using SSH
  2. You have configured the AWS CLI on your instance using keys with read/write access to S3 – see How to Configure the AWS CLI
  3. You have a bucket or buckets set up containing some test files or objects

Copying a file to S3

$ aws s3 cp MyFile.txt s3://my-bucket/path/

Moving all files from S3

$ aws s3 mv s3://my-bucket/path ./MyDirectory --recursive

Removing a file from S3

$ aws s3 rm s3://my-bucket/path/MyFile.txt

Syncing current directory with a S3 bucket

$ aws s3 sync . s3://my-bucket/path

Delete all contents of a bucket

$ aws s3 rm s3://my-bucket/path --recursive

List all buckets

$ aws s3 ls

List contents of a bucket

$ aws s3 ls s3://bucket-name

How to Copy Files to an AWS EC2 Instance Using WinSCP and SFTP

This tutorial will show you how you can transfer files from your local machine running Windows to an AWS EC2 or Lightsail instance using SFTP and the WinSCP client.

Prerequisites

  1. You have created the instance using EC2 using the Amazon Linux AMI or AWS Lightsail
  2. You are using a Windows computer
  3. You have a .ppk private key – see How to Create a PPK file from a PEM file – Windows 10
  4. You have downloaded and installed the free WinSCP SFTP, SCP and FTP client for Windows



Transferring files to the EC2 Instance

Step 1 – Open WinSCP

Step 2 –  Click on Session, New Session or press Ctrl+N

How to Copy Files to an AWS EC2 Instance Using SFTP
Use Ctrl+N to connect to a new site

Step 3 – Click on ‘New Site’

Step 4 – Enter the public IP address for your instance in the Host name field

How to Copy Files to an AWS EC2 Instance Using SFTP
Enter the Host Name, User Name, then click on ‘Advanced’

Step 5 – Enter the User name – if connecting to a standard EC2 instance using the Amazon Linux AMI the  user name will be  ec2-user, if it is a Bitnami WordPress instance it will be bitnami

Step 6 – Click on Advanced to add the private key file for authentication

Step 7 – Click on Authentication

How to Copy Files to an AWS EC2 Instance Using SFTP
How to Copy Files to an AWS EC2 Instance Using SFTP

Step 8 – In the Private key file field click to browse for the .ppk private key file for the instance you created from the .pem file provided by AWS and click ‘OK’.

How to Copy Files to an AWS EC2 Instance Using SFTP
How to Copy Files to an AWS EC2 Instance Using SFTP

Step 9 – Save the session by clicking on ‘Save’ under the User Name – at this point you can name the session so you don’t have to upload the key next time you want to connect to the instance.

Step 10 – Click on ‘Login’ on the Login dialog, and the program will connect to the instance. You should see the directory tree.

Troubleshooting

If you have any problems, check:

  • The host name is correct
  • The user is correct
  • The private key file (.ppk) is correct for the instance – check the AWS key pair used

 

How to Connect to an Amazon Web Services (AWS) EC2 Instance Using SSH

This tutorial shows you how to connect to your AWS EC2 instance from a Windows 10 computer using SSH.

Prerequisites

  1. Download PuTTY a SSH and Telnet client for Windows
  2. Ensure you have your .pem file which you will have downloaded when you set up your key pair when creating your EC2 instance
  3. Create a .ppk file from a .pem file – see How to Create a PPK file from a PEM file – Windows 10
  4. Make a note of your instance’s public IP address

Connecting to the Instance

Step 1 – Open PuTTY, you will see a PuTTY Configuration window.


How to Connect to an Amazon Web Services (AWS) EC2 Instance Using SSH
PuTTY Configuration window

Step 2 – In the Host Name (or IP address) field enter the public IP address of your EC2 instance. Leave the port number at 22.

You can also enter the username to save time using ec2-user@ and then the IP address to save entering the username when logging in.



How to Connect to an Amazon Web Services (AWS) EC2 Instance Using SSH
Enter the username and public IP address of the instance

Step 3 – Click on the ‘+’ sign next to SSH to open the list of options.

How to Connect to an Amazon Web Services (AWS) EC2 Instance Using SSH
Click on ‘+’ next to SSH

Step 4 – Click on ‘Auth’.

How to Connect to an Amazon Web Services (AWS) EC2 Instance Using SSH
Click on ‘Auth’

Step 5 – Click on ‘Browse’ and select the .ppk private key file you created from the .pem file using PuTTYgen.

How to Connect to an Amazon Web Services (AWS) EC2 Instance Using SSH
Upload the .ppk file

Step 6 – Enter a name for the session in the ‘Saved Sessions’ field to save the settings entered above for quicker access next time you want to SSH into the same instance.

How to Connect to an Amazon Web Services (AWS) EC2 Instance Using SSH
Click on Session, enter a name and save

Step 7 – Click ‘Open’ and the terminal window should open

How to add a SSL Certificate to an AWS Lightsail Bitnami WordPress Site

Now you’ve created your new Bitnami WordPress site using AWS Lightsail the first thing you will see when viewing it in Google Chrome is a ‘Not secure’ warning message next to the URL – a sure-fire way of scaring your visitors away!

Here’s a step-by-step guide to fixing the problem:

Step 1 – Purchase a SSL Certificate

AWS offer free certificates but you need to use their CloudFront Content Delivery Network and a pricey Elastic Load Balancer.  It’s also quite complicated to set up. If your site is new and hasn’t much traffic then the only option is to buy a certificate from a Certificate Authority.  Try GoDaddy.com or 1&1.co.uk.



Step 2 – Once you have purchased a certificate, your provider will need a CSR (Certificate Signing Request) before you can download the certificate. This is to link the certificate to your domain name and server.

To do this, you need to SSH into your AWS instance using the ‘Connect using SSH’ button in the instance console in Lightsail.

A window will open and you should see the Bitnami terminal or Command Line Interface (CLI) with the cursor next to a bitnami@ip-xxx-xx-x-xxx:~ $ prompt.

How to add a SSL Certificate to an AWS Lightsail Bitnami WordPress Site
Click the ‘Connect using SSH’ button

Step 3 – Create a CSR and follow the instructions on your certificate supplier’s website on copying and pasting it into your certificate application form – see How to Create a CSR.

Step 4 – You will now need to verify your site by either uploading a file or adding a TXT record to your DNS settings.  Again, your certificate supplier will have instructions on what to do.

Step 5 – When the site’s verified,  follow the instructions to download the certificate from the certificate supplier’s website to your computer.

Step 6 – Install the certificate and bundle to the server

Step 7 – Change the conf file

Step 8 – Restart apache

Step 9 – Check everything is working – close the browser and type the url using https:

Step 10 – Do a mod rewrite to redirect http traffic to https

How to Create a WordPress Blog using AWS Lightsail

In the old days creating a WordPress blog site involved setting up a LAMP server, downloading the latest version of WordPress from WordPress.org and installing the software.  Today, creating a new WordPress site is a breeze with Amazon Web Services (AWS) Lightsail.

Step 1 – visit AWS Lightsail

Step 2 – Click on ‘Get started for free’

How to set up a WordPress Blog using AWS Lightsail
Click on ‘Get started for free’

Step 3 – Create a new AWS account or sign in if you have one already

How to set up a WordPress Blog using AWS Lightsail
Create a new account or sign in

Step 4 – Click on Create Instance

How to set up a WordPress Blog using AWS Lightsail
Click on ‘Create instance’

Step 5 – Choose an instance location – US, UK or in any of the other AWS regions

Step 6 – Choose Linux/Unix platform

Step 7 – Select the ‘WordPress’ Blueprint

How to set up a WordPress Blog using AWS Lightsail
Select a location, select the Linux platform and the WordPress blueprint

Step 8 – Select a plan – you can start with a small server and scale up when traffic to your new WordPress site increases.

Step 9 – Name your instance

Step 10 – Click ‘Create’

How to set up a WordPress Blog using AWS Lightsail
Select a plan, name your instance and click ‘Create’

Step 11 – Wait for the instance to create

How to set up a WordPress Blog using AWS Lightsail
Wait for the instance to create

Step 12 – When the  instance is running you will see a public IP address. Enter the IP address in a browser and your new WordPress site will appear

How to set up a WordPress Blog using AWS Lightsail
Site is running with a public IP address

Step 13 – View your site and follow the instructions to get access to the site back-end

How to set up a WordPress Blog using AWS Lightsail
Click on the ‘Bitnami’ logo to view the instructions to get access to the site admin area

 

Related Articles

How to add a SSL Certificate to an AWS Lightsail Bitnami WordPress Site