This article explores the process to stop an AWS RDS SQL Server using web console and AWS CLI.
AWS RDS provides managed database instances for SQL Server, Oracle, MySQL, MariaDB and PostgreSQL. You can easily create, configure and manage the AWS RDS SQL Server. You can refer to these useful articles related to AWS RDS SQL Server on SQLShack.
AWS provides a free-tier account to try the RDS instance for the development, testing purposes. It does not charge any minimum cost for you and uses pay as you model. It means that if your instance is running 24*7, you pay a higher cost. You can manage the RDS SQL cost by stopping the instance while you are not using it. You should always plan the resource usage and estimated cost using the Amazon RDS Pricing calculators.
We get the following benefits in the free tier accounts for 12 months from the account registration date.
- AWS RDS SQL Server for single availability zone (AZ) service for 750 hours usage for SQL server express edition
- General-purpose SSD database storage – 20 GB
- You can also get 20 GB storage for database backups (snapshots)
Suppose you create an RDS SQL for the development or testing purpose. You stop instances once you complete learning about RDS. You do not regularly access the SQL instance so it should be in Stopped state. You did not use RDS for 10 days and once you log in again, you are surprised that RDS instance is in running status. You might be worried, right!
In this article, we will focus on stopping an AWS RDS SQL Server, costs associated with it and why it comes online automatically if you do not start it manually.
Stopping an AWS RDS SQL Server
You can quickly start or stop SQL instance in AWS using AWS web console or AWS CLI. In the following screenshot, we see that instance is in Available status.
In the RDS dashboard, select the instance and go to Actions.
Here, you get the following options.
- Stop: To stop the RDS instance
- Reboot: To restart RDS instance services
- Delete: if we want to remove the RDS database permanently, we can choose this option
- Take Snapshot: RDS automatically takes snapshots to recover data in case of any issues. You can use this option to take a manual snapshot
- Restore to point in time: We can restore RDS instance to a specific point in time to recover data
We want to stop the RDS SQL Server instance, so click on the Stop option, and you get the following wizard to stop DB instance.
We specify whether we want to create a snapshot before stopping AWS RDS SQL Server. You also get a piece of information that you can stop a DB instance for up to seven days. If you do not start it manually, AWS automatically starts an instance for you.
Let’s take a DB snapshot before stopping the instance. Once you click on Yes, specify a snapshot name. You should give an appropriate snapshot name to identify it quickly.
Specify a snapshot name and click on Yes, Stop Now. It starts stopping the RDS instance.
You can click on Snapshots in the RDS SQL dashboard, and it shows you available manual snapshots. We can see the snapshot that we specified while stopping the RDS instance.
It takes some time to stop AWS RDS SQL Server. You can refresh the RDS dashboard or web console, and it shows STOPPED status.
Once you stop RDS DB instance, AWS charges you only for the provisioned storage as well as for the backup storage. Backup storage includes automated backups and manual snapshots within the specified retention window.
STOP AWS RDS SQL Server instance using AWS CLI commands
We use the command-line interface (CLI) for working with the RDS services programmatically. It provides you flexibility in managing the resources without going through the AWS web console process such as login, manage AWS resources.
In the article, Learn AWS CLI: An Overview of AWS CLI (AWS Command Line Interface), we took an overview and installed it on the Windows OS. You should go through this article and set up a profile with your access key, secret key and AWS region in which your resources exist.
In my case, the RDS instance is already in the STOPPED state. Therefore, let’s first start it using CLI commands. To start an RDS instance, we use start-db-instance command and specify the instance identifier.
You can get the RDS identifier from the RDS dashboard as shown below.
We use the following command to start RDS instance SSASInRDS with CLI profile Production.
>aws rds start-db-instance –db-instance-identifier ssasinrds –profile production
If your RDS instance is in a different region, you cannot stop, start using CLI because it cannot find the DB instance. You get the error, as shown below.
You can either create a new profile with the correct region or modify the existing profile to point towards the appropriate region. You can get more information about the CLI profile using the article link listed above.
As shown below, my config file and RDS instance both showing the correct AWS region us-east-1.
Let’s execute this command using AWS CLI.
>aws rds start-db-instance –db-instance-identifier ssasinrds –profile production
It gives JSON output, and a few useful columns as shown below.
It gives information about DB instance, instance class, status, matter user name, endpoint, allocated storage, VPC, security group, BackupRetentionPeriod, PreferredBackupWindow, DBParameterGroups, AvailabilityZone, EngineVersion.
It starts the RDS instance, as shown below. It might take some time to change status from Starting to Available so that users can connect to the database.
Once an RDS instance is available, we can use stop-rds-instance CLI command to stop it.
>aws rds stop-db-instance –db-instance-identifier ssasinrds –profile production
This command also gives output similar to the start of RDS using CLI.
It follows the same process for stopping RDS and goes through Stopping to Stopped status.
Essential points to STOP AW RDS SQL Server
We can note the following points for stopping an AWS RDS SQL Server.
- You can stop RDS instance irrespective of the AWS regions, DB class, version
- DB instance should be configured in the Single Availability zone
- We cannot stop the RDS instance configured in a multi availability zone. RDS uses database mirroring or Always on for a stand by a copy of the DB instance for Multi-AZ. You can refer to Multi-AZ Configuration for AWS RDS SQL Server for Multi-AZ configuration
- We cannot stop RDS instance having a read replica configuration
- Once we click on stop RDS, it performs a normal shutdown and goes through Stopping to Stopped state
- AWS retains the storage volume attached to RDS along with their data while the instance is in the STOPPED state. It clears the data stored in the cache
- If you do not star RDS for seven days, AWS automatically starts it to perform required maintenance. If you do not need an available status, you can stop it again
- AWS retains RDS instance name, ID, Domain Name Server ( DNS), security group, option group
- AWS also retains the transaction log backups to provide a point-in-time restoration
- We cannot make any configuration changes while RDS is in STOPPED status
- We cannot remove the option group, parameter group associated with the RDS instance while it is in STOPPED status
- We can modify the option and parameter group, but its changes get applied immediately to RDS once we start the instance
- AWS always retains the RDS endpoint even instance is in Amazon Virtual Private Cloud or not. You should always use the endpoint to connect it with the SSMS or client applications. RDS IP might get changed depending upon the VPC
In this article, we explored AWS RDS SQL Server using both web console, and the CLI commands. You should always stop the RDS instance if it is not in use. You must note that AWS does not stop RDS for indefinite. It gets the auto start after seven days. We will cover the process to automate the stop and start RDS in the upcoming articles.
- Rebuild system databases for SQL Server on Linux and Windows - August 15, 2022
- Configure cross-platform SQL Server Always On Availability Groups - August 10, 2022
- SQLPackage utility to export Azure SQL Databases - August 1, 2022