-
Notifications
You must be signed in to change notification settings - Fork 134
Databases
Casey Lee edited this page Sep 25, 2018
·
7 revisions
A database can be created for each service and then referenced by the service. The service will have access to the following variables to use as environment variables:
- DatabaseName - Name of the database that was created
- DatabaseEndpointAddress - Address for the RDS endpoint
- DatabaseEndpointPort - Port for the RDS endpoint
- DatabaseMasterUsername - Username for the master account in RDS
- DatabaseMasterPassword - Password for the master account in RDS
---
service:
name: my-service
# Pass DB config as environment variables
environment:
SPRING_DATASOURCE_USERNAME: ${DatabaseMasterUsername}
SPRING_DATASOURCE_PASSWORD: ${DatabaseMasterPassword}
SPRING_DATASOURCE_URL: jdbc:mysql://${DatabaseEndpointAddress}:${DatabaseEndpointPort}/${DatabaseName}
# Define the database
database:
name: mydbname # Name of database to create on RDS instance
## The following configs are the defaults if no `environmentConfig` is defined
engine: mysql # RDS engine to use (default: aurora)
instanceClass: db.t2.medium # Instance class (default: db.t2.small)
iamAuthentication: true # Enable IAM authentication (default: false)
masterUsername: admin # RDS master username (default: admin)
allocatedStorage: 100 # Storage requirement (in GB) (default: none)
engineMode: serverless # RDS engine mode: provisioned or serverless (default: provisioned)
minSize: 2 # Minimum ACU for auto scaling (default: 2)
maxSize: 16 # Maximum ACU for auto scaling (default: 256)
autoPauseSeconds: 300 # Number of seconds after which DB is paused. Set to 0 to disable auto pause (default: 0)
kmsKey: arn:aws.... # The ARN of the KMS key to use for the database
# Configuration per environment, override any of the configs above
environmentConfig:
acceptance:
engineMode: serverless # RDS engine mode: provisioned or serverless (default: provisioned)
minSize: 2 # Minimum ACU for auto scaling (default: 2)
maxSize: 2 # Maximum ACU for auto scaling (default: 256)
autoPauseSeconds: 300 # Number of seconds after which DB is paused. Set to 0 to disable auto pause (default: 0)
production:
engineMode: provisioned # RDS engine mode: provisioned or serverless (default: provisioned)
minSize: 8 # Minimum ACU for auto scaling (default: 2)
maxSize: 64 # Maximum ACU for auto scaling (default: 256)
autoPauseSeconds: 0 # Number of seconds after which DB is paused. Set to 0 to disable auto pause (default: 0)
# List the databases
> mu db list
# Upsert the database
> mu db up <environment>
# Terminate the database
> mu db terminate <environment> [<service_name>]