AWS Logo
Menu
Q-Bits: Configuring Amazon RDS using AWS CloudFormation

Q-Bits: Configuring Amazon RDS using AWS CloudFormation

In this Q-Bits installment we will explore how Amazon Q Developer enhances productivity when deploying Amazon RDS database resources with AWS CloudFormation.

Kevin Tinn
Amazon Employee
Published Mar 20, 2025

Introduction

Welcome to another installment of Q-Bits, our regular series showcasing cool ways Amazon employees are leveraging Amazon Q Developer. In this Q-Bits installment we will dive into how Amazon Q Developer can assist with deploying and configuring Amazon Relational Database Service (RDS) resources using AWS CloudFormation. When tasked with creation and tuning of RDS resources using CloudFormation, I used to find myself deep in the docs looking up details of properties and finding example code. This process is time consuming, and generally a non-differentiating effort. This is where Amazon Q Developer really helps me by letting me spend less time on routine coding tasks, and more time creating unique experiences for my customers.

Amazon Q Usage Examples

Some examples of how Amazon Q Developer is helpful for this task are:
  • Generation of the initial CloudFormation Stack with RDS resources
  • Explaining aspects of RDS I want to understand better
  • Generation of CloudFormation code to demonstrate features such as RDS Parameter and Option Groups
  • Generation of automation to deploy this specific CloudFormation code using sensitive parameters

Create Initial CloudFormation Stack with RDS Resources

Amazon Q easily generates a great starting point for an RDS stack using a simple prompt to the Amazon Q /dev command explaining your requirements:
Prompt Amazon Q to Create Stack using /dev
Prompt Amazon Q to Create Stack
Amazon Q will analyze your prompt, and provide a suggestion to implement the request:
Amazon Q Implementation Suggestion
Amazon Q Implementation Suggestion
Accepting the suggestion will result in the code being created in a file named rds-stack.yaml:
RDS CloudFormation Code Generated by Amazon Q Developer
RDS CloudFormation Code Generated by Amazon Q Developer

Explain Aspects of RDS

Using Amazon Q Developer's chat interface is a great way to get to know RDS better. For example, I want to dive deep on what a multi-availability zone RDS deployment entails. Typically I would hit the docs, but since I am already in the IDE let me just check with Amazon Q first:
Ask Amazon Q about Multi-AZ Deployment
Ask Amazon Q about Multi-AZ Deployment
Amazon Q will analyze your prompt, and provide a detailed response:
Amazon Q Multi-AZ Response
Amazon Q Multi-AZ Response
Amazon Q will also provide sources and offer suggestions on what to research further:
Amazon Q Sources and Suggestions
Amazon Q Sources and Suggestions

Create CloudFormation Code to Demonstrate RDS Features

I want to incorporate RDS Parameter Groups and Option Groups into my stack (and largely understand those features), but would like to create an example of them in my CloudFormation Stack using the /dev command:
Ask Amazon Q to Create RDS Option And Parameter Group
Ask Amazon Q to Create RDS Option And Parameter Group
Amazon Q will provide a suggestion on how to add that to the code:
Amazon Q Suggestion and Code
Amazon Q Suggestion and Code

Generation of Automation to Deploy this Specific CloudFormation Code using Sensitive Parameters

Time to deploy the RDS stack. For now I just want to do initial testing of stack deployment from my IDE terminal. Additionally, I want to be smart about dealing with sensitive input such as an administrative password. I'll ask Amazon Q for an example of the AWS CLI command to use, and how to deal with sensitive parameters that should have the NoEcho option set (along with a comment explaining the NoEcho option):
Ask Amazon Q to Create Deployment Script with Sensitive Parameter
Ask Amazon Q to Create Deployment Script with Sensitive Parameter
Amazon Q adds the parameter to the stack and generates deployment script with parameter file:
Amazon Q Suggestion to Create Deployment Automation with Sensitive Parameters
Amazon Q Suggestion to Create Deployment Automation with Sensitive Parameters

Conclusion

That wraps up a some examples of using Amazon Q Developer to create and deploy Amazon RDS resources via an AWS CloudFormation Template. As an outcome Amazon Q has generated three new code files for us, getting us kick-started on our task of deploying and configuring an RDS Database with parameter/option groups and sensitive deployment parameters:
  • rds-stack.yaml: AWS CloudFormation Template containing our Amazon RDS stack resources
  • deploy-rds.sh: script to deploy the RDS stack
  • parameters.json: file containing parameter values for deployment of the RDS stack
I encourage you to take some time to test these features out yourself. Once you get the feel for working with Amazon Q, use it for other use cases outside of RDS and CloudFormation (such as setting up AWS Lambda functions in CDK or creating S3 buckets using Terraform). To get started with Amazon Q developer check out the Amazon Q Developer Guide.
 
Stay tuned for more Q-Bits articles where we'll explore other AWS services with Amazon Q Developer!

Resources

Stack Creation Prompt

Create a new cfn stack containing an RDS MariaDB database that resides in a VPC (VPC ID passed in as stack parameter). In the stack also create a DBSubnetGroup for the RDS database that uses two subnets that are provided as stack parameters. Also configure the RDS database to use a password that is in AWS Secrets Manager and is automatically rotated.

Multi-AZ Prompt

What does deploying RDS to multiple availability zones mean in terms of how and what underlying hardware is deployed?

Code Example Prompt

In rds-stack.yaml, add a parameter and option group to the existing RDS database demonstrating common usage of a parameter group and an option group. Also add a comment to the file explaining the difference between an RDS parameter group and an RDS option group.

Deployment Automation with Sensitive Parameter Prompt

Update rds-stack.yaml to take the database password as a parameter. Since it is a sensitive parameter mark it as noecho and add comment above the parameter explaining what noecho does. Also create a bash script that deploys the RDS stack, proving the input parameters for the stack from a file so that the password is not stored in terminal history.
 

Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.

Comments