Subchapter 63.2
references/auth/authentication-guide.mdMarkdown11 KBView on GitHub
Principle of least privilege:
dsql:DbConnect for standard usersdsql:DbConnectAdmin for administrative operations{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "dsql:DbConnect",
"Resource": "arn:aws:dsql:us-east-1:123456789012:cluster/<cluster-id>",
"Condition": {
"StringEquals": {
"aws:ResourceTag/Environment": "development"
}
}
}
]
}Rotation strategies:
Best practices:
ALWAYS dynamically assign credentials:
# Good - Use Parameter Store
export CLUSTER_ENDPOINT=$(aws ssm get-parameter \
--name /myapp/dsql/endpoint \
--query 'Parameter.Value' \
--output text)
# Bad - Hardcoded in code
const endpoint = "abc123.dsql.us-east-1.on.aws" // BAD: Use Parameter Store insteadDefaults below; verify against the live limits via the AWS MCP Server’s aws___search_documentation if available (aurora dsql connection limits), or check the DSQL connection limits docs (opens in a new tab) directly:
aws___search_documentation if available, or the DSQL authentication docs (opens in a new tab): aurora dsql authentication token)Aurora DSQL uses the PostgreSQL wire protocol (opens in a new tab) and enforces SSL:
sslmode: verify-full
sslnegotiation: direct # PostgreSQL 17+ drivers (better performance)
port: 5432
database: postgres # single database per clusterKey details:
verify-full to verify server certificatedirect TLS negotiation for PostgreSQL 17+ compatible driversFor production applications:
BeforeConnect or equivalent hookCloudTrail integration:
Recommended setup: Enable a CloudTrail trail with data events for DSQL API calls.
Prerequisite: The target S3 bucket MUST have SSE-KMS encryption enabled with a bucket policy restricting access to the CloudTrail service principal. The policy MUST include aws:SourceArn and aws:SourceAccount condition keys to prevent confused-deputy attacks (any other AWS account that knows the bucket name could otherwise direct CloudTrail to write forged logs into your bucket):
# Ensure S3 bucket has SSE-KMS encryption
aws s3api put-bucket-encryption \
--bucket my-cloudtrail-bucket \
--server-side-encryption-configuration '{
"Rules": [{"ApplyServerSideEncryptionByDefault": {"SSEAlgorithm": "aws:kms", "KMSMasterKeyID": "arn:aws:kms:us-east-1:123456789012:key/<key-id>"}}]
}'
# Apply a bucket policy scoped to THIS account's CloudTrail trail.
# Replace 123456789012 with your account ID and dsql-audit-trail with your trail name.
cat > /tmp/cloudtrail-bucket-policy.json <<'POLICY'
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AWSCloudTrailAclCheck",
"Effect": "Allow",
"Principal": {"Service": "cloudtrail.amazonaws.com"},
"Action": "s3:GetBucketAcl",
"Resource": "arn:aws:s3:::my-cloudtrail-bucket",
"Condition": {
"StringEquals": {
"aws:SourceArn": "arn:aws:cloudtrail:us-east-1:123456789012:trail/dsql-audit-trail",
"aws:SourceAccount": "123456789012"
}
}
},
{
"Sid": "AWSCloudTrailWrite",
"Effect": "Allow",
"Principal": {"Service": "cloudtrail.amazonaws.com"},
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::my-cloudtrail-bucket/AWSLogs/123456789012/*",
"Condition": {
"StringEquals": {
"s3:x-amz-acl": "bucket-owner-full-control",
"aws:SourceArn": "arn:aws:cloudtrail:us-east-1:123456789012:trail/dsql-audit-trail",
"aws:SourceAccount": "123456789012"
}
}
}
]
}
POLICY
aws s3api put-bucket-policy --bucket my-cloudtrail-bucket --policy file:///tmp/cloudtrail-bucket-policy.json
# Create a trail that logs DSQL management events.
# --enable-log-file-validation lets you detect tampered/deleted log files.
# --cloud-watch-logs-* parameters are REQUIRED for the metric filter and
# alarm below to receive events; without them CloudTrail only delivers to S3.
aws cloudtrail create-trail \
--name dsql-audit-trail \
--s3-bucket-name my-cloudtrail-bucket \
--is-multi-region-trail \
--kms-key-id arn:aws:kms:us-east-1:123456789012:key/<key-id> \
--enable-log-file-validation \
--cloud-watch-logs-log-group-arn arn:aws:logs:us-east-1:123456789012:log-group:CloudTrail/DefaultLogGroup:* \
--cloud-watch-logs-role-arn arn:aws:iam::123456789012:role/CloudTrail_CloudWatchLogs_Role
aws cloudtrail start-logging --name dsql-audit-trailCloudWatch alarms for security monitoring:
# Encrypt the CloudWatch Log Group (DSQL auth events may contain sensitive metadata)
aws logs associate-kms-key \
--log-group-name CloudTrail/DefaultLogGroup \
--kms-key-id arn:aws:kms:us-east-1:123456789012:key/<key-id>
# Create a metric filter for failed authentication attempts
aws logs put-metric-filter \
--log-group-name CloudTrail/DefaultLogGroup \
--filter-name DSQLFailedAuth \
--filter-pattern '{ ($.eventSource = "dsql.amazonaws.com") && ($.errorCode = "AccessDenied*") }' \
--metric-transformations metricName=DSQLFailedAuth,metricNamespace=DSQL/Security,metricValue=1
# Create an alarm on failed auth attempts
Query logging:
ALWAYS prefer scoped database roles over the admin role.
admin for initial setup and role managementdsql:DbConnectpublicSELECT * FROM sys.iam_pg_role_mappings;For complete role setup instructions, schema separation patterns, and IAM configuration, see access-control.md.