Skip to content
Rowsafe
Docs
Connect a cloud account

Connect AWS

Give Rowsafe an IAM access key, limited to the servers it creates, so it can create database servers (EC2) in your AWS account.

To create servers for you in AWS, Rowsafe needs the access key of an IAM user with only the policy below. It takes about five minutes.

Create the user and its key

Choose the AWS account

Sign in to the AWS console. An AWS account just for these databases is the strongest separation (AWS Organizations creates one in a minute). Your usual account works too.

Create the policy

Open IAM, Policies, Create policy. On the JSON tab, paste the policy below, click Next, name it RowsafeServers and create it.

Create the user

In IAM, open Users, Create user. Name it rowsafe, no console access. Choose Attach policies directly, tick RowsafeServers, and finish.

Create an access key

Open the user, Security credentials, Create access key. Choose Third-party service, confirm and create it. Copy the access key ID and secret access key: AWS shows the secret only once.

Paste it into Rowsafe

In the dashboard, open Settings → Cloud accounts (or Create a server for me) and click Connect a cloud account. Choose Amazon Web Services (AWS), paste the Access key ID (starts with AKIA) and Secret access key, name the account and click Connect.

Rowsafe checks the key with a free "dry run": could it start a server, create a firewall and an address? Nothing is created. Your account's root key is refused.

What access this gives Rowsafe

The policy

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "RowsafeRead",
      "Effect": "Allow",
      "Action": [
        "ec2:DescribeInstances",
        "ec2:DescribeImages",
        "ec2:DescribeVpcs",
        "ec2:DescribeSecurityGroups",
        "ec2:DescribeKeyPairs",
        "ec2:DescribeAddresses"
      ],
      "Resource": "*"
    },
    {
      "Sid": "RowsafeCreate",
      "Effect": "Allow",
      "Action": [
        "ec2:RunInstances",
        "ec2:CreateSecurityGroup",
        "ec2:ImportKeyPair",
        "ec2:AllocateAddress"
      ],
      "Resource": "*"
    },
    {
      "Sid": "RowsafeTagOnCreate",
      "Effect": "Allow",
      "Action": "ec2:CreateTags",
      "Resource": "*",
      "Condition": {
        "StringEquals": {
          "ec2:CreateAction": ["RunInstances", "CreateSecurityGroup", "ImportKeyPair", "AllocateAddress"]
        }
      }
    },
    {
      "Sid": "RowsafeManageOwn",
      "Effect": "Allow",
      "Action": [
        "ec2:StartInstances",
        "ec2:StopInstances",
        "ec2:TerminateInstances",
        "ec2:ModifyInstanceAttribute",
        "ec2:AuthorizeSecurityGroupIngress",
        "ec2:RevokeSecurityGroupIngress",
        "ec2:DeleteSecurityGroup",
        "ec2:DeleteKeyPair",
        "ec2:AssociateAddress",
        "ec2:DisassociateAddress",
        "ec2:ReleaseAddress"
      ],
      "Resource": "*",
      "Condition": {
        "StringEquals": { "aws:ResourceTag/rowsafe": "1" }
      }
    }
  ]
}

In plain words, the key can:

  • see EC2 servers, images, networks, security groups, key pairs and addresses;
  • create servers, security groups, key pairs and Elastic IPs, tagging them as it creates them;
  • start, stop, resize, change the firewall of and delete only what is tagged rowsafe=1.

It can't touch IAM, S3, databases or anything else, or change servers it didn't tag. It could start new ones, which is why a separate AWS account is the strongest choice.

For each server, Rowsafe creates a Debian 12 instance with its disk, a security group letting in only your addresses, an Elastic IP, and a key pair only if you give your SSH key. Only when someone clicks and confirms. See what Rowsafe does with your cloud account.

For private connections (optional)

For Create the endpoint for me on a private connection, add these statements to RowsafeServers or as a second policy. The policy the dashboard shows already has them. Without them, everything else works and the dashboard shows the console steps instead.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "RowsafePrivateConnectionRead",
      "Effect": "Allow",
      "Action": ["ec2:DescribeVpcEndpoints", "ec2:DescribeVpcs", "ec2:DescribeSubnets", "ec2:DescribeSecurityGroups"],
      "Resource": "*"
    },
    {
      "Sid": "RowsafePrivateConnectionEndpoint",
      "Effect": "Allow",
      "Action": "ec2:CreateVpcEndpoint",
      "Resource": "arn:aws:ec2:*:*:vpc-endpoint/*",
      "Condition": { "StringEquals": { "aws:RequestTag/rowsafe": "1" } }
    },
    {
      "Sid": "RowsafePrivateConnectionEndpointUsing",
      "Effect": "Allow",
      "Action": "ec2:CreateVpcEndpoint",
      "Resource": [
        "arn:aws:ec2:*:*:vpc/*",
        "arn:aws:ec2:*:*:subnet/*",
        "arn:aws:ec2:*:*:security-group/*",
        "arn:aws:ec2:*:*:vpc-endpoint-service/*"
      ]
    },
    {
      "Sid": "RowsafePrivateConnectionFirewall",
      "Effect": "Allow",
      "Action": "ec2:CreateSecurityGroup",
      "Resource": ["arn:aws:ec2:*:*:security-group/*", "arn:aws:ec2:*:*:vpc/*"]
    },
    {
      "Sid": "RowsafePrivateConnectionTagOnCreate",
      "Effect": "Allow",
      "Action": "ec2:CreateTags",
      "Resource": "*",
      "Condition": { "StringEquals": { "ec2:CreateAction": ["CreateVpcEndpoint", "CreateSecurityGroup"] } }
    },
    {
      "Sid": "RowsafePrivateConnectionManageOwn",
      "Effect": "Allow",
      "Action": ["ec2:DeleteVpcEndpoints", "ec2:AuthorizeSecurityGroupIngress", "ec2:DeleteSecurityGroup"],
      "Resource": "*",
      "Condition": { "StringEquals": { "aws:ResourceTag/rowsafe": "1" } }
    },
    {
      "Sid": "RowsafePrivateConnectionFirewallRules",
      "Effect": "Allow",
      "Action": "ec2:AuthorizeSecurityGroupIngress",
      "Resource": "arn:aws:ec2:*:*:security-group-rule/*"
    }
  ]
}

In plain words: Rowsafe can create an endpoint and a security group tagged rowsafe=1 in a VPC you pick, open port 5432 to that VPC, and delete only what it tagged.

Revoke it

  • In AWS: IAM, Users, rowsafe, Security credentials: deactivate or delete the key. Or delete the user.
  • In Rowsafe: Settings → Cloud accounts, Remove (once its servers are deleted). Nothing in AWS changes.

Your servers keep running and stay protected. Resize, firewall changes and deletes then happen in the EC2 console.

Good to know

  • Prices are "about": estimates from AWS list prices for the server, its disk and its public IPv4 address. Your AWS bill is what counts.
  • Each region needs its default VPC. If you deleted it, the dashboard says how to recreate it.
  • AWS limits Elastic IPs (5 per region by default) and servers. If you hit a limit, ask for more in Service Quotas.
  • A server can only be resized to the same processor type (ARM or x86).
  • AWS accepts only RSA and Ed25519 SSH keys.
Edit on GitHub