AWS RDS
Common Fate’s AWS RDS integration allows your end users to request Just-In-Time (JIT) access to RDS databases, leveraging AWS SSM to connect via the Common Fate AWS Proxy service deployed to ECS in your account. The proxy service captures audit logs of all SQL commands executed by the user during their session which can be viewed in real-time.
This guide will walk you through integrating Common Fate with AWS RDS. By the end of this guide, you’ll have a functioning integration with Common Fate with Databases available for access.
Prerequisites
You’ll need to have set up the Common Fate AWS integration before adding AWS RDS. You’ll also need to be using the Common Fate Terraform Provider v2.22+.
The AWS RDS integration creates temporary Permission Sets in IAM Identity Center allowing users to connect over AWS SSM Session Manager. In order to provision these Permission Sets, the Common Fate AWS integration IAM roles need some additional permissions.
To add these permissions using our Terraform module, ensure that the permit_provision_permission_sets
variable is set to true
in the Terraform module:
AWS RDS Overview
When a user requests access to a database in Common Fate, the provisioner creates a Permission Set in IAM Identity Center with the name set to the grant ID. This Permission Set is assigned to the user and the Account containing the Proxy. The Permission Set grants the user access to connect to the proxy using SSM StartSession for the AWS-StartPortForwardingSession document only.
The user then uses the Granted CLI granted rds proxy
to begin port-forwarding the database to their local machine.
Audit Logging Queries
The Common Fate RDS Proxy handles MySQL and Postgres connections at the wire protocol level. The proxy acts as a database server to the database client, and forwards commands to the target database after logging the queries to the session logs in Common Fate for the Grant.
Deploying the Proxy
The proxy module is deployed into the account containing the target RDS instances.
To deploy and register the proxy with Common Fate use our commmon-fate-proxy-ecs module which will handle deploying the ECS task and networking. Below is an example using the module.
To expose a database to Common Fate, you will need to register them with our proxy-resource-aws-rds Terraform module. Some examples have been provided below for configuring a mysql and postgres database. The username field should match a user that exists in the database, you can consider creating a read only user in your database to limit the actions that can be taken while connected to the database.
The common-fate/proxy-resource-aws-rds/commonfate module creates the necessary IAM policies to allow the proxy service to read the database secrets from Secrets Manager. This module also creates a security group rule allowing the proxy to access the database.
The AWS Secrets Manager secret value referenced by password_secrets_manager_arn
must be a key/value pair containing a password
key. For example, the following secret in JSON format is valid:
Secrets managed by AWS RDS follow this format automatically.
Endpoint overrides
Common Fate will use the default endpoint pulled using the aws_db_instance data source.
Sometimes it may be necessary to connect using a different endpoint than the default configured in the database module above. To solve this the database users
configuration has an optional endpoint
field which can be used to override the endpoint specified in the module.
This can be used to strictly specify reader and writer endpoints for Aurora RDS instances.
Configuring Common Fate
In this section, you will add selectors and availabilities so that users can request access to the databases. You’ll need to have set up the Common Fate Application Configuration repository using our Terraform provider.
You can create an access workflow, or use an existing one.
Now create a commonfate_aws_rds_database_availability. This resources make a single database and user available to request:
Connecting to a Database
Users connect to a database using Granted CLI.
Select a database
Connect your database client
The CLI will provide the connection information, these are stable between grants for the same database and role.
Updating the Proxy
When you update your Proxy deployment in ECS, a container restart may be required. In this case, all active connections to the database will be terminated.