What We’re Building
In production cross-account setups:- Account A hosts Bytebase on an EC2 instance
- Account B hosts the RDS database
- Bytebase assumes a role in Account B to access the database
- Role 1:
bytebase-instance-role(simulates Account A’s EC2 role) - Role 2:
bytebase-target-db-role(simulates Account B’s database access role)
Prerequisites
- An EC2 instance where Bytebase will run
- An RDS instance with IAM authentication enabled
- IAM admin permissions to create roles and policies
Step 1: Set Up the EC2 Instance Role
This role will be attached to your EC2 instance running Bytebase.Create the Role
- Go to IAM Console → Roles
- Click Create role
- Choose trusted entity:
- Select AWS service
- Choose EC2
- Click Next
- Skip policy attachment for now (we’ll add it later)
- Name the role:
bytebase-instance-role - Click Create role
Attach Role to EC2
For a new EC2 instance:- During launch, in Advanced details → IAM instance profile, select
bytebase-instance-role
- Select your instance in the EC2 Console
- Click Actions → Security → Modify IAM role
- Select
bytebase-instance-role - Click Update IAM role
Step 2: Create the Database Access Role
This role will have permission to connect to your RDS database. In production, this would be in a different account.Create the Role with Trust Policy
- In IAM Console, click Create role
- Select Custom trust policy
-
Replace the default policy with this (substitute your account ID):
This trust policy allows
bytebase-instance-roleto assume this role. In production, the Principal would reference a role from a different account. - Click Next
- Skip policy attachment (we’ll add inline policy next)
-
Name the role:
bytebase-target-db-role - Click Create role
Add RDS Connect Permission
-
Open the newly created
bytebase-target-db-role - Go to the Permissions tab
- Click Add permissions → Create inline policy
-
Switch to JSON view and paste:
For production, replace wildcards with specific values:
arn:aws:rds-db:REGION:ACCOUNT_ID:dbuser:DB_RESOURCE_ID/bytebaseFind your DB_RESOURCE_ID in RDS Console → your database → Configuration tab - Click Review policy
-
Name it:
RDSConnect - Click Create policy
Step 3: Allow the EC2 Role to Assume the Database Role
Now we need to give the EC2 role permission to assume the database role.-
Go back to the
bytebase-instance-rolein IAM Console - Click Add permissions → Create inline policy
-
Switch to JSON view and paste (substitute your account ID):
- Click Review policy
-
Name it:
AssumeTargetRole - Click Create policy
Step 4: Configure the Database
Your RDS instance needs:- IAM authentication enabled (check in RDS Console → Modify → Database authentication options)
- A database user configured for IAM auth
Create the IAM Database User
Connect to your RDS instance using your master credentials, then run: For PostgreSQL:Step 5: Configure Bytebase Connection
Now configure Bytebase to use the cross-account authentication:- Open Bytebase and click New Instance
-
Configure basic connection:
- Host: Your RDS endpoint (e.g.,
mydb.abc123.us-east-1.rds.amazonaws.com) - Port: 5432 (PostgreSQL) or 3306 (MySQL)
- Username:
bytebase - Authentication: Select
AWS RDS IAM
- Host: Your RDS endpoint (e.g.,
-
Configure AWS credentials:
- Credential Source: Select Specific Credentials
- Access Key ID: Leave empty (uses EC2 instance profile)
- Secret Access Key: Leave empty (uses EC2 instance profile)
- Session Token: Leave empty
- Role ARN:
arn:aws:iam::YOUR_ACCOUNT_ID:role/bytebase-target-db-role - Database Region: Select your RDS region
- Database: Your database name
- Click Test Connection to verify the setup
- If successful, click Create

