Relational Database - 913-RichardOrr/caliber-backend GitHub Wiki
For this application, we used AWS's RDS using PostgreSQL.
[insert ERD here]
aws cloudformation deploy --template-file rds.yaml --stack-name <stackName> --role-arn <roleARN> --parameter-overrides DBUsername=<someUsername> DBPassword=<somePassword>
- This deploys the CloudFormation template based off the name given. If you're setting up the database we have created in this project, it will be the rds.yaml file
- You also need to name the stack.
- The Role-ARN may not be necessary depending on the permissions required.
- The parameter overrides give the username and password a specific value so that you can connect to the database in other resources such as DBeaver.
aws cloudformation describe-stack-events --stack-name <stackName>
- This describes the stack events to ensure that the stack was created. If there was an error, it will tell you, but you will not know what the exact error was until you run this command. It is usually a permissions error or a template error.
- This stack name must be the same that you use in Step 1.
- (Optional)
aws cloudformation delete-stack <stackName>
- If you had an error in Step 1, then this will delete the stack. You need to delete the stack because if there is an error, it will stay in RollbackComplete state until you delete it so that you can run the command in Step 2.
- must be the same name that you use in Step 1.
Note: You will need to repeat Steps 1-3 until the console outputs Successfully created/updates stack - <stackName>. This statement means that the stack was successfully created and there were no errors creating the resources.
aws rds describe-db-instances --db-instance-identifier calibermobile
- This describes the database instance that was created in the template file. In the rds.yaml file that we're using, we have defined the DBInstanceID (aka the DBInstanceIdentifier) to be calibermobile.
- Under Endpoint, it gives you an address that you can use as the host endpoint that you can use to connect to the database using outside tools (DBeaver for example like mentioned above).
- The RDS instance is setup and you can use the endpoint from Step 4 and the Username and Password you defined in Step 1 to connect to the database.
We used DBeaver to connect to the database and set up the tables that way. There is a setup script that you can run after connecting to the database in DBeaver.