- This article explains how to setup your Amazon Web Services (AWS) environment so you can run a sample application that showcases the usage of AWS Simple Storage Service (S3), directly from your web application’s client-side (browser) code.
What is Amazon S3?
Amazon S3 is a cloud-based file storage service from Amazon.
Why would I want to use S3 in my web application?
S3 is very affordable, fast, and reliable. Since S3 is just like a file-system on your computer, it can store any text/binary data, including photos and documents. Photos & documents would be a prime candidate for S3 as they are simple binary data, they can be large, and they can be transferred directly to S3 without needing to interact with your server-side programs.
You’d need to install the Integration Library package using the LANSA Package Manager.
See this usage guide for how to use the LANSA Package Manager.
Running the Sample Application
Once you have installed the Integration Library package, go to the Installed Packages section, and then the Samples tab.
Run the Amazon Simple Storage Services (S3) – Browser Direct Upload & Download sample application.
Signing Up with AWS
Unless you have an account already with AWS, you’d need to sign up for a new account. You’d need to provide a credit card, however you also get 12 months of free tier access. Just make sure that you only use services that are included in the free tier.
Go to https://aws.amazon.com/free for full offer terms.
To sign in or sign up, go to https://aws.amazon.com.
Understanding AWS Root User
When you created your AWS account, you begin with a single sign-in identity that has complete access to all AWS resources in the account, including billing. This identity is called the AWS account root user and is accessed by signing into the AWS Console, with the email address and password that you used to create the account.
Since the root user has unlimited access to your account, it’s best to create a set of secondary accounts that have just the minimum required permissions to
do their job. These non-root users are created via the Identity and Access Management service of AWS, so they are
called IAM users.
At a a minimum, you should create an IAM user that functions as an administrator.
You may want to create other IAM users for different purposes, for example for access via the AWS Command Line Interface (CLI).
You want also want to create another IAM user that you would use to programmatically access the S3 service from your programs.
Have a look at this AWS guide for more information.
Creating a New Administrator IAM User
Have a look at this AWS guide
Understanding LANSA Cloud Middleware
In order to use some AWS services, such as direct transfer of files between AWS S3 (Simple Storage Service) and the browser,
you’d need to deploy the LANSA Cloud Middleware to AWS. They will be installed as AWS Lambda (serverless).
The LANSA Cloud Middleware is basically a set of helper services that facilitates the use of
AWS services from your LANSA RDML programs.
Note that LANSA Cloud Middleware is provided as-is and free-of-charge.
LANSA does not provide any form of support for the LANSA Cloud Middleware. Any questions and comments about the LANSA Cloud Middleware
should go to the Visual LANSA Forum.
Installing the AWS CLI (Command Line Interface)
You’d need the AWS CLI to deploy the LANSA Cloud Middleware to AWS.
Download the CLI from here:
Creating New IAM User for API Invocation
You’d need to create 2 set of users and access keys:
- For use with the command line interface (CLI)
- For API invocation from your RDML code
To keep things simple in this guide, you can reuse the same IAM administrator user you created earlier with CLI use,
so you’d just need to create a new user for AWS API invocation from your RDML code.
In a real environment however, we’d recommend that you create a separate user for CLI use.
To minimise security risk, remember to always assign the minimum required permission to the users.
We’ll now create a new API user.
Go to the AWS Management Console.
Search for IAM in the search box:
In the first screen, enter the user id (e.g. api-user), and tick the
Programmatic access checkbox.
Click the Next button.
In this screen, you will add a permission to the user. There are a couple of ways to add permission,
one of the easiest is to attach one (or more) built-in policy to the user.
In this guide, we need the user to be able to access the Simple Storage Services (S3), so we
will add the S3 Full Access policy to the user.
Click the Next: Tags button to go to the next screen (Tags).
We are not going to add any tags so click on the Next: Review button.
Click on the Create User button. You have successfully added a new user.
Make sure that you download the CSV or save the secret access key as you won’t be able to view the secret access key associated with this key ID after this.
You can however create a new pair of key ID and secret access key easily, so it’s not a big problem if you lose your keys.
Creating Access Key for Your CLI User
Since we are using the same IAM user we use to administer via the console, we need to create an access key so we can use that same user from the CLI.
Go to the IAM, click on Users, and then
click on the user you want to use.
Go to the Security credentials tab
Click on the Create access key button.
Download the CSV file containing the new access key, or copy and paste the secret key into a text file.
Setup Your CLI with the New Access Key
You still need to configure your CLI as it needs to know the credentials (access key) to use when communicating with AWS.
On the command prompt, type in the following command:
> aws configure
Enter the following information:
- Access key ID
Enter the access key ID you obtained in the earlier step.
- Secret access key
Enter the secret access key you obtained in the earlier step.
- Default region name
Enter a region you’d use the most. If unsure, just enter us-east-1
- Default output format
Your CLI is now ready to use.
Creating an S3 Bucket for LANSA Cloud Middleware Deployment
Deployment requires an S3 bucket where AWS can temporarily put the ZIP file containing the files to be deployed.
You can delete the files in this bucket after deployment is finished.
First, go to the AWS Management Console.
Type in S3 in the search box.
Enter bucket name (e.g. deploy-bucket) and region.
Bucket name must be unique across the whole AWS, so use your company name as a prefix or suffix.
Just click on the Next button on this screen.
This screen is where set the public access permission for the objects created in this bucket.
Unless you want to allow public access, make sure you tick the Block all public access checkbox.
You are now on the last screen (review). Click on the Create bucket button.
You now have succesfully created a new S3 bucket.
Deploying the LANSA Cloud Middleware to AWS
Now that you have your CLI setup with the right credentials, you can deploy
the LANSA Cloud Middleware to AWS.
Open PowerShell, and change the current directory to where you downloaded the ZIP file.
Run the following command to unzip:
Expand-Archive -Path lansa-cloud-middleware.zip -DestinationPath lansa-cloud-middleware
Change the current directory into
./lansa-cloud-middleware/deploy-aws, by running the following command:
Run the deploy.ps1 script:
Configuring Your LANSA Runtime Environment with Your AWS Access Keys and Cloud Middleware URL
Open the Integration Services Configuration application and navigate to API Providers >> Amazon Web Services
If the app does not open, you may not have it installed.
Use the LANSA Package Manager to install the Integration Services package.
Once installed, you can also launch the Integration Services Configuration application from the LANSA Package Manager.
Once you have the package installed, go to the Installed Package tab (at the top-left),
then choose the Tools sub-tab.
You will see the Configure Integration Services application listed there.
You should now see the configuration app.
Expand the Providers API menu, then click on Amazon Web Services.
You will be presented with the AWS API configuration screen.
Fill up the access key details, default region,
and the Cloud Middleware URL you obtained from the earlier step
(deployment to AWS using
deploy.ps1 PowerShell script).
You are ready to run the example!
You should now be able to run the S3 Simple Upload/Download Example,
either from the LANSA Package Manager,
or directly from the IDE. If you are running from the IDE, the entry point
webpage is xDemoAwsS3SimpleUploadDownload (