CL5: App using AWS Cloud9

Create a new AWS Cloud9 environment to be used as IDE

➡️ Setup a new AWS Cloud9 environment, as shown below.

➡️ Make sure to use Ubuntu as underlying OS.

Amazon Linux also works, but requires you to switch from Amazon Corretto to OpenJDK before continuing with the lab.

Node

(Optional) Build locally

Requires existing application, see here.

$ mvn package

(Optional) Test locally

Option A) Start application via mvn

See SAP documentation to learn more

$ mvn tomee:run -pl application

Option B) Start application via cf local (cf plugin)

See also [https://blogs.sap.com/2019/03/20/how-to-test-cloudfoundry-apps..outside-of-cloudfoundry/]()

Install CF for Cloud9 (https://github.com/cloudfoundry/cli#downloads)

Ubuntu

$ wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add -
$ echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list
$ sudo apt-get update
$ sudo apt-get install cf-cli

Amazon Linux

$ sudo wget -O /etc/yum.repos.d/cloudfoundry-cli.repo https://packages.cloudfoundry.org/fedora/cloudfoundry-cli.repo
$ sudo yum install cf-cli

Install cf local Plugin

$ cf install-plugin cflocal -r CF-Community

Create local.yml file (copy from manifest.yml, replace “sap-java-buildpack” by “java_buildpack”)

$ cf local stage <artifactId> -p "application/target/<artifactId>-application.war"
$ cf local run <artifactId> -p 8080

Live Preview

Terminal

$ curl http://localhost:8080/hello
$ curl http://localhost:8080/index.html

Node

Browser

Only works in Chrome or Firefox!

https://<cloud9-id>.vfs.cloud9.<region>.amazonaws.com/index.html

e.g. https://67a6b15ddaa13c329027bb1849e7df48.vfs.cloud9.us-east-1.amazonaws.com/index.html

Node

To troubleshooting Cloud9 preview see the AWS Cloud9 documentation