Connect to the Source-Java-Webserver where your Java application runs.
You have multiple options to connect your Web Server. Check this article for more detail on how to connect to your Linux instance.
You can connect to your Web server via using AWS Systems Manager - Session Manager. Session Manager provides secure and auditable instance management without the need to open inbound ports, maintain bastion hosts, or manage SSH keys.
Go to your Amazon EC2 instances, select your Java Web Server and Click “Connect”.
Choose “Session Manager” and click “Connect”
If you prefer to SSH into the webserver, you would need the following details.
a. Public DNS Name of the webserver
b. Username configured in the webserver
You can find this information in the output section of the cloudformation stack. The stack can be accessed by navigating to the CloudFormation console.
|SSHKey||SSHKeyURL (You need to create .pem file from this key)|
|Public DNS Name||JavaWebServerDNSName|
For SSH key, you need to create a .pem file via copying the key from the URL to your text editor and save it as .pem file.
In the webserver, we need to create a profile for the AWS CLI which App2Container can use. In this lab we setup the default profile by running ‘aws configure’.
You will use the credentials for app2container user details you’ve created in the prerequisite step.
AWS Access Key ID [None]: <<add AWS access key from previous steps>> AWS Secret Access Key [None]: <<add AWS secret access key from previous steps>> Default region name [None]: us-west-2 Default output format [None]: [blank]
Running App2Container commands on a Linux server requires elevated permissions. Check if you running as root or use “sudo su” when you log-in to server, or prefix “sudo” for each command.
Download and install App2Container for Linux
curl -o AWSApp2Container-installer-linux.tar.gz https://app2container-release-us-east-1.s3.us-east-1.amazonaws.com/latest/linux/AWSApp2Container-installer-linux.tar.gz
Extract the package to a local folder on the server and navigate to that folder.
tar xvf AWSApp2Container-installer-linux.tar.gz
Run the install script from the folder where you extracted it and follow the prompts
(optional) Familiarize yourself with the available command for App2Container
The init command performs one-time initialization tasks for App2Container. This interactive command prompts for the information required to set up the local App2Container environment.
First, You will need to create an Amazon S3 bucket where App2Container can store artifacts during the containerization process.
Login back to Source Web server and initiliaze app2container with “app2container init” command.
You are prompted to provide the following information:
|Workspace directory path||Leave Default. (A local directory where App2Container can store artifacts during the containerization process. The default is /root/app2container.)|
|Use AWS EC2 Instance profile||Leave Default. (You can choose to use EC2 instance profile to run App2Container operations.)|
|AWS profile||Leave Default. (Contains information needed to run App2Container, such as your AWS access keys.)|
|Amazon S3 bucket||Enter the Amazon S3 bucket name (app2container-Your-Initials-Date) you have created in previous step. (e.g. app2container-sd-jan-29)|
|Permission to collect usage metrics||Leave Default. (this option is to allow App2Container to collect information about the host operating system, application type, and the app2container commands that you run.)|
|Permission to Automatically upload logs and App2Container generated artifacts on crashes and internal errors||Leave Default. (this option is to allow App2Container to upload logs and artifacts on crashes and internal errors)|
|Whether to enforce signed images||Leave Default. (You can optionally require that images are signed using Docket Content Trust (DCT))|
Make sure to enter the correct Amazon S3 bucket name (app2container-Your-Initials-Date) you’ve created in previous step once prompted. See example output below.
Workspace directory path for artifacts[default: /root/app2container]: Use AWS EC2 Instance profile 'arn:aws:iam::-:instance-profile/App2ContainerWorkshop-EC2InstanceProfile-' configured with this instance? (Y/N)[default: n] AWS Profile (configured using 'aws configure --profile')[default: default]: Optional S3 bucket for application artifacts: app2container-sd-jan-29 Report usage metrics to AWS? (Y/N)[default: y]: Automatically upload logs and App2Container generated artifacts on crashes and internal errors? (Y/N)[default: y]: Require images to be signed using Docker Content Trust (DCT)? (Y/N)[default: n]:
Congratulations! You have installed and initialized App2Container and you are now ready to start containerizing your Java Application.
In the next modules, you will containerize your Web Application and deploy it to AWS ECS with App2Container.