-
Install AWS CLI: Install the AWS Command Line Interface (CLI) on your local machine to interact with AWS services.
-
Configure AWS CLI: Run
aws configure
and provide your AWS Access Key ID, Secret Access Key, default region, and output format. -
EC2 Instance IAM Role: Create an IAM role for an EC2 instance to grant access to the S3 bucket for private access.
-
Using AWS CLI: Use the
aws s3 cp
command to upload files to an S3 bucket.aws s3 cp <local_file_path> s3://<bucket_name>/<destination_path>
-
Using AWS CLI: Use the
aws s3 cp
command to download files from an S3 bucket.aws s3 cp s3://<bucket_name>/<source_path> <local_destination_path>
-
Copy JAR File to EC2: Use SCP or AWS CLI to copy the Spring Boot application JAR file to your EC2 instance.
-
Run Application: SSH into your EC2 instance and run the Spring Boot application using the
java -jar
command.java -jar your-application.jar
-
Access Application: Access your application via the public IP address or DNS hostname of your EC2 instance, appending the port number if needed (e.g.,
http://example.com:8080
).
-
Identify Process ID (PID): Use
netstat
orlsof
to find the PID of the process running on the desired port.sudo netstat -tuln | grep <port_number> sudo lsof -i :<port_number>
-
Terminate Process: Once you have the PID, use the
kill
command to terminate the process.sudo kill <PID>
-
Verify Termination: Check if the process has been successfully terminated using
netstat
or by attempting to access the port.sudo netstat -tuln | grep <port_number>
Note: To ensure your application runs seamlessly in the background, execute the following command:
nohup java -jar your-application.jar --spring.profiles.active=your-yml-file-name
By following these steps, you can effectively manage S3, deploy Spring Boot applications to EC2, and terminate processes running on your EC2 instance. If you encounter any issues or have further questions, feel free to ask!