User Data Script to start a Spring Boot application on Amazon Linux ec2 boot
<p>I'm seeking some assistance particular to AWS and running scripts on an Amazon Linux ec2 instance boot. This is a custom AMI image but of the Amazon Linux machine, just with Java, Maven, Gradle installed.</p>

<p>The problem I'm currently having is that I want the ec2 instance that houses my Spring Boot application to automatically start a Tomcat server on port 8080 each boot/launch. Ideally this means that when I start the instance through AWS, the server is already running without me SSHing into the instance myself to run the commands. I believed that adding "User Data" to the instance settings would solve this but it seems that the script is not executing on launch. There are also no logs produced in the init.d file indicating that user data ever ran, or any files created when I piped the output to a txt file. I'd love some advice on how to approach this if anyone has had a similar experience.</p>

<p>The script I'm loading into my "User Data" is as text:</p>

<pre><code>#!/bin/bash
cd ~/java-service-tier
./gradlew clean build
java -jar build/libs/&lt;myApp&gt;.jar
</code></pre>

<p>where <code>&lt;myApp&gt;</code> is my app's jar file produced as a result of the build command.</p>

<p>My project uses a middle-layer Java service application in Spring Boot to interact with a MySQL database hosted on Amazon RDS. This is built with Gradle. There is then a web-tier layer that talks with the service layer to make its data requests and manipulates the front-end in Angular based off the service layer responses. The architecture setup is sound and not an issue, but I thought I'd give some background in case it was relevant. </p>