# Deploy an RDS Database via Terraform

In scenarios where the **MS-SQL Database** is decoupled from the Portal Application, it's recommended to run the database using the **AWS RDS** managed service for better scalability, availability, and management. The database must use an **MS-SQL engine**, which can be deployed in any of its supported versions.

There are multiple ways to deploy the MS-SQL database on AWS RDS, but to streamline the process, we provide an example of how to deploy it using **Terraform** in our Git repository. This example includes all the necessary configurations for setting up an RDS instance with MS-SQL, ensuring it integrates seamlessly with the WorkSpaces Manager environment.

{% embed url="<https://gitlab.com/nuvens-public/wsm-rds-sql>" %}

Once the database has been deployed —whether via **Terraform**, **CloudFormation**, or manually on an EC2 instance— you need to configure the database to allow connections from the **WorkSpaces Manager Appliance**. At a minimum, this configuration should include:

1. **Database Access**: Set up a username and password for the WSM Appliance to connect to the database.
2. **Security Group Configuration**: Ensure that the database's security group allows inbound traffic on **TCP/1433** (MS-SQL) from the IP address or VPC of the WSM Appliance.
3. **Secrets Manager**: Store the database credentials (username and password) in **AWS Secrets Manager** for secure access by the WSM Appliance.

By storing the credentials in **Secrets Manager**, the WSM Appliance can securely retrieve and use them during operations, reducing the need for hardcoded credentials and improving security.

The retrieval of credentials is done in real-time by calling the **AWS Secrets Manager API**, ensuring that no sensitive information is stored or cached elsewhere. This process enhances security, as the credentials are only accessed when needed and are not exposed in any configuration files or logs, reducing the risk of unauthorized access.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.nuvens.cloud/install/alternate-deployment-options/deploy-an-rds-database-via-terraform.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
