This article will help get a developer set up to develop in Java 11 in their own AWS environment from scratch. Amazon Corretto is a no-cost, multiplatform, production-ready distribution of the Open Java Development Kit(OpenJDK). It is certified as compatible with the Java SE standard. This will allow you to develop in the AWS Cloud with the latest version of Java.
At Xerris, we help enable organizations and individuals to get up and running with AWS following similar offerings including AWS bootcamps educating people on best practices of AWS.
Objective: Get a developer set up with an AWS Account, Java JDK 11 with Amazon Corretto, Eclipse and AWS Explorer to be ready for AWS Development with Java 11 Corretto.
- Setting up your AWS Account
You will need an AWS Account to deploy code and take advantage of the many AWS Services. To create and activate a new AWS Account https://aws.amazon.com/ and choose “Create an AWS Account” . You will then be required to enter your email address, password, and your AWS Account Name. Proceed with the other required information. This will include the required Payment Information where you will enter credit/debit card information. You must also enter in your phone number to confirm your identity. If you are starting out, it is advisable to just select the Basic Plan or Free Tier. Part of the process will include activating your AWS account via a confirmation email. You now have access to 12 months Free Tier Access and opening the door to the AWS Platform.
2. Logging into the AWS Account and setting up MFA
With the AWS Account set up, you should be able to log into the AWS Console where you can view and configure your root account to be protected with Multi Factor Authentication(MFA) to prevent unauthorized access to your account.
a) You will need to install a Virtual MFA application on your phone such as Google Authenticator or Microsoft Authenticator.
b) Essentially, once you are in the console, you can configure the MFA access by clicking on your account name in the top right corner and select “My Security Credentials”, then you open up the Multi-factor authentication(MFA) section to set this up.
c) Once configured, you will be required to enter your MFA code as part of the login process. Which helps secure your AWS Account against unauthorized access.
Detailed instructions can be found at https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_mfa_enable_virtual.html#enable-virt-mfa-for-root
3) AWS Command Line Interface installation
The AWS Command Line is a unified tool to help manage your AWS services from the command line.
a) Install AWS CLI
b) Verify that you have installed it correctly by verifying the version that you have installed
Detailed instructions: https://aws.amazon.com/cli/
4) Create an IAM User
To run AWS configuration from your machine, you will need to have an IAM(Identity and Access Management) user configured.
a)Create an AWS IAM Group
Log into your AWS Console and go to the IAM Service (Select from the Services dropdown at the top left).
Click on User Groups and then “Create New Group”, set the Group Name to “admin”, find and select the “AdministratorAccess” policy so that users of this group(Your AWS CLI user) can use the AWS CLI to create and configure AWS Resources. When creating groups it is advised to consider the “least privilege” model for users by giving the least amount of privileges for a user to complete their duties.
Verify that you can see this new Group with administrator access when you press on the Users link on the left hand side
b)Create a User to use the newly created group.
Click on the users link, press “Add Users”, enter the user name (let’s say cliuser), select Programmatic access, press “Next: Permissions”, check the group that you created in (a), press “Next: Tags”, press “Next: Review”, press “Create User”
You will then see a success message and an option to download a .csv file which contains the Access key ID and the Secret access key. Download the csv file to a secure location on your machine and you can note the access key id and secret access key. These will be required to configure your AWS CLI
5) Configure AWS CLI
Open up a new command shell(cmd on Windows) now that you have installed AWS CLI and that you have an AWS User configured(along with the access key id and secret access key.
Type in the command “aws configure”
Enter the AWS Access Key ID
Enter the AWS Secret Access Key
Enter in the Default region name (For my case I have selected us-west-2)
Enter the Default output format : (Just hit return)
There are many AWS Regions to select from, generally you want a region to be a region close to you geographically.
Note that your AWS config is stored at ~/.aws/config or on your windows machine in the file located at C:\Users\”username”\.aws\config
Test out your AWS configuration with the following command(see screenshot):
aws iam list-groups-for-user --user-name cliuser
Note that it is a double hyphen before “user-name”. This will validate that your CLI is configured properly to your AWS Account.
6) Install Amazon Corretto (Java 11)
Now that we have have AWS CLI installed and configured we will now install Amazon Corretto so that we can https://aws.amazon.com/corretto/ to install
Install this for your machine.
I am using Windows, and this should be setup by default in C:\Program Files\Amazon Corretto
Then set your environment variables JAVA_HOME and PATH
Set JAVA_HOME to be C:\Program Files\Amazon Corretto\jdk16.0.2_7
Add your %JAVA_HOME%\bin variable to your current PATH variable
After this you should be able to see the “java -version” in your environment
7) Install the Eclipse IDE
And install the latest Eclipse version for yourself.
Select “Eclipse IDE for Enterprise Java Developers”
8)Install AWS Toolkit for Eclipse
Go to Help/Install new software
Enter https://aws.amazon.com/eclipse into the “Work with:” textbox
Select the first 3 options presented including “AWS Core Management Tools”
Click next and follow through to install them
9) A brief look at AWS Explorer in Eclipse
Once installed you should be able to launch the AWS Explorer within Eclipse. You should see it in Eclipse or under Window/Show View/Other../AWS Toolkit
The AWS Explorer should default to the AWS account that you configured on your machine.
One quick test is to create an S3 bucket in the AWS Explorer and then confirm its existence in the AWS Console.
Now you have set up your AWS Account, Java 11 (Amazon Corretto), Eclipse and AWS Toolkit, you are ready to develop in the AWS cloud with Java 11.
If you now want to build an AWS Serverless Application, please proceed to https://www.xerris.com/insights/creating-an-aws-serverless-java-11-application-with-cdk-lambda-s3-dynamodb-api-gateway/