This repository is a fork of: 0x1DOCD00D/LogFileGenerator Please refer the original README.md for the functional details of this repository
Changes are made to make this repository deployable as a web application over AWS Beanstalk.
Clone and zip the repository with all contents in the root directory of the .zip file read more. Sample command to create a zip file:
zip ./LogGenerator.zip -r * .[^.]* -x ".git/*" "project/target/*" "target/*" ".idea"
Archive with default configuration for the source code has been provided in src/main/resources/LogGenerator.zip
This project can be build and run locally using:
sbt compile #builds the project
sbt run #run the projectRequirements: JDK >= 1.8, sbt >= 1.5
- The application requires an EFS volume to be created in the AWS account. It is in the root of this volume the application logs are written. User has to mention the id for this volume
.ebextensions/efs-mount.configoption_settings: aws:elasticbeanstalk:application:environment: FILE_SYSTEM_ID: 'fs-0xxxxxxxxx' # your volume id MOUNT_DIRECTORY: '/efs'
- Tweak the parameters in
src/main/resources/application.confto modify the runtime of the application and frequency of log messages. With the default configuration, this application generates logs for 30 minutes and generates next message with 1 second frequency. - The application runs few scripts over the EC2 instance before the code gets deployed. These scripts are to mount the EFS volume and install scala. These implicitly assume the underlying Linux instance to be Linux-based OS.
- Before we deploy our application, we create a storage where the LogGenerator will be writing the log files. This storage is an EFS (elastic file storage) volume. This volume can be mounted and accessed across multiple EC2 instances.
- Go to EFS console here and create an EFS with default settings.
- Go to EBS in AWS console here. Make sure that the EBS and EFS are in the same region.
- Create a Web app:
- Write an application name
- Choose Java platform with Corretto 8 platform branch
- Select upload your code and upload the
ziparchive of the source code - Click Configure more options
- Configure more options:
- Edit instances for any custom security rule needed. You might want to add inbound routes for
sshinto the efs or viewing logs for debugging. Toggle checkbox to enable IMDSv1. - Edit capacity to specify the number of instances. Edit the instance type to
t2.small. - Edit security to add your public/private key-pair.
- Edit instances for any custom security rule needed. You might want to add inbound routes for
- Deploy the zip using
Youtube video link
- Default
powershellcommand for archiving makes the archive incompatible with Beanstalk. Follow this to test if archiving has been done correctly here - If the application fails to deploy the failure logs can be fetched via ssh to the EC2 instance via AWS CLI. The logs are located at
/var/log/