Example EC2 Startup Script

  • This was the final EC2 startup script from last class
  • Installs Java, a JAR file, a data file, and a monitoring agent
#!/bin/bash
cd /home/ec2-user
sudo yum install -y java-17-amazon-corretto
aws s3 cp s3://my-pocket/data.jar .
aws s3 cp s3://my-pocket/real-estate-data.csv .
aws s3 cp s3://my-pocket/newrelic.yml .
aws s3 cp s3://my-pocket/newrelic-agent.jar .
curl -Ls https://download.newrelic.com/install/newrelic-cli/scripts/install.sh | bash \
  && sudo NEW_RELIC_API_KEY=FAKE_KEY NEW_RELIC_ACCOUNT_ID=12345 /usr/local/bin/newrelic install

6 / 24