This source code refers to a blog article we've published as part of the AWS Open Source Blog:
UPDATE: As Spring Cloud AWS is no longer part of the Spring Cloud release train, the sample application has been migrated to the successor awspring. Read more about the rationale behind this move here.
- Make sure you have the AWS CLI installed and configured a
stratospheric
profile with the correct credentials and AWS region e.g.:
Content of ~/.aws/config
:
[default]
region = eu-central-1
[profile stratospheric]
region = eu-central-1
Content of ~/.aws/credentials
:
[default]
aws_access_key_id=DEFAULT_KEY
aws_secret_access_key=DEFAULT_SECRET
[stratospheric]
aws_access_key_id=XYZ
aws_secret_access_key=XYZ
- Ensure you have JDK 17 installed:
java -version
- Create the required infrastructure for the application (make sure to replace
your-unique-bucket-name
with a globally unique name):
cd cloudformation
./create.sh your-unique-bucket-name
Please note that for demonstration purposes the S3 Bucket and its content is publicly accessible. Remove it afterwards.
- Create at least the following two parameters using the AWS Parameter Store (inside SSM):
/config/stratospheric-demo/custom.bucket-name -> the S3 bucket name you passed to ./create.sh
/config/stratospheric-demo/custom.sqs-queue-name -> stratospheric-demo-queue
The parameter values can be either String
or SecureString
- Start the application on your local machine:
./gradlew bootRun
- Upload the demo images to your S3 bucket (make sure to replace
your-unique-bucket-name
)
aws s3api put-object --bucket your-unique-bucket-name --key stratospheric-book.pdf --body docs/stratospheric-book.pdf --acl public-read --profile stratospheric
aws s3api put-object --bucket your-unique-bucket-name --key stratospheric-book-cover.jpg --body docs/stratospheric-book-cover.jpg --acl public-read --profile stratospheric
aws s3api put-object --bucket your-unique-bucket-name --key stratospheric-book-cover-mockup.jpg --body docs/stratospheric-book-cover-mockup.jpg --acl public-read --profile stratospheric
- Visit http://localhost:8080/ to open the file viewer. In addition to this, you should see incoming log messages from the SQS listener.
- (Optional) Build and run the application inside a Docker Container
./gradlew assemble
docker build -t statospheric-demo .
docker run -p 8080:8080 -e AWS_REGION=eu-central-1 -e AWS_ACCESS_KEY_ID=XYZ -e AWS_SECRET_KEY=SECRET stratospheric-demo
- Make sure to clean up all AWS resources afterwards. Empty all files within your S3 bucket and then delete the CloudFormation stack inside the AWS console.
- More information about the Stratospheric project
- Get the E-Book Stratospheric on Leanpub
- Spring Cloud AWS on GitHub
- Spring Cloud AWS documentation
- Maciej Walkowiak's Spring Academy YouTube channel with great content about Spring Cloud AWS