Secure RDS SQL Server: KMS, TLS, security groups
-
Phase 0: Before you start
-
Phase 1: The foundation
-
Phase 2: Operations and security
-
Phase 3: SQL Server on AWS
-
Phase 4: Troubleshooting step by step
-
Phase 5: Final project and career
Databases hold the data attackers want most. RDS SQL Server security works in layers: who can reach port 1433, whether each connection is encrypted, what each login is allowed to do, and whether the disks and backups are encrypted. If you skip a layer, the remaining ones end up carrying more weight than they should.
You’ll confirm encryption at rest and the server certificate, force TLS on all connections with rds.force_ssl, create a least-privilege login for applications and review the network rule protecting saat-sql. After that you’ll fix a weak password SQL Server won’t accept, and a security group change that locks everyone out.
| Time | You need | By the end you can |
|---|---|---|
| 50 minutes (including one reboot of saat-sql) | You need Lessons 42 and 43 finished (saat-sql, Start-SqlLab.ps1, Stop-SqlLab.ps1) and your laptop signed in as saat-admin. The session costs about USD 0.20. | You’ll check KMS encryption and the RDS certificate authority, enforce TLS with a static parameter and a planned reboot, confirm the session is encrypted, create least-privilege SQL logins, and sort out password policy and security group problems. |
What it is, in one line
RDS SQL Server security is the combination of network rules, encryption in transit and at rest, and least-privilege logins that keeps your database and its data private.
In Simple Words
A bank with guards, armoured vans and limited keys
A bank never trusts a single lock. A guard at the gate checks who’s allowed in (security groups), money moves between branches only in armoured vans (TLS), and the vault stays locked even if someone gets inside (encryption at rest). Staff only get the keys they need, so a cashier can open the cash drawer but not the vault, which is what a least-privilege login is.
If the guard turns everyone away, staff included, the bank is safe but no use to anyone that day. Security rules need to be exact, and being tight isn’t enough on its own.
Engineer's View
How each layer works on RDS for SQL Server
Encryption at rest uses a KMS key for storage, automated backups, snapshots and read replicas. You choose it when you create the instance, and changing it later means copying a snapshot with a new key and restoring from that. If you need encryption at the database level, Transparent Data Encryption (TDE) is also available through an option group on Standard and Enterprise editions.
Encryption in transit: each RDS SQL Server has a server certificate signed by an RDS certificate authority such as rds-ca-rsa2048-g1. Set the static parameter rds.force_ssl to 1, reboot, and the server refuses unencrypted connections. Clients that validate the certificate need the RDS CA bundle in their trust store, and CA rotations come round regularly with deadlines attached.
Logins: by default SQL logins follow the Windows password policy (complexity and length), and you can’t set a custom password policy. Give each app its own login with database roles like db_datareader and db_datawriter, and keep it off the master user. Network: the instance’s security group should allow 1433 from the app and admin security groups and nothing else.
Management changes and failed logins show up in CloudTrail and the exported error log.
How it works, step by step
Here are the four layers, working from the outside in:
1Network decides who can knock
saat-db-sg allows 1433 only from saat-app-sg, and your laptop gets in through sqljump, which sits in that group.
2TLS protects what travels
With TLS forced, a client that won’t encrypt gets refused when it connects, before it even tries a login.
3Logins limit what’s possible
The app login can read and write rows and do nothing else. Forcing TLS needs a planned restart:
4Encryption at rest covers the rest
Storage, backups and snapshots are encrypted with KMS, so someone who copies a snapshot can’t use it without the key (Lesson 30).
✅ Checkpoint: You can describe the four layers and explain why rds.force_ssl needs a reboot and why apps get their own login.
Hands-on lab: RDS SQL Server security in four layers
Before you run any command, double-check it
Read every command twice before you press Enter. Check the target: the system or account, the IDs, the names and the sizes. These commands are for learning and were tested in our lab, not on your system. At work, run the read-only list commands first, follow your change process, make sure a backup exists, and ask a second person to check anything that changes or deletes data. You run them at your own risk.
Sign in and start the SQL lab:
cd C:\aws-lab
aws login --profile saat-admin
$env:AWS_PROFILE = 'saat-admin'
$v = Get-Content C:\aws-lab\saat-vpc.json | ConvertFrom-Json
.\Start-SqlLab.ps11Check encryption at rest and the certificate
Paste this whole block:
aws rds describe-db-instances --db-instance-identifier saat-sql --query "DBInstances[0].[StorageEncrypted,CACertificateIdentifier,CertificateDetails.ValidTill]" --output text
aws rds describe-db-instances --db-instance-identifier saat-sql --query "DBInstances[0].KmsKeyId" --output text | ForEach-Object { aws kms describe-key --key-id $_ --query "KeyMetadata.[KeyManager,Description]" --output text }
aws rds describe-certificates --query "Certificates[?CertificateIdentifier=='rds-ca-rsa2048-g1'].[CertificateIdentifier,ValidTill,CustomerOverride]" --output textYou should see something like this:
True rds-ca-rsa2048-g1 2027-10-20T08:12:00+00:00
AWS Default key that protects my RDS database volumes when no other key is defined
rds-ca-rsa2048-g1 2061-05-25T23:34:57+00:00 FalseStorage uses the AWS managed key aws/rds. In production people often use a customer managed key instead, so snapshot access can be controlled and audited on its own. The server certificate expires in about a year and renews by itself, while the CA lasts much longer.
2Force TLS on every connection
Paste this whole block. The reboot takes a few minutes:
'[ { "ParameterName": "rds.force_ssl", "ParameterValue": "1", "ApplyMethod": "pending-reboot" } ]' | Set-Content force-ssl.json
aws rds modify-db-parameter-group --db-parameter-group-name saat-sqlserver-ex-16 --parameters file://force-ssl.json | Out-Null
Start-Sleep 20
aws rds describe-db-instances --db-instance-identifier saat-sql --query "DBInstances[0].DBParameterGroups[0].ParameterApplyStatus" --output text
aws rds reboot-db-instance --db-instance-identifier saat-sql --query "DBInstance.DBInstanceStatus" --output text
aws rds wait db-instance-available --db-instance-identifier saat-sql
aws rds describe-db-instances --db-instance-identifier saat-sql --query "DBInstances[0].DBParameterGroups[0].ParameterApplyStatus" --output text
sqlcmd -S "127.0.0.1,11433" -U saatadmin -C -N true -h -1 -Q "SET NOCOUNT ON; SELECT encrypt_option FROM sys.dm_exec_connections WHERE session_id = @@SPID"You should see something like this:
pending-reboot
rebooting
in-sync
TRUEThe tunnel window keeps working through the reboot because each new connection gets forwarded fresh, and from here on any client that doesn’t encrypt is refused. -C still trusts the certificate without checking it, since your laptop connects to 127.0.0.1 and not the RDS name. Apps inside the VPC should validate the certificate against the RDS CA bundle.
3Create a least-privilege app login
Paste this whole block:
$appPw = aws secretsmanager get-random-password --password-length 24 --exclude-punctuation --require-each-included-type --query RandomPassword --output text
sqlcmd -S "127.0.0.1,11433" -U saatadmin -C -Q "CREATE LOGIN saat_app WITH PASSWORD = '$appPw', DEFAULT_DATABASE = SaatShop"
sqlcmd -S "127.0.0.1,11433" -U saatadmin -C -d SaatShop -Q "CREATE USER saat_app FOR LOGIN saat_app; ALTER ROLE db_datareader ADD MEMBER saat_app; ALTER ROLE db_datawriter ADD MEMBER saat_app;"
$adminPw = $env:SQLCMDPASSWORD; $env:SQLCMDPASSWORD = $appPw
sqlcmd -S "127.0.0.1,11433" -U saat_app -C -d SaatShop -h -1 -Q "SET NOCOUNT ON; SELECT COUNT(*) FROM dbo.Orders"
sqlcmd -S "127.0.0.1,11433" -U saat_app -C -d SaatShop -Q "CREATE TABLE dbo.Hack (Id int)"
$env:SQLCMDPASSWORD = $adminPwYou should see something like this:
3
Msg 262, Level 14, State 1, Server EC2AMAZ-ABC123, Line 1
CREATE TABLE permission denied in database 'SaatShop'.The app login can read the three orders but can’t touch the schema, so if the app is ever compromised the attacker gets row access to one database and not the whole server. In production you’d put the password in Secrets Manager and have the app read it using its role (Lesson 31).

4Review the network rule
Paste this whole block:
aws ec2 describe-security-group-rules --filters "Name=group-id,Values=$($v.DbSg)" --query 'SecurityGroupRules[?IsEgress==`false`].[IpProtocol,FromPort,ReferencedGroupInfo.GroupId,CidrIpv4]' --output text
$v.AppSgYou should see something like this:
tcp 1433 sg-0c1d2e3f4a5b60003 None
sg-0c1d2e3f4a5b60003There’s one inbound rule, TCP 1433 from saat-app-sg, and no CIDR ranges. Aim for the same shape in production: reference security groups instead of IP ranges, and give admins access through a controlled path.

✅ Checkpoint: Storage is encrypted, rds.force_ssl is in-sync and your session shows encrypt_option TRUE. saat_app can read but can’t create tables, and saat-db-sg allows 1433 only from saat-app-sg.
Break It, Then Fix It
First a mistake that security catches, then a security mistake that stops everything.
1Break it: a weak app password
Try creating a second login the way plenty of scripts still do:
sqlcmd -S "127.0.0.1,11433" -U saatadmin -C -Q "CREATE LOGIN saat_report WITH PASSWORD = 'shop123'"You’ll get an error like this:
Msg 15118, Level 16, State 1, Server EC2AMAZ-ABC123, Line 1
Password validation failed. The password does not meet the operating system policy requirements because it is not complex enough.RDS applies the Windows password policy to SQL logins. Some teams get round it with CHECK_POLICY = OFF, which is the wrong lesson to take away. Fix: generate the password, store it in Secrets Manager and leave the policy switched on:
$rptPw = aws secretsmanager get-random-password --password-length 24 --exclude-punctuation --require-each-included-type --query RandomPassword --output text
sqlcmd -S "127.0.0.1,11433" -U saatadmin -C -Q "CREATE LOGIN saat_report WITH PASSWORD = '$rptPw'; SELECT name, is_policy_checked FROM sys.sql_logins WHERE name LIKE 'saat[_]%'"You should see something like this:
name is_policy_checked
saat_app 1
saat_report 12Break it: remove the app tier’s access
Say someone tidies up saat-db-sg and deletes the 1433 rule. Remove it yourself, then try to connect:
aws ec2 revoke-security-group-ingress --group-id $v.DbSg --protocol tcp --port 1433 --source-group $v.AppSg | Out-Null
Start-Sleep 5
sqlcmd -S "127.0.0.1,11433" -U saatadmin -C -l 15 -Q "SELECT 1"sqlcmd gives up after its 15-second login timeout, and the tunnel window shows something like this:
Connection to destination port failed, check SSM Agent logs.
Every app server in saat-app-sg has just lost its database as well. Because the error looks like a network outage and not a security change, people tend to restart servers first, when CloudTrail’s RevokeSecurityGroupIngress event (Lesson 25) would tell them what really happened.
Fix: put back the same rule that was there before, and never something wider like 10.0.0.0/8:
aws ec2 authorize-security-group-ingress --group-id $v.DbSg --ip-permissions "IpProtocol=tcp,FromPort=1433,ToPort=1433,UserIdGroupPairs=[{GroupId=$($v.AppSg),Description=1433-from-app-sg}]" | Out-Null
sqlcmd -S "127.0.0.1,11433" -U saatadmin -C -h -1 -Q "SET NOCOUNT ON; SELECT 'connected'"You should see this:
connectedClean up the test logins and stop the lab. rds.force_ssl stays on for the rest of the course:
sqlcmd -S "127.0.0.1,11433" -U saatadmin -C -d SaatShop -Q "DROP USER saat_app;"
sqlcmd -S "127.0.0.1,11433" -U saatadmin -C -Q "DROP LOGIN saat_app; DROP LOGIN saat_report;"
Remove-Item force-ssl.json
.\Stop-SqlLab.ps1✅ Checkpoint: SQL Server refused a weak password and you fixed it properly, then put a deleted security group rule back exactly as it was. The test logins are gone, forced TLS stays on and saat-sql is stopping.
This happened at work
The reporting login that could do everything
A logistics company gave its new reporting tool the RDS master login “for now”, because the tool had to read from several databases. Its connection string ended up in a config file on a shared reporting server.
Then a contractor’s laptop with access to that share got infected. The attacker found the config and connected, and because the master user can create logins and drop databases, they made a hidden login and quietly exported customer tables over several nights. TLS wasn’t forced either, so that traffic crossed the VPN unencrypted.
To clean up, the company rotated the master password, deleted the hidden login and forced TLS. Each tool now has its own login with read-only roles on just the databases it needs, the passwords live in Secrets Manager, and there’s an alert whenever a login is created outside a change window.
Common mistakes and troubleshooting
| Mistake | What happens | What to do |
|---|---|---|
| Apps using the master login | A compromised app takes control of the server | One login per app with database roles |
| CHECK_POLICY = OFF for convenience | Weak passwords get through | Generate strong passwords and keep the policy on |
| Setting rds.force_ssl without testing clients | Old clients fail after the reboot | Test TLS 1.2 and the CA bundle first |
| Wide CIDR rules on 1433 | Too many machines can reach the port | Reference security groups only |
| Ignoring CA rotation deadlines | Clients fail certificate checks | Track CACertificateIdentifier and rotate before the deadline |
| Unencrypted instance | Snapshots and backups are unencrypted too | Encrypt at creation; fix with a snapshot copy |
Interview questions
Click a question to open it. Each one is worded the way an interviewer would ask it, and underneath you’ll find why they ask and one way you could answer in your own words.
Fresher level
1. You’re creating a new RDS SQL Server instance for customer data. How would you make sure the data is encrypted at rest?
Why they ask this: They want to know you understand when and how RDS encryption gets set, because missing it at creation means a lot of extra work later.
How you might answer: I’d switch on storage encryption with a KMS key while creating the instance. That covers data, logs, backups, snapshots and read replicas, so everything stays encrypted.
2. Security says every connection to the database must be encrypted. How would you enforce that on RDS SQL Server?
Why they ask this: They’re checking you know how to force TLS and not just allow it, and that you know it needs a reboot.
How you might answer: I’d set rds.force_ssl to 1 in the instance’s parameter group. Since it’s a static parameter, I’d reboot the instance at a quiet time so it takes effect.
3. A developer wants the app to connect with the master user because it’s easier. What would you tell them?
Why they ask this: Real teams take this shortcut all the time, so they want to see you understand least privilege and can explain it to someone else.
How you might answer: I’d tell them the master user can create logins and change any database on the instance, so if the app were ever compromised the attacker would own the whole instance.
What I’d do is create a login for the app with only the permissions it needs.
2–5 years experience
4. Right after you turned on rds.force_ssl, some clients can’t connect anymore. What would you check?
Why they ask this: These errors are common straight after forcing encryption, so they want to hear a clear order for troubleshooting TLS problems.
How you might answer: I’d start by checking the client driver supports TLS 1.2. Next, whether the client validates certificates and has the RDS CA bundle, and whether the hostname it connects to matches the name on the certificate.
I’d also go through the connection string settings, such as Encrypt and TrustServerCertificate.
5. An audit finds an old RDS instance that isn’t encrypted. How would you fix it?
Why they ask this: They’re checking you know encryption can’t just be switched on afterwards, and that you’d plan the cutover.
How you might answer: I’d take a snapshot, copy it with encryption on and a KMS key chosen, and restore a new instance from the encrypted copy. Then, after planning it with the app team, I’d move the clients over to the new instance.
6. What is RDS CA rotation, and why should an admin care about it?
Why they ask this: CA changes have broken a lot of apps that validate certificates, so they want to know you’d catch certificate expiry before it turns into an outage.
How you might answer: RDS server certificates are signed by an RDS certificate authority. When AWS introduces new CAs, I have to move the instances to the new CA and make sure clients trust it before the old one expires.
Otherwise every client that validates certificates stops being able to connect.
Senior level
7. You’re asked to design database security for a PCI workload on RDS SQL Server. How would you approach it?
Why they ask this: They want to see layered security for a regulated workload, covering network, encryption, identity, auditing and regular review.
How you might answer: I’d keep the database in private subnets with security groups that allow traffic by reference, and force TLS with certificate validation. For encryption I’d use customer managed KMS keys, and TDE as well if it’s required.
Every app would get its own least-privilege login with secret rotation, and people would sign in with Windows authentication through Managed AD. For auditing, SQL Server Audit to S3, CloudTrail and GuardDuty RDS protection, along with regular access reviews.
8. You suspect someone is misusing a database login. What do you do?
Why they ask this: They want a calm incident response in a sensible order, where you gather evidence and contain the problem.
How you might answer: I’d start with the error log and SQL Server Audit to see when and from where the login connected, and sys.dm_exec_sessions for anything live. CloudTrail would show management changes, and VPC Flow Logs any unusual sources.
After that I’d disable or rotate the login and look for new logins or permission changes the person might have made.
Quick quiz
Q1. Which parameter forces TLS on RDS for SQL Server?
- force_tls
- rds.force_ssl
- require_secure_transport
- ssl_mode
Show answer
B: set it to 1 and reboot.
Q2. Why did the parameter show pending-reboot?
- It failed
- rds.force_ssl is static
- The group was wrong
- TLS is unsupported
Show answer
B: static parameters take effect at the next restart.
Q3. What did saat_app get when it tried CREATE TABLE?
- Success
- Msg 262 permission denied
- Login failed
- Timeout
Show answer
B: it only has the data reader and writer roles.
Q4. Why was the password shop123 rejected?
- Too long
- Windows password policy complexity
- Wrong database
- TLS was off
Show answer
B — Msg 15118.
Q5. What should saat-db-sg reference for 1433?
- 0.0.0.0/0
- The app tier security group
- The whole VPC CIDR
- Nothing
Show answer
B: reference security groups, not IP ranges.
Quick recap
- Protect RDS SQL Server in layers: the network, TLS, logins and encryption at rest.
- rds.force_ssl is static, so set it, plan a reboot and then check encrypt_option.
- Each app gets its own least-privilege login and never uses the master user.
- Leave the password policy on, and generate passwords and keep them in Secrets Manager.
- Security group rules should reference the app security groups, and after a mistake you restore the exact rule.
Next lesson
Lesson 45: Windows Authentication with AWS Managed Microsoft AD → Next you’ll join saat-sql to a Managed Microsoft AD domain and sign in with Windows accounts in place of SQL logins.
Further reading: RDS SQL Server security
Want to go deeper into RDS SQL Server security? Read Using SSL with a Microsoft SQL Server DB instance and Rotating your SSL/TLS certificate. You can also see the full plan for this course on the AWS Cloud Administration course page.
