To run the project it's needed to have the AWS CLI installed. Follow this guide to set it up.
The S3 Downloader application needs AWS credentials to access S3. Do not store your AWS keys in code or configuration files. Use one of the methods below.
- Sign in to the AWS Management Console with an account that has IAM permissions.
- Go to IAM → Users.
- Select an existing user or create a new one.
- Ensure the user has S3 access permissions (e.g., attach
AmazonS3FullAccessor a custom policy for your bucket). - Open the Security credentials tab.
- Under Access keys, click Create access key.
- Copy the Access Key ID and Secret Access Key.
Important: The secret key is shown only once. Save it securely.
- Set them as environment variables before running the app:
export AWS_ACCESS_KEY_ID=<YOUR_ACCESS_KEY>
export AWS_SECRET_ACCESS_KEY=<YOUR_SECRET_KEY>
export AWS_DEFAULT_REGION=eu-south-1The AWS SDK for Java (v2, which your project uses) automatically looks for credentials in this order:
-
Environment variables
export AWS_ACCESS_KEY_ID=your-access-key export AWS_SECRET_ACCESS_KEY=your-secret-key export AWS_DEFAULT_REGION=eu-south-1
You can set them on your system, in your Docker container, or in your CI/CD environment.
-
AWS credentials file
Usually located at:
~/.aws/credentials(Linux/Mac)
Example content:
[default] aws_access_key_id = YOUR_ACCESS_KEY aws_secret_access_key = YOUR_SECRET_KEY
-
Option A: Using aws configure
- Install the AWS CLI if not already installed.
- Run the command:
aws configure
- Enter your AWS Access Key ID, Secret Access Key, default region, and output format. Example:
AWS Access Key ID [None]: <YOUR_ACCESS_KEY> AWS Secret Access Key [None]: <YOUR_SECRET_KEY> Default region name [None]: eu-south-1 Default output format [None]: json
-
Option B: Using Environment Variables Set the following environment variables before starting the application:
export AWS_ACCESS_KEY_ID=<YOUR_ACCESS_KEY> export AWS_SECRET_ACCESS_KEY=<YOUR_SECRET_KEY> export AWS_DEFAULT_REGION=eu-south-1
./mvnw spring-boot:runmvn spring-boot:run -Dspring-boot.run.arguments="--aws.profile=backup-user"curl -X POST "http://localhost:8080/download?prefix=backup/2024/"If you have Postman installed, you can use the Postman Collection available in the project at: test/postman to invoke the endpoint