Product Management Application is a secure application for managing user account and product info. A Web Application using Sprint Boot that meets Cloud-Native Web Application Requirements. It implemented RESTful APIs that return with proper HTTP status codes based on user stories. It is deployed by launching AMI using AWS Amazon Linux 2 via Packer. Setup autorun using Systemd, link: https://github.com/ZhengruiLu/AWS-Infra-Assistant-PM-Application
Submitted by: Zhengrui Lu
Time spent: 40 hours spent in total
The following required functionality is completed:
- RESTful API Endpoints To Be Implemented: https://app.swaggerhub.com/apis-docs/csye6225-webapp/cloud-native-webapp/spring2023-a5
- All API request/response payloads should be in JSON.
- All API calls to return with a proper HTTP status code.
- Users should be authenticated & authorized where applicable.
- The application is expected to automatically bootstrap the database at startup.
- Bootstrapping creates the schema, tables, indexes, sequences, etc. Or updates them if their definition has changed.
- Deployed Application by launching the AMI using Amazon Linux 2 via Packer.
- Setup autorun using Systemd.
- Used Terraform configuration file to create all AWS resources needed. See Repository: aws-infra
- Pull Request Raised Workflow.
- Add a GitHub Action workflow to run the application unit tests for each pull request raised.
- A pull request can only be merged if the workflow executes successfully.
- Pull Request Merged Workflow.
- Add another GitHub actions workflow and configure it to be triggered when a pull request is merged. This workflow should do the following:
- a. Run the unit test.
- b. Validate Packer Template
- c. Build Application Artifact(s)
- d. Build AMI
- i. Upgrade OS packages
- ii. Install dependencies (python, node.js, etc.)
- iii. Install application dependencies (pip install for Python)
- iv. Set up the application by copying the application artifacts and the configuration files.
- v. Configure the application to start automatically when VM is launched.
- e. Create a new Launch Template version with the latest AMI ID for the autoscaling group. The autoscaling group should be configured to use the latest version of the Launch Template.
- f. Issue command to the auto-scale group to do an instance refresh.
- Add another GitHub actions workflow and configure it to be triggered when a pull request is merged. This workflow should do the following:
Describe any challenges encountered while building the app.
- Learn how to use the Spring Boot Framework to build a project.
- How to add authenticated and authorized functionality.
- Differentiate between HTTP status codes, such as 401 and 403.
- Understand the functions and application methods of AWS related services.
- Framework: SpringBoot
- Database: MySQL/MariaDB
- Infrastructure as Code: Terraform, Packer
- Autorun: Systemd
- Cloud: AWS
- CI/CD: Github Action
- IDE: Intellij
- Test Endpoints: Postman
After clone the repository to local, open the directory ProductManager, find pom.xml, right click it and choose "Add it as a Maven project", then right click it again, choose "Maven" - "Reload Project".
Find the directory "resources", find the file application.yml. Find the database part, and fill in with your MySQL/MariaDB username and password.
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/usertestdb
username: add your username
password: add your password
Find the file ProductManagerApplication in ProductManager - src - main - java - com.csye6225.productmanager, Click run.
Authorization - Choose "Basic Auth" Username: same with created user's username - email Password: somepassword
Example:
GIF created with LiceCap.
Please change params according to your setting.
- URL http://localhost:8080/v1/product?name=book&description=test
- scheme http
- hostname localhost
- port 8080
- origin http://localhost:8080
- path /v1/product
- query ?name=book&description=test
- POST: http://localhost:8080/v1/product?name=book&description=test description&sku=XYZ12345&manufacturer=test manufacturer&quantity=1
- GET: http://localhost:8080/v1/product/1
- PUT: http://localhost:8080/v1/product/1?quantity=12
- PATCH: http://localhost:8080/v1/product/1?quantity=10
- DELETE: http://localhost:8080/v1/product/1
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
