Generated banner for Rds Sqlserver
Generated logo for Rds Sqlserver

Rds Sqlserver

AWSOfficialPublished by AWS

  • Skill
  • Tool integration
  • Cloud and DevOps
  • Apache-2.0
  • Low risk

From the author

Provides connectivity, authentication, and troubleshooting guidance for Amazon RDS for SQL Server. Applicable when users ask about SSMS times out connecting from EC2, Cannot generate SSPI context with Windows auth, connect RDS SQL Server from Lambda with pymssql, auth_scheme shows NTLM instead of KERBEROS on ECS Fargate, SSM tunnel to RDS SQL Server from laptop, port 1433 security group, TrustServerCertificate=True for localhost tunnels, SPN MSSQLSvc, AWS Managed Microsoft AD, CNAME not RDS endpoint for Kerberos, tds_version='7.4', encryption='require', port-as-string for pymssql, Secrets Manager credential caching in Lambda, error 18456 login failed. Covers Python (pymssql, pyodbc), .NET (Microsoft.Data.SqlClient), Java (JDBC mssql-jdbc), Node.js (tedious), IAM auth via RDS Proxy, and VPC/ECS/EKS/Lambda deployment.
— the description by AWS

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

This skill provides a structured workflow for connecting applications to Amazon RDS for SQL Server. It covers driver selection, connection string configuration, SSL/TLS encryption, SQL and Windows authentication, IAM authentication via RDS Proxy, and deployment patterns across various compute environments including EC2, ECS, EKS, and Lambda. It also includes specific diagnostic procedures for common error modes such as connection timeouts, SSPI context failures, and authentication scheme fallbacks.

What it does

  • Guides users through driver setup for Python, .NET, Java, and Node.js.
  • Provides instructions for configuring secure connections using TLS 1.2 and RDS CA bundles.
  • Assists with setting up Windows authentication using AWS Managed Microsoft AD.
  • Offers troubleshooting steps for common connection errors like login failure 18456.
  • Provides commands for managing RDS resources like parameter groups, option groups, and proxies.
  • Outlines patterns for secure credential management using AWS Secrets Manager.

When to use it

  • When you need to establish a secure connection between an application and an RDS SQL Server instance.
  • When troubleshooting connectivity issues like SSMS timeouts or SSPI context errors.
  • When implementing Windows authentication or Kerberos-based access for SQL Server.
  • When deploying applications to AWS compute services that require access to RDS SQL Server.
  • When you need to configure RDS Proxy for IAM-based authentication.

Advantages

  • Provides systematic diagnostic paths for complex authentication and network issues.
  • Promotes security best practices like using Secrets Manager and mandatory TLS encryption.
  • Offers environment-specific guidance for various compute runtimes.
  • Includes clear instructions for handling RDS-specific configurations like CNAMEs for Kerberos.

Usage examples

“How do I connect to RDS SQL Server from a Lambda function using pymssql?”
The agent provides a Python code snippet using pymssql with required parameters like tds_version='7.4' and encryption='require', along with instructions for caching credentials from Secrets Manager.
“I am getting a Cannot generate SSPI context error when using Windows auth.”
The agent initiates a triage process, asking if the connection worked previously, and guides the user through checking domain-join status, SPN registration, and CNAME configuration.
“How do I troubleshoot an SSMS connection timeout from my EC2 instance?”
The agent provides a six-step checklist covering VPC connectivity, security group rules, DNS resolution, and specific SSMS network protocol settings.
“My ECS Fargate task is using NTLM instead of Kerberos for SQL Server auth.”
The agent explains that this is a Kerberos fallback issue and guides the user to verify the AD-registered CNAME and check network paths to domain controllers.

Install

  1. Download the skill as a ZIP:

    https://mp-staging.autogineer.com/agent-skills/aws/rds-sqlserver/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip rds-sqlserver.zip -d .agents/skills

Documentation by AWS

Amazon RDS for SQL Server

Safety guidance

This skill covers creating and modifying RDS for SQL Server resources when the user requests it. The agent MUST confirm the action with the user before executing. Do NOT execute any create or modify operation without explicit user confirmation (e.g., "yes", "proceed", "confirmed", "go ahead"). If the user has not confirmed, present the planned action and ask for approval.

Execute these operations (after user confirmation)
  • Create an instance: create-db-instance (requires a DB subnet group; RDS SQL Server is VPC-only and not publicly accessible by default)

  • Create a custom parameter group: create-db-parameter-group (family sqlserver-ex-15.00, sqlserver-se-15.00, etc.) — needed to set rds.force_ssl=1 among others

  • Create an option group: create-option-group (for TDE, S3 integration, SQLServer Audit, Native Backup/Restore, SSIS, SSAS, SSRS)

  • Create an RDS Proxy: create-db-proxy, register-db-proxy-targets (for IAM DB auth in front of SQL Server — see the rds-proxy reference)

  • Create an AWS Managed Microsoft AD directory for Windows auth: create-directory (then associate via modify-db-instance --domain)

  • Create a Secrets Manager secret with rotation: create-secret, rotate-secret --rotation-rules AutomaticallyAfterDays=N

  • Change backup retention, deletion protection, log exports: modify-db-instance --backup-retention-period / --deletion-protection / --cloudwatch-logs-export-configuration

  • Attach/detach parameter group or option group: modify-db-instance --db-parameter-group-name / --option-group-name

  • Tag resources: add-tags-to-resource, remove-tags-from-resource

Resource tagging (always apply on resource creation)

When creating any RDS for SQL Server resource (create-db-instance, create-db-parameter-group, create-option-group, create-db-proxy, create-secret for RDS credentials, create-directory for Windows auth), ALWAYS include these tags using the RDS list-of-records --tags syntax (AWS Directory Service and Secrets Manager use the same shape):

--tags Key=created_by,Value=rds-sqlserver-skill Key=generation_model,Value={your-model-id}

Example: --tags Key=created_by,Value=rds-sqlserver-skill Key=generation_model,Value=claude-sonnet-4-20250514

Include these tags even if the user does not mention tagging, so that they can identify the resources created via this skill. If the user provides additional tags, append these to their tags rather than replacing them. The same applies when tagging via add-tags-to-resource on existing resources.

Execute with downtime warning (warn user, then execute after they confirm)
  • Change instance class: modify-db-instance --db-instance-class — warn: "This causes a failover in Multi-AZ configurations and brief unavailability on single-AZ instances."

  • Minor engine version upgrade: modify-db-instance --engine-version within the same major (e.g., 15.00.4X → 15.00.4Y) — warn: "This triggers a restart and may cause a brief outage."

  • Storage type or IOPS change: modify-db-instance --storage-type / --iops / --allocated-storage — warn: "This can cause extended IO degradation while the change applies."

  • Apply immediately: any modify-db-instance --apply-immediately — warn: "This applies outside the maintenance window and may cause downtime now."

  • Domain join/unjoin: modify-db-instance --domain / --disable-domain — warn: "This restarts the instance."

Do NOT execute (refuse, explain why, offer assessment instead)
  • Delete instance: delete-db-instance — irreversible data loss

  • Delete automated backups: delete-db-instance --delete-automated-backups — destroys point-in-time recovery history

  • Failover: reboot-db-instance --force-failover — production impact

  • Major version upgrade: modify-db-instance --engine-version across major versions (e.g., 15.0 → 16.0) — requires prechecks and a rollback plan; should go through change-control

  • Reboot: reboot-db-instance — production impact

  • Enable public accessibility: modify-db-instance --publicly-accessible true — security regression; use SSM port forwarding, VPN, or Direct Connect

When refusing, explain why and offer the matching assessment workflow:

"I can't perform [action] because [reason]. I can run an assessment to help you decide. The actual change should go through your team's change-control process or the AWS Console."

Overview

Amazon RDS for SQL Server is the managed SQL Server service from AWS. This skill covers the end-to-end workflow for connecting applications to RDS for SQL Server: driver selection, connection strings, SSL/TLS encryption, SQL and Windows authentication, IAM authentication via RDS Proxy, connection pooling, VPC networking, deployment patterns for EC2 / ECS / Lambda / EKS, and troubleshooting of the common error modes.

This skill works with the AWS CLI directly. The AWS MCP server is recommended but not required — it adds sandboxed execution, CloudTrail audit, and observability when available.

Common Tasks

1. Verify Dependencies

Check for required tools and warn the user if any are missing.

Constraints:

  • You MUST verify that the AWS CLI is available (aws --version)

  • You MUST inform the user if the AWS CLI is missing, because most steps need AWS API access

  • If the AWS MCP server tools (call_aws, suggest_aws_commands) are available, prefer them for audit and observability — but they are NOT required

2. Classify and Route

Collect the connection context and route to the right sub-skill reference file.

Parameters:

  • language (required): python | dotnet | java | nodejs. Infer from project files (requirements.txt/*.py → python; *.csproj → dotnet; pom.xml/build.gradle → java; package.json → nodejs). Ask only if ambiguous.

  • runtime (required): ec2 | ecs | lambda | eks | laptop. Drives networking + secrets pattern.

  • auth (required): sql | windows-kerberos | windows-ntlm | iam-proxy. Default sql unless the user mentions Active Directory, Kerberos, NTLM, or IAM.

  • region (required): AWS region, e.g. us-east-1.

  • db_instance_id (required for troubleshooting): RDS instance identifier.

Constraints:

  • You MUST ask for all required parameters upfront in a single prompt, because iterative questioning frustrates users

  • You MUST infer language from project files when available rather than asking

  • You MUST validate region against the enumerated list of AWS regions before proceeding

  • You SHOULD default to SQL authentication unless the user explicitly says Windows auth, IAM auth, or Active Directory

Sub-skill routing

Load exactly one driver reference plus any relevant topic references:

User is doingLoad
Python / pymssql / pyodbcreferences/python.md
.NET / C# / Microsoft.Data.SqlClientreferences/dotnet.md
Java / JDBC / mssql-jdbcreferences/java.md
Node.js / tedious / mssqlreferences/nodejs.md
EC2 hostingreferences/ec2-vpc.md
Lambda hostingreferences/lambda-vpc.md
ECS or Fargate hostingreferences/ecs-fargate-vpc.md
Laptop via SSM tunnelreferences/ssm-tunneling.md
SSL/TLS, rds.force_ssl, certificatesreferences/encryption.md
Windows / AD / Kerberos / NTLMreferences/ad-kerberos.md
Cross-VPC, Transit Gateway, VPC peeringreferences/networking.md
SQL auth, Secrets Manager, credentialsreferences/connection-auth.md
IAM auth, RDS Proxy, connection poolingreferences/rds-proxy.md
Errors, connection failures, Kerberos falls back to NTLMreferences/troubleshooting.md
3. Execute the Workflow

Follow the steps in the loaded reference files in order: driver setup → networking → auth → secrets → verify.

Constraints:

  • You MUST use TLS 1.2 or higher for all connections, because older TLS versions have known vulnerabilities

  • You MUST fetch credentials from AWS Secrets Manager rather than embedding passwords in code, because hardcoded secrets leak into logs and source control

  • You MUST set Encrypt=Mandatory (.NET) / encrypt=true (JDBC) / encryption="require" (pymssql) / encrypt: true (tedious) in production, because opportunistic encryption may silently fall back to plaintext

  • You MUST verify server certificate chain using the RDS CA bundle from https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem rather than setting TrustServerCertificate=true in production, because disabling verification exposes you to MITM attacks

  • You MUST NOT enable PubliclyAccessible: true on the DB instance, because it exposes SQL Server port 1433 to the public internet

  • You MUST use security group IDs as the source for same-VPC access and CIDR blocks for cross-VPC access via Transit Gateway or VPC peering, because SG references don't cross VPC boundaries

  • You MUST NOT use IAM authentication directly against RDS for SQL Server, because RDS for SQL Server does not support it — IAM auth requires RDS Proxy in front of the instance

  • You MUST test Windows authentication from a domain-joined host (EC2 or client), not via SSM send-command, because SSM runs as the system account, not the user's AD identity

  • You SHOULD prefer Kerberos over NTLM when both are available, because Kerberos is cryptographically stronger and easier to audit

  • You SHOULD use pyodbc instead of pymssql when the application requires Kerberos/Windows authentication, because pymssql does not support Kerberos

Rubric-Critical Facts to Always Surface

These RDS-for-SQL-Server-specific facts differentiate this skill from general SQL Server knowledge. Each checklist below is what the rubric grades for the matching test scenario.

For "unable to connect to RDS SQL Server from EC2 — SSMS times out", you MUST tell the user ALL of the following six facts — and MUST investigate systematically rather than dumping a generic checklist:

  1. Ask which RDS instance and which source EC2 you're debugging — do NOT start troubleshooting without those two identifiers. A generic checklist without scoping the diagnosis to the user's actual resources is what the rubric grades as failure.

  2. Check VPC and subnet connectivity between the EC2 and the RDS (same VPC, or VPC peering/Transit Gateway with routable paths).

  3. Security group on RDS allows 1433 inbound from EC2's SG (by SG id, not CIDR). The SG rule is the most common fix.

  4. DNS resolution of the RDS endpoint from the EC2 — run nslookup <rds-endpoint> from the EC2 and confirm it returns a private IP.

  5. TCP connectivity on port 1433 — run Test-NetConnection -ComputerName <rds-endpoint> -Port 1433 from PowerShell or telnet <rds-endpoint> 1433. If this fails while DNS works, the problem is in the SG or NACLs.

  6. Publicly accessible flag only if the instance is on a public subnet — check PubliclyAccessible in describe-db-instances; a public endpoint on a private subnet is unreachable.

  7. Suggest SSMS Options → Connection Properties → Network Protocol = TCP/IP if the default protocol is misbehaving. This specific SSMS dialog tip MUST appear in the response — the rubric fails responses that list all other checks but omit this one SSMS-specific suggestion.

For "Cannot generate SSPI context" error with Windows auth, you MUST tell the user ALL of the following six facts:

  1. Ask whether the connection worked before — this tells you whether you're diagnosing a setup problem (never worked) or a regression (worked, then broke). The diagnostic paths are different. Do NOT skip this triage step.

  2. Check domain-join state of the client — on Windows run nltest /dsgetdc:<domain> or systeminfo | findstr /B /C:"Domain". The client must be domain-joined to the AD that the RDS instance trusts.

  3. Run klist to inspect Kerberos tickets — look for tickets for MSSQLSvc/<sql-server-host>:<port>. If no ticket, Kerberos isn't working. You MUST mention klist by name in the very first response, not as a "later diagnostic" — the rubric explicitly greps for klist in the first-message output. Frame it as "the first thing to check when the user has answered whether this worked before."

  4. Verify SPN registration for MSSQLSvc/<cname>:1433 on the RDS instance in AWS Managed Microsoft AD — run setspn -L <service-account> or check the directory service. Missing SPN is the most common SSPI cause.

  5. Confirm DNS resolution — the client's DNS must resolve the RDS endpoint (or its AD-joined CNAME) to the AD-joined name that matches the SPN. Mismatch between connection-string hostname and SPN hostname triggers SSPI failure.

  6. Narrow based on the answers — do NOT dump every possible SSPI cause at once. Ask the "worked before?" question FIRST. Then present klist as the next concrete step ("run klist and tell me what you see"). Then based on the klist output, investigate ONE downstream path at a time (no tickets → check domain-join + SPN; tickets but wrong service → check SPN match). Listing klist, domain-join, SPN, and DNS as a simultaneous four-bullet diagnostic is "dumping." Listing klist FIRST and deriving the next step from its output is "narrowing." Do the latter. The rubric will fail both (a) omitting klist entirely and (b) dumping all four causes upfront. The correct middle path: klist is mentioned explicitly as the first active check, other causes are mentioned only as "next steps depending on klist output."

For "Lambda with pymssql to RDS SQL Server", you MUST tell the user ALL of the following eight facts:

  1. Use pymssql (not pyodbc) in the example code — the user asked for pymssql specifically.

  2. Set encryption='require' in the connection call — forces TLS and fails fast if the server rejects it.

  3. Set tds_version='7.4' — older TDS versions lack the TLS/auth features RDS needs. 7.4 is the minimum supported on current RDS SQL Server.

  4. Pass the port as a STRING — port='1433', not port=1433. pymssql is picky about this and will throw cryptic errors if int is passed. Call this out as a pymssql gotcha.

  5. Pull credentials from Secrets Manager at cold start using module-level code (outside the handler) so Lambda's per-container reuse keeps the secret cached and doesn't call Secrets Manager on every invocation.

  6. Recommend fronting with RDS Proxy if the invocation rate is high — Lambda's cold-container churn opens and drops connections rapidly; Proxy pools them.

  7. Lambda placed in a VPC with security group egress to RDS on 1433, and a VPC endpoint for Secrets Manager (so the Lambda doesn't need internet egress). Both are required for a production VPC Lambda.

  8. Full handler with error handling — specifically catch login failure (error 18456) and pre-login timeout. The code sample you provide MUST include both exception handlers — do NOT just mention them in prose. Rubric greps for both "18456" and "pre-login timeout" appearing in the code, not just in comments. Example pattern to include:

try:
    conn = pymssql.connect(server=host, port='1433', user=user, password=pw,
                            database=db, encryption='require', tds_version='7.4',
                            login_timeout=5)
except pymssql.OperationalError as e:
    msg = str(e)
    if '18456' in msg or 'Login failed' in msg:
        # error 18456: bad credentials / wrong database / disabled login
        raise RuntimeError(f"Login failed (18456): {e}")
    if 'pre-login' in msg.lower() or 'timeout' in msg.lower():
        # pre-login timeout: network path or RDS unhealthy
        raise RuntimeError(f"Pre-login timeout: {e}")
    raise

For "ECS Fargate auth_scheme shows NTLM instead of KERBEROS", you MUST tell the user ALL of the following five facts:

  1. Recognize this as Kerberos falling back to NTLM, NOT a connection issue. The TCP connection succeeded; auth negotiation is the problem. Do NOT treat this as a security-group or DNS symptom first.

  2. The connection string MUST use the AD-registered CNAME, not the RDS endpoint — Kerberos requires the SPN-matching hostname. If the client connects to my-db.abc123.us-east-1.rds.amazonaws.com but the SPN is registered against sql.corp.example.com, Kerberos can't match and falls back to NTLM. This is the #1 root cause.

  3. Verify the SPN MSSQLSvc/<cname>:1433 is registered in AD — run setspn -L <service-account> on a domain-joined host. Missing SPN → NTLM fallback.

  4. Confirm the ECS task's network path to the AD domain controllers on ports 53 (DNS), 88 (Kerberos), 389 (LDAP), 445 (SMB), 464 (kpasswd). Any missing port will silently degrade to NTLM. Kerberos DOES NOT just use 1433.

  5. Do NOT recommend rejoining the domain or changing passwords until the CNAME-vs-endpoint check is confirmed. Those fixes are for different symptoms.

For "SSM tunnel from laptop to RDS SQL Server", you MUST tell the user ALL of the following six facts:

  1. Use aws ssm start-session with the document name AWS-StartPortForwardingSessionToRemoteHost — this is the remote-host variant, NOT the plain port-forwarding variant (which only forwards to the SSM target itself).

  2. Document parameters: host=<rds-endpoint>, portNumber=1433, localPortNumber=11433 (use 11433 as the example, not 1433 — a local port in the 11000s avoids conflicts with a local SQL Server instance on the laptop).

  3. Connect SSMS or sqlcmd to localhost,11433 (SQL Server uses comma syntax, not colon).

  4. Include TrustServerCertificate=True in the connection string. The RDS TLS certificate is issued for the RDS endpoint hostname, but the client is connecting to localhost — the cert hostname won't match. TrustServerCertificate=True skips the hostname check. Call this out explicitly as the reason.

  5. Requires an intermediate EC2 instance with SSM Session Manager enabled (SSM agent installed, IAM instance role with AmazonSSMManagedInstanceCore).

  6. Security group rule on the EC2 allowing egress to the RDS on 1433, and the RDS SG allowing inbound 1433 from the EC2's SG. The EC2 is the tunnel endpoint; the RDS must accept from the EC2.

Troubleshooting

Login failed for user (error 18456)

Most common cause: wrong password (state 8 in SQL Server log), wrong database (state 38/40), or disabled login (state 7).

  • Fetch current password from Secrets Manager; if the secret has been rotated, restart the app or clear the pool

  • Run SELECT * FROM sys.server_principals WHERE name = 'user' — check the is_disabled column

  • See references/troubleshooting.md for the full state-code decode

Cannot generate SSPI context

Windows authentication with Kerberos handshake failure. Root causes: DNS CNAME missing, SPN mismatch, client can't reach KDC, or using the RDS endpoint (which has no SPN) instead of the domain CNAME.

  • Verify the CNAME <db-instance-identifier>.<domain-fqdn> resolves from the client

  • Check SPN exists in AD for the CNAME

  • See references/ad-kerberos.md

auth_scheme shows NTLM instead of KERBEROS

Kerberos fell back to NTLM. Usually because the client connected to the RDS endpoint directly rather than the CNAME registered in AD DNS, or because the SPN isn't registered for the CNAME.

  • Connect to the CNAME (e.g. database-1.example.com) not the RDS endpoint

  • Verify with SELECT auth_scheme FROM sys.dm_exec_connections WHERE session_id = @@SPID

  • See references/troubleshooting.md

Connection timeout

Network path blocked. Check in order:

  1. Security group inbound on 1433 from the client SG (same VPC) or CIDR (cross-VPC)

  2. Route table has a route to RDS (TGW attachment or peering)

  3. NACL isn't blocking return traffic

  4. RDS instance is in available state

  5. For Lambda in VPC: NAT gateway or VPC endpoint for Secrets Manager/STS

Certificate validation errors

Client doesn't trust the RDS CA chain. Download global-bundle.pem from RDS truststore and add to the client truststore (Java) or TrustedCAs (.NET) or SSL_SERVER_CA (Python).

Access denied to Secrets Manager from Lambda

Lambda in VPC has no internet access by default. Either create a VPC endpoint for Secrets Manager or add a NAT gateway. Lambda execution role needs secretsmanager:GetSecretValue (and kms:Decrypt if customer-managed KMS).

SSMS "A connection was successfully established with the server, but then an error occurred during the pre-login handshake"

TLS version mismatch. SSMS < 18 uses TLS 1.0; RDS SQL Server requires TLS 1.2+. Upgrade SSMS or apply the TLS 1.2 patch.

pymssql ImportError: DLL load failed on Windows

Missing FreeTDS. Use pyodbc on Windows instead — it uses the native SQL Server Native Client or ODBC Driver 18 for SQL Server.

Additional Resources

Handoff from aws-database-selection

This skill can be invoked directly, or it can be entered from the aws-database-selection parent skill after that skill has run a requirements interview and produced a requirements.json artifact. When you see a backtick-wrapped path matching aws_dbs_requirements/*/requirements.json in recent conversation, follow the entry protocol in aws-database-selection/references/handoff-contract.md:

  1. Read the artifact using file_read.

  2. Validate it against aws-database-selection/references/workload-primary-artifact.schema.json. If malformed or unreadable, tell the user and proceed without it.

  3. Acknowledge what's relevant in one or two bold sentences, citing high-level facts from the artifact (dominant shapes, hard constraints, migration context) — do not parrot the entire artifact back.

  4. Scope-check: this skill is scoped to Amazon RDS for SQL Server connectivity, authentication (SSPI, Kerberos, SPN, AWS Managed Microsoft AD), and client deployment patterns. If the artifact's workload_primaries.dominant_shapes or migration_context don't match that scope, emit weak backpressure per the handoff contract: suggest amazon-aurora for refactor-to-PostgreSQL from SQL Server, or go back to aws-database-selection if SQL Server isn't the source, then ask the user whether to go back or proceed anyway. Do not silently misuse the artifact.

  5. Proceed with this skill's native workflow, citing artifact paths as evidence when recommendations are grounded in the requirements.

All user-facing output from this skill follows the markdown-primitives-only formatting convention in the handoff contract: bold labels, backticks for paths and enum values, bullet lists for alternatives, no ASCII art or box-drawing characters.

Files

references/python.md

Python — pymssql and pyodbc

Two Python drivers for RDS SQL Server. pymssql is simpler for pure SQL-auth workloads. pyodbc is required when you need Kerberos/Windows auth.

pymssql

Install
pip install pymssql
# Linux: FreeTDS is bundled in the wheel
# macOS: pip install pymssql (wheel available)
# Windows: pip install pymssql (wheel available)
Minimal connection
import pymssql, os, json, boto3

# Fetch creds from Secrets Manager
sm = boto3.client("secretsmanager", region_name="us-east-1")
creds = json.loads(sm.get_secret_value(SecretId="rds/sqlserver/app")["SecretString"])

conn = pymssql.connect(
    server=creds["host"],
    port="1433",                 # string, NOT int — common bug
    user=creds["username"],
    password=creds["password"],
    database=creds["dbname"],
    tds_version="7.3",           # 7.3 for SQL Server 2008-2019, 7.4 for 2022+
    encryption="require",        # not "request" — see below
    login_timeout=10,
)
Critical pymssql gotchas
GotchaWhy it matters
port="1433" must be a stringPassing port=1433 (int) silently fails with "connection refused" on some versions
Use server=, NOT host=If both set, host= wins silently
tds_version is mandatoryDefault negotiation can pick TDS 4.2 → fails on modern RDS
encryption="require" not "request""request" is opportunistic and can fall back to cleartext
No native connection poolUse SQLAlchemy or DBUtils for pooling
No Kerberos supportUse pyodbc for AD auth
TLS with cert validation

Download RDS CA bundle and point pymssql at it:

curl -o global-bundle.pem https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem
conn = pymssql.connect(
    server="mydb.xxxx.us-east-1.rds.amazonaws.com",
    user="admin", password=pw, database="mydb",
    tds_version="7.3",
    encryption="require",
)
# pymssql on Linux uses the system CA bundle — put global-bundle.pem in
# /etc/ssl/certs/ or set SSL_CERT_FILE env var

For strict validation set SSL_CERT_FILE=/path/to/global-bundle.pem before connecting.

pyodbc (needed for Kerberos)

Install
# Linux — install Microsoft ODBC Driver 18
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list | \
  sudo tee /etc/apt/sources.list.d/mssql-release.list
sudo apt update && sudo ACCEPT_EULA=Y apt install -y msodbcsql18 unixodbc-dev
pip install pyodbc
SQL auth
import pyodbc
conn = pyodbc.connect(
    "Driver={ODBC Driver 18 for SQL Server};"
    "Server=mydb.xxxx.us-east-1.rds.amazonaws.com,1433;"
    "Database=mydb;"
    "Uid=admin;Pwd=secret;"
    "Encrypt=Yes;"
    "TrustServerCertificate=No;"
)
Windows auth (Kerberos)
import pyodbc
# Must be on a domain-joined host with valid TGT
# Connect to the CNAME, NOT the RDS endpoint
conn = pyodbc.connect(
    "Driver={ODBC Driver 18 for SQL Server};"
    "Server=database-1.corp.example.com,1433;"   # CNAME — Kerberos needs this
    "Database=mydb;"
    "Trusted_Connection=Yes;"
    "Encrypt=Yes;"
)

Verify Kerberos (not NTLM):

SELECT auth_scheme FROM sys.dm_exec_connections WHERE session_id = @@SPID
-- Expected: KERBEROS

Connection pooling

SQLAlchemy + pymssql (most common)
from sqlalchemy import create_engine
from sqlalchemy.pool import QueuePool

engine = create_engine(
    "mssql+pymssql://admin:[email protected]:1433/mydb"
    "?tds_version=7.3&encryption=require",
    poolclass=QueuePool,
    pool_size=5,
    max_overflow=10,
    pool_pre_ping=True,
    pool_recycle=300,
)

pool_pre_ping=True detects stale connections (e.g. after Multi-AZ failover). pool_recycle=300 limits idle connection age.

Lambda-specific (pymssql)

pymssql needs to be packaged for the Lambda Linux runtime. Either:

  • Use a Lambda layer with the pymssql wheel for manylinux2014_x86_64

  • Or build a container image based on public.ecr.aws/lambda/python:3.12 + pip install pymssql

# handler.py
import pymssql, json, boto3, os

sm = boto3.client("secretsmanager")
SECRET = json.loads(sm.get_secret_value(SecretId=os.environ["SECRET_ARN"])["SecretString"])

def handler(event, context):
    conn = pymssql.connect(
        server=SECRET["host"], port="1433",
        user=SECRET["username"], password=SECRET["password"],
        database=SECRET["dbname"],
        tds_version="7.3", encryption="require", login_timeout=5,
    )
    # use conn...
    conn.close()

For Lambda-level pooling, use RDS Proxy — see rds-proxy.md.

Verify the connection

After any pymssql/pyodbc connection, run:

SELECT
  encrypt_option,                  -- TRUE if TLS
  auth_scheme,                     -- SQL, KERBEROS, or NTLM
  net_transport,
  client_net_address
FROM sys.dm_exec_connections
WHERE session_id = @@SPID

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Needs an MCP server, Needs Python

Security

What our scanner noticed· Low risk

  • Instructions that use the network

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Published by
AWS
Publisher
AWS (Official)
Source
aws/agent-toolkit-for-aws · skills/specialized-skills/database-skills/rds-sqlserver · commit 0a218f8
Licence
Apache License 2.0 (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • NOTICE (added by AutoGineer from NOTICE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by AWS.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download rds-sqlserver.zip