Skip to content
tempkey ← Back to blog

Tempkey Blog

Database Security Without Shared Passwords: Contractor Access Management for AWS RDS

Learn how to eliminate shared database credentials when working with external engineers on AWS RDS. Discover time-bounded access workflows and automated offboarding patterns.

Implementing contractor access management for aws rds allows engineering teams to grant external developers short-lived, database-level credentials without ever circulating static master passwords or unencrypted connection strings. By binding database roles to AWS Identity and Access Management (IAM) authentication tokens, you can enforce time-delimited access that expires automatically, eliminating dangling database privileges when freelance contracts end.

For inbox-safety context, FTC phishing guidance recommends treating unexpected messages and requests for personal information with caution.

For privacy context, FTC guidance on how websites and apps collect and use information explains why people should be careful about where they share personal contact details.

For engineering leads and operations managers, external contractors provide critical velocity—whether tuning slow queries, executing schema migrations, or diagnosing production anomalies. However, standard administrative habits often introduce severe security vulnerabilities. Handing out static database passwords or keeping long-lived credentials on uncontrolled personal devices violates foundational security principles. Managing database privileges for external contributors requires an architecture where access is temporary by default, strictly isolated by network boundaries, and verified when work concludes.

The Hidden Risks of Static Credentials in Freelance Database Projects

Most small- to mid-sized engineering teams struggle with database security for freelancers because typical developer onboarding scripts are built for full-time employees. When an external database consultant begins an engagement, an administrator often runs a quick script to generate a static database user, assigns a persistent password, and sends it across Slack, email, or a shared password vault. That single operational compromise triggers systemic downstream risks.

First, static credentials rarely stay within secure confines. Freelancers typically operate on unmanaged personal hardware rather than corporate laptops configured with mobile device management (MDM) software. Database credentials end up stored in plain text inside local .env files, cached in graphical database client history (such as DBeaver or TablePlus), saved in shell command history (like psql or mysql invocation logs), and backed up to third-party personal cloud backups. Even if the contractor maintains good security hygiene, your production database credentials now exist across unmonitored endpoints outside your control.

Second, freelance engagements suffer from ambiguous termination timelines. A full-time employee offboarding follows a formal HR workflow involving account deactivations across identity providers. In contrast, contractor projects frequently taper off without a definitive offboarding event. An external developer might finish a tuning task, submit a final invoice, and remain silent for months. Meanwhile, their database credentials remain valid inside pg_shadow or mysql.user tables. If that freelancer's laptop is compromised months later, your database remains an open target.

Finally, shared administrative credentials obliterate non-repudiation. When multiple external developers connect using a shared administrative account or a generic contractor_dev role, pinpointing which individual ran a destructive DROP TABLE, modified an index, or exported sensitive records becomes impossible. Robust aws rds access control demands individual attribution, credential ephemerality, and automated lifecycle enforcement.

Core Architectures for Contractor Access Management for AWS RDS

To eliminate static passwords while maintaining operational agility, engineering teams must evaluate their core credential delivery mechanisms. Three primary architectures exist for authenticating external contractors to AWS RDS instances: static database users, AWS Secrets Manager rotation, and AWS IAM database authentication.

Evaluation Criteria Static Database Credentials AWS Secrets Manager Rotation AWS IAM Database Authentication
Credential Lifespan Indefinite (until manual drop) Scheduled interval (e.g., 30–90 days) 15 minutes (ephemeral authentication tokens)
Local Endpoint Exposure High; stored in configs and GUI tools Medium; retrieved password stored locally Minimal; token expires before it can be reused
Revocation Mechanism Manual DDL (DROP USER) Secret rotation or IAM policy change Immediate via IAM policy or role detachment
Contractor Experience Standard user/password login Requires AWS CLI/SDK or portal access Generates auth token via AWS CLI or tooling
Native Audit Trail Database engine logs only Secrets Manager retrieval API logs AWS CloudTrail (API) + Database engine audit logs

While AWS Secrets Manager provides automated rotation for long-lived application microservices, it is poorly suited for human interactive debugging. Contractors still receive a static database password; it simply changes on a recurring schedule. If an incident occurs during that rotation window, the contractor retains valid access.

In contrast, AWS IAM database authentication fundamentally alters this dynamic. As outlined in the AWS Documentation on IAM Database Authentication, IAM database authentication generates short-lived auth tokens valid for 15 minutes, removing the need for static database passwords. Instead of authenticating against an internal database password hash, the database engine verifies a cryptographic signature generated by AWS Security Token Service (STS) and IAM using the AWS Signature Version 4 (SigV4) protocol.

Under this model, external contractors are granted temporary IAM permissions rather than permanent database accounts. When their AWS IAM permissions expire or are detached, their ability to request new database connection tokens vanishes instantly, without requiring manual DDL statements inside your database engine.

Defining Least-Privilege Database Roles

Even with temporary IAM tokens, you must strictly limit database-level permissions. rarely map an external contractor to a superuser account (such as postgres or admin ). Instead, establish granular database roles aligned directly with contractor job functions:

  • Read-Only Diagnostics: Intended for performance consultants tuning slow queries. Permissions are restricted to SELECT statements on specific application schemas, with access to internal database statistics views (e.g., pg_stat_statements).
  • Application Support: Allows reading application state and executing limited data updates on non-sensitive tables, strictly barring schema modifications or user administration.
  • Schema Migrations: Temporarily permits Data Definition Language (DDL) operations (such as CREATE TABLE, ALTER TABLE, and CREATE INDEX) during a scheduled deployment window, revoked immediately upon release completion.

Configuring IAM Database Authentication for Ephemeral Contractor Access

Transitioning to IAM database authentication requires configuration across both the AWS infrastructure layer and the relational database engine. Below is an end-to-end implementation for an Amazon RDS PostgreSQL or MySQL cluster.

Step 1: Enable IAM Database Authentication on AWS RDS

IAM authentication must be explicitly activated at the instance or cluster level. You can enable this using the AWS Management Console or via the AWS CLI:

aws rds modify-db-instance \
    --db-instance-identifier prod-postgresql-primary \
    --enable-iam-database-authentication \
    --apply-immediately

Note: Enabling this feature does not cause downtime, but verifying that your database parameter group enforces SSL/TLS connections is critical, as IAM authentication strictly requires encrypted transit.

Step 2: Create IAM-Enabled Database Users

Next, configure the database engine to accept IAM-signed authentication tokens. Connect to your RDS database using an administrative account and execute the engine-specific setup.

For PostgreSQL:

-- Create the database user
CREATE USER contractor_alex;

-- Grant the AWS IAM authentication role
GRANT rds_iam TO contractor_alex;

-- Assign least-privilege read-only permissions
GRANT CONNECT ON DATABASE app_production TO contractor_alex;
GRANT USAGE ON SCHEMA public TO contractor_alex;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO contractor_alex;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO contractor_alex;

For MySQL:

-- Create the MySQL user using the AWS Authentication plugin
CREATE USER 'contractor_alex'@'%' IDENTIFIED WITH AWSAuthenticationPlugin AS 'RDS';

-- Require encrypted transport
ALTER USER 'contractor_alex'@'%' REQUIRE SSL;

-- Assign least-privilege read-only permissions
GRANT SELECT ON app_production.* TO 'contractor_alex'@'%';
FLUSH PRIVILEGES;

Step 3: Define Granular IAM Policies

Create an IAM policy that authorizes the contractor's federated identity or temporary IAM role to connect to the specific database user account. The resource ARN format follows a rigid structure:

arn:aws:rds-db:<region>:<account-id>:dbuser:<db-instance-resource-id>/<db-user-name>

{
   "Version": "2012-10-17",
   "Statement": [
      {
         "Effect": "Allow",
         "Action": [
             "rds-db:connect"
         ],
         "Resource": [
             "arn:aws:rds-db:us-east-1:123456789012:dbuser:db-A1B2C3D4E5F6G7H8/contractor_alex"
         ],
         "Condition": {
             "Bool": {
                 "aws:SecureTransport": "true"
             }
         }
      }
   ]
}

This policy guarantees that even if the contractor possesses valid AWS API keys, they can only authenticate to the designated database user account (contractor_alex) on that specific RDS resource ID, and only over an encrypted connection.

Step 4: Generate Authentication Tokens and Connect

Rather than providing a static database password, the contractor generates a signed authentication token using the AWS CLI or an SDK. The token is an encoded string containing the SigV4 signature:

TOKEN=$(aws rds generate-db-auth-token \
    --hostname prod-postgresql-primary.c12345678901.us-east-1.rds.amazonaws.com \
    --port 5432 \
    --region us-east-1 \
    --username contractor_alex)

The contractor then connects using standard database tooling, passing the generated TOKEN as their password. For example, using the standard PostgreSQL command-line utility:

PGPASSWORD="$TOKEN" psql \
    --host=prod-postgresql-primary.c12345678901.us-east-1.rds.amazonaws.com \
    --port=5432 \
    --username=contractor_alex \
    --dbname=app_production \
    --set=sslmode=require

Configuring Desktop Database GUIs (DBeaver, TablePlus)

Contractors rarely interact with databases solely via terminal sessions; they rely on desktop GUIs like DBeaver, TablePlus, or pgAdmin. Because an IAM token expires 15 minutes after generation, static password fields in these tools fail on reconnects.

To configure a client like DBeaver for ongoing use:

  1. Set the connection authentication type to AWS IAM Authentication (natively supported in DBeaver EE and modern extensions).
  2. Supply the contractor's temporary AWS credentials (access key, secret key, and session token) via the AWS credentials profile selector.
  3. Download and install the Amazon RDS SSL Root CA certificate bundle into the client truststore.
  4. Ensure SSL Mode is set to require or verify-full.

When configured correctly, the client software automatically generates a fresh IAM token via the AWS API each time a new database connection pool is established.

Network Isolation Patterns: Bastions, SSM Session Manager, and RDS Proxy

Identity authentication forms only one half of secure access. The second half is network-level containment. Placing production RDS instances inside public subnets—even when protected by database passwords—exposes your database ports to automated internet scanning, credential stuffing, and unpatched zero-day vulnerabilities.

Isolating RDS in Private VPC Subnets

All production RDS instances must reside exclusively within private VPC subnets with PubliclyAccessible set to false. Route tables for these subnets must lack internet gateway routes. Direct ingress should be restricted through security group rules to only authorized application tiers, proxies, or dedicated administrative endpoints.

Eliminating Bastion Hosts via AWS SSM Session Manager

Historically, connecting remote developers to private subnets required managing an SSH bastion host (jump box). Bastions carry severe administrative overhead: engineers must provision SSH keys, rotate keypairs, patch underlying Linux operating systems, and expose SSH port 22 to the public internet.

Modern engineering teams eliminate SSH keys entirely using AWS Systems Manager (SSM) Session Manager port forwarding. An internal EC2 instance or managed container acts as an SSM endpoint inside your private subnet. The contractor rarely connects via SSH and requires no open inbound ports on the security group.

The contractor initiates an encrypted port-forwarding tunnel through the AWS CLI:

aws ssm start-session \
    --target i-0123456789abcdef0 \
    --document-name AWS-StartPortForwardingSessionToRemoteHost \
    --parameters '{"host":["prod-postgresql-primary.c12345678901.us-east-1.rds.amazonaws.com"],"portNumber":["5432"],"localPortNumber":["5432"]}'

Once active, the contractor points their local database client to localhost:5432, feeding their 15-minute IAM auth token as the password. All traffic is securely tunneled over encrypted HTTPS WebSockets managed by AWS SSM APIs, with every session initialization logged in AWS CloudTrail.

Protecting Database Health with Amazon RDS Proxy

External contractors running analytical queries, query optimization tools, or schema inspections can unintentionally flood a database with unpooled connections. Deploying Amazon RDS Proxy between the contractor tunnel and your database cluster provides three critical safeguards:

  • Connection Pooling: RDS Proxy pools and shares database connections, shielding production databases from memory exhaustion caused by rogue contractor scripts or poorly configured client pooling.
  • Enforced Encryption: RDS Proxy enforces TLS 1.2 or 1.3 encryption across all inbound sessions, rejecting unencrypted client handshakes automatically.
  • Granular Endpoint Routing: You can configure dedicated read-only proxy endpoints mapped to RDS Read Replicas, physically preventing contractors from issuing accidental write transactions against your primary writer instance.

Automating Lifecycle Controls: Contractor Access Management for AWS RDS in Practice

Configuring IAM authentication and SSM tunnels solves credential hygiene, but human operational overhead remains a major failure point. Ops managers must still manually provision IAM policies, remember contract end dates, and execute offboarding scripts when sprints finish. Without automated governance, temporary contractor permissions inevitably become permanent dangling access.

Effective contractor access management for aws rds combines cloud-native identity controls with automated lifecycle management. Instead of relying on calendar reminders or shared spreadsheets, organizations use purpose-built tooling to govern the lifecycle of temporary permissions.

Organizations simplify this workflow by utilizing contractor access management tools like Tempkey alongside AWS IAM. Tempkey natively enforces access on 10 providers — Slack, Google Workspace, Microsoft 365, GitHub, GitLab, Zoom, AWS IAM, Figma, Dropbox, and Asana. Instead of manually manipulating IAM policies each time a contractor joins or departs, administrators define calendar-based access windows with predetermined expiration dates.

When provisioning external developers, you configure temporary AWS IAM access mapped strictly to their database role. Through Tempkey's native cloud integrations, the granting and revoking of IAM privileges execute on a scheduled, time-bounded basis. Provider admin tokens are write-only in the browser and encrypted at rest using AWS KMS in production; they are never displayed again after submission.

Crucially, effective offboarding requires automated confirmation. Tempkey executes revocation and reads provider state back to confirm it. Because revocation depends on third-party provider APIs, Tempkey does not guarantee removal within any specific time and surfaces failed or unenforceable revokes in the audit log. This programmatic verification ensures that when a contractor's project window closes, their underlying IAM authorization is actively checked, preventing lingering access paths from escaping administrative oversight.

For organizations operating under structured offboarding requirements, Tempkey gives you an exportable, append-only audit trail to support your own compliance and offboarding records. Tempkey does not hold SOC 2, ISO 27001, HIPAA, or PCI certification. By capturing exact grant, expiration, and revocation verification events, your operations team maintains verifiable evidence of credential termination without maintaining complex manual tracking documents.

Operational Pitfalls: Schema Migrations, Long-Running Queries, and Dangling Grants

Implementing ephemeral database access introduces architectural edge cases that every engineering lead must anticipate. Managing contractor sessions requires understanding how database connection lifecycles interact with authentication tokens.

Pitfall 1: Misunderstanding Token Lifespans vs. Active Sessions

The single most common misconception regarding IAM database authentication is the belief that an active database session terminates automatically after 15 minutes. The 15-minute IAM token lifespan applies exclusively to connection establishment.

Once a PostgreSQL or MySQL client successfully authenticates and establishes a TCP session, that session can remain connected indefinitely unless the database server intervenes. If a contractor generates a token, connects at 9:00 AM, and keeps their client session open, they can continue executing queries at 5:00 PM, long after their IAM authorization has expired. To prevent unmonitored persistent sessions, implement strict server-side connection timeouts:

PostgreSQL Configuration (postgresql.conf or RDS Parameter Group):

-- Terminate connections idle for more than 30 minutes
idle_session_timeout = '1800000'

-- Terminate queries running longer than 15 minutes
statement_timeout = '900000'

-- Terminate transactions left in an idle state for more than 5 minutes
idle_in_transaction_session_timeout = '300000'

MySQL Configuration (RDS Parameter Group):

-- Terminate interactive sessions idle for more than 30 minutes (1800 seconds)
interactive_timeout = 1800

-- Terminate non-interactive sessions idle for more than 30 minutes
wait_timeout = 1800

-- Terminate queries executing longer than 15 minutes
max_execution_time = 900000

Additionally, when terminating a contractor's access, administrators should run an active session purge alongside IAM policy detachment:

-- PostgreSQL: Terminate all active sessions for contractor_alex
SELECT pg_terminate_backend(pid) 
FROM pg_stat_activity 
WHERE usename = 'contractor_alex';

Pitfall 2: Bulk Data Exfiltration Risks

Freelancers debugging performance issues often attempt to dump entire tables to their local machines to run profilers or local test suites. This poses significant compliance and data governance risks. Mitigate exfiltration attempts by restricting bulk operations:

  • Row Limits via Proxy: Restrict max result sets using intermediary database proxies or application-tier gateways.
  • Disable File Export Privileges: In MySQL, ensure contractors lack the FILE privilege, preventing SELECT ... INTO OUTFILE operations.
  • Column-Level Permissions: If contractors only need to optimize queries on indexing structures, mask or revoke access to personally identifiable information (PII) columns:
    REVOKE SELECT (ssn, credit_card, password_hash) ON users FROM contractor_alex;

Pitfall 3: Direct Primary Database Access vs. Read Replicas

Contractors should rarely touch a production primary writer instance unless performing approved, monitored schema migrations. Route all diagnostics, slow query tuning, and index analysis to an Amazon RDS Read Replica. Read replicas shield your primary transaction processing engine from locking operations, expensive sequential scans, and connection saturation caused by external debugging.

Auditing, Offboarding Verification, and Compliance Recordkeeping

Demonstrating security governance requires transparent, continuous auditing across both the cloud control plane and the relational database engine. Auditing external contractor database activity requires capturing two distinct telemetry streams: authorization events and execution logs.

Tracking Authorization in AWS CloudTrail

Every time a contractor requests an authentication token or establishes an SSM tunnel session, AWS records the API invocation in AWS CloudTrail. Monitor these specific API events:

  • rds-db:connect: Indicates an attempt to generate a database authorization token for a specific database user and resource ID.
  • ssm:StartSession: Tracks the initialization of port-forwarding tunnels through SSM Session Manager.
  • iam:AttachUserPolicy / iam:DetachRolePolicy: Captures the provisioning and deprovisioning of underlying cloud IAM access paths.

Capturing Query Telemetry with Database Audit Plugins

CloudTrail logs confirm who obtained credentials, but they do not record what queries were executed inside the database engine. To achieve complete observability, enable native database audit extensions.

For RDS PostgreSQL: The pgaudit Extension
Configure the pgaudit extension inside your custom RDS parameter group to log all statements executed by contractor roles:

shared_preload_libraries = 'pgaudit'
pgaudit.role = 'contractor_alex'
pgaudit.log = 'all'
pgaudit.log_catalog = off
pgaudit.log_relation = on
pgaudit.log_statement_once = on

Export these logs directly to Amazon CloudWatch Logs. Using CloudWatch Metric Filters, you can configure immediate alerts if a contractor account issues high-risk DDL statements (e.g., DROP, TRUNCATE, ALTER) or attempts to access restricted sensitive tables.

For RDS MySQL: The MariaDB Audit Plugin
Enable the MariaDB Audit Plugin on your RDS MySQL instance via the RDS Option Group:

SERVER_AUDIT_EVENTS = 'CONNECT,QUERY'
SERVER_AUDIT_INCL_USERS = 'contractor_alex'
SERVER_AUDIT_EXCL_USERS = 'app_runtime,rdsadmin'

Standardized Contractor Offboarding Checklist

To eliminate lingering database access paths, execute this structured checklist whenever an external developer completes an engagement:

  1. Cloud IAM Detachment: Detach all IAM policies granting rds-db:connect and SSM port-forwarding rights, or verify that automated tools have scheduled their expiration.
  2. Active Session Termination: Terminate any established connections running under the contractor's database username using pg_terminate_backend (PostgreSQL) or KILL (MySQL).
  3. Database Role Locking: Revoke connection privileges at the engine level:
    -- PostgreSQL
    ALTER USER contractor_alex NOLOGIN;
    
    -- MySQL
    ALTER USER 'contractor_alex'@'%' ACCOUNT LOCK;
  4. State Read-Back Verification: Query cloud provider APIs and database system catalogs to confirm that IAM policies are detached, security group rules are closed, and database accounts are locked.
  5. Audit Log Archival: Export and archive CloudTrail session logs and database query logs associated with the contractor's username to satisfy external review and offboarding records.

Teams evaluating administrative overhead often review pricing and deployment options to weigh the operational cost of managing manual offboarding checklists against automated solutions. Automated verification provides an operational safety net, ensuring dangling credentials are identified and recorded immediately.

Frequently Asked Questions

Can external contractors connect to AWS RDS without having an AWS console login?

Yes. External contractors do not require access to the AWS Management Console to authenticate to an RDS instance using IAM authentication. Administrators can provision programmatic-only IAM users or federated roles accessible via the AWS CLI or custom scripts. By granting access strictly through IAM API keys or temporary STS credentials, contractors can generate database auth tokens and initiate SSM port-forwarding sessions entirely from their local terminal, rarely accessing the AWS web console.

How does IAM database authentication work with third-party database GUI clients?

Third-party database GUIs (like DBeaver, pgAdmin, and TablePlus) connect by substituting the static database password with a short-lived IAM authentication token. Tools with native AWS RDS integration, such as DBeaver, can generate these tokens automatically using underlying AWS CLI credential profiles. For tools without native AWS IAM support, developers use an external terminal script to generate a token via the AWS CLI (aws rds generate-db-auth-token) and paste that string into the standard password field before connecting. Because tokens are valid for 15 minutes, connection pooling or reconnect extensions are recommended for sustained GUI sessions.

What happens to an active contractor database session when an IAM token expires?

An IAM authentication token is evaluated solely at the moment of connection establishment. When the 15-minute token lifetime expires, an already-connected database session remains open and fully functional. The database engine does not disconnect established TCP sockets simply because the initial authentication token has expired. To prevent contractors from maintaining connections indefinitely, engineering teams must configure server-side parameters such as idle_session_timeout in PostgreSQL or wait_timeout in MySQL, or manually terminate active sessions using database administration commands when offboarding.

How do you revoke AWS RDS access instantly if a freelancer contract ends early?

To revoke RDS access immediately, you must act at both the cloud IAM layer and the active session layer. First, detach or delete the IAM policy granting the contractor rds-db:connect and AWS SSM session permissions; this prevents the contractor from generating any new authentication tokens. Second, run an administrative query inside your database engine to terminate all active sessions open under that contractor's username (such as executing SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE usename = 'contractor_user'; in PostgreSQL). Finally, lock the database user account to block any residual connection attempts.

Stop circulating database passwords in team chats. Connect Tempkey to your AWS IAM setup to provision time-bounded database access for contractors and automatically verify revocations when projects wrap up.