AppML using Amazon Database
Amazon RDS is a database cloud service.
It is easy to set up and manage.
It is FREE to try!
What is Amazon Relational Database Service (RDS)
Amazon Relational Database Service (RDS) is a cloud based database service.
Why use Amazon RDS?
Amazon RDS manages many of the challenges of running a database.
With Amazon RDS you can scale performance and storage as you need it.
Amazon RDS manages automated backups, patching, and recovery.
It supports popular database products like:
- MySQL
- PostgreSQL
- Oracle
- Microsoft SQL Server
- and the new, MySQL-compatible Amazon Aurora DB engine
Getting Started
Before you can start using RDS, you need to sign up for Amazon Web Services, and set up a database user and security group.
Sign Up for Amazon Web Services
When you sign up for Amazon Web Services (AWS), your AWS account is automatically signed up for all services in AWS, including Amazon RDS.
If you are a new AWS customer, you can get started with Amazon RDS for free.
The AWS Free Tier is allows you to try AWS for free for 12 months after you sign up. For more information, see AWS Free Usage Tier.
If you decide to continue with AWS after your free period (or if you need more storage or performance than the free usage tier offers), you only pay for the resources you use.
To create an AWS account go to: https://aws.amazon.com/, and then click Sign Up.
Follow the on-screen instructions. Note your AWS account number, because you'll need it later.
Create a MySQL Database Instance
In this example we will set up a free Database instance running MySQL. (This is free because it is intended for testing).
Create a MySQL DB instance:
- Go to Amazon RDS console: https://console.aws.amazon.com/rds/
- In the navigation pane, click Instances.
- Click Launch DB Instance
- On the Select Engine page, click the MySQL icon and then click Select for the MySQL DB engine
- On the Production? page, click checkbox next to "No, this instance is intended for use outside of production.......", and then click Next Step
- On the Specify DB Details page follow the instructions (follow these
instructions for setting up a free test database)
For this option: Typical Input License Model general-public-license DB Engine Version Select the default version of MySQL DB Instance Class Select db.t2.micro to select a configuration that is eligible for free test usage Multi-AZ Deployment Select No Storage Type Magnetic (Standard) Allocated Storage 5 DB Instance Identifier Type the name of your database instance (this is not the name of your database) Master Username Type the master username for your database Master Password Type the password for your master user Confirm Password Conform the password - On the Configure Advanced Settings page follow the instructions (follow these
instructions for setting up a free test database)
For this option: Typical Input VPC Default VPC Subnet Group default Publicly Accessible Yes Availability Zone No Preference VPC Security Group(s) default Database Name Type the name of your database (in this example, we will show you how to create the northwind database we use for examples in the AppML tutorial) Database Port 3306 (unless you need it to run on a specific port) DB Parameter Group Keep the default value Option Group Keep the default value Enable Encryption No Backup Retention Period 7 Backup Window No Preference Auto Minor Version Upgrade Yes Maintenance Window No Preference - Click Launch DB Instance
- Click View Your DB Instances
- The new DB instance appears in the list of DB instances (it will have a "creating" status until it is ready for use)
- When the status changes to "available", you can connect to the database
- Click the details icon to view details and copy the URL from "Endpoint", including the port
The Endpoint URL should look something like this:
databasename.aaabbbcccddd.region.rds.amazonaws.com:3306
Configure Database Connection in AppML
To configure the database connection, edit the appml_config file:
PHP example: appml_config.php
<?php echo("Access Forbidden");exit();?>
{
"dateformat" :
"yyyy-mm-dd",
"databases" : [{
"connection" : "mydatabase",
"host" : "yourDatabaseURL",
"dbname" : "yourDatabaseName",
"username" : "yourUserName",
"password" : "yourPassword"
}]
}
Edit the following:
- mydatabase - change to whatever you want the database connection to be called in your application
- yourDatabaseURL - change to the endpoint URL from the previous step
- yourDatabaseName - change to the name you specified for your database in Amazon RDS
- yourUserName - change to the username you specified for your database in Amazon RDS
- yourPassword - change to the password you specified for your database in Amazon RDS
AppML should now be configured to connect to your Amazon RDS database.
You can now fill your database with data:
- If you have access to a PHP server, this is described in the AppML PHP chapter
- If you have access to an ASP.NET server, this is described in the AppML .NET chapter
Optional: Create an IAM User for increased security
Amazon RDS, require that you provide username and password when you access it.
You can access the account with your Amazon username, but for security purposes we recommend that you create an Identity and Access Management (IAM) user, for your database.
First, create the Administrators group:
- Sign in to the AWS Management Console and open the IAM console at https://console.aws.amazon.com/iam/
- In the menu, click Groups, then click Create New Group
- In the Group Name box, type Administrators and then click Next Step
- In the list of policies, select the check box next to the AdministratorAccess policy
- Click Next Step, then click Create Group
Then create the IAM user, and add it to the Administrators group:
- In the menu, click Users, then click Create New User
- In box 1, enter a user name
- Clear the check box next to "Generate an access key for each user", then click Create
- In the list of users, click the name (not the check box) of the user you just created
- In the Groups section, click Add User to Groups
- Select the check box next to the Administrators group, then click Add to Groups
- Scroll down to the Security Credentials section, and click Manage Password
- Select Assign a custom password, then enter a password in the Password and Confirm Password boxes, click Apply
To sign in as this new IAM user, sign out of the AWS console, then use the following URL:
Login with IAM
https://your_aws_account_id.signin.aws.amazon.com/console/
Replace your_aws_account_id with your AWS account number without the hyphens (if your account number is 1234-5678-9012, your AWS account ID is 123456789012)