This tutorial will talk about how to provision a relational database with SQL file imported, and bootstrap an application which depends on the database.
Favorite Links is an interesting project which can store all
your favorite web links in one application. It is using Node.js and MySQL. It has been built into a container image
oamdev/nodejs-mysql-links:v0.0.1. Let's bootstrap the application and see how to provision a database, and import a SQL
file (which means to create tables, and insert data into them if needed).
Currently, it only works on Alibaba Cloud ComponentDefinition alibaba-rds-preview is the feature preview for Alibaba Cloud RDS, and will be merged into alibaba-rds later.
Feel free to skip this section if you are not interested.
Alibaba Cloud RDS Preview supports importing SQL file when create an RDS instance with these properties:
|sql_file||The name of SQL file in the bucket, like ||string||false|
|sql_bucket_name||The bucket name of the SQL file. like ||string||false|
|sql_bucket_endpoint||The endpoint of the bucket. like ||string||false|
After an RDS database is created, the SQL file from OSS bucket will be imported into the database by the power of Terraform
which is referenced by Alibaba Cloud RDS Preview ComponentDefinition.
Let's say we have an OSS bucket
oss://favorite-links which contains a SQL file
db.sql in it, and the bucket endpoint
Use the following Application to provision a database
links, import the SQL file
db.sql, and bootstrap the application
After the application is successfully deployed, you can access the web application by the following URL: