Skip to contentManaged Kafka is live: Apache Kafka on AWS for half the cost of MSK

Connection options

Connect through AWS VPC Lattice

In BYOC deployments, connect Artie to databases across AWS accounts and VPCs with VPC Lattice, without peering, NLBs or PrivateLink endpoint services.

VPC Lattice connections are in early access for bring your own cloud (BYOC) deployments. In these deployments, Artie runs in a dedicated AWS account and VPC that you provision. To enable VPC Lattice, contact Artie through Slack or email. For Artie-hosted data planes, use AWS PrivateLink.

How VPC Lattice works

In each VPC that contains a database, you create a resource gateway. You also create a resource configuration for each database you want Artie to replicate. You then share the resource configurations with your Artie account through AWS Resource Access Manager (RAM).

Artie creates a resource endpoint in the Artie VPC for each shared database and connects through it. Your VPCs need no VPC peering, Transit Gateway, or load balancer. The diagram shows one Artie account reaching databases in two workload accounts.

Workload account BWorkload account AArtie account (BYOC)VPC LatticeVPC LatticeVPC LatticeArtie data planeResource endpointResource endpointResource endpointResource gatewayResource gatewayDatabaseDatabaseDatabase

Connections only go one way. Artie opens connections to the hosts and ports in your resource configurations, and nothing else in your VPC is reachable. Your database sees traffic coming from the resource gateway’s private IP addresses inside its own VPC.

When to use VPC Lattice

The AWS Well-Architected Framework recommends separate AWS accounts for workloads and environments (best practice SEC01-BP01, Separate workloads using accounts). Accounts are a boundary for security, billing, and access. A BYOC deployment follows the same practice by running Artie in its own account. Your databases often end up spread across many other accounts, in VPCs that aren’t peered with each other or with the Artie VPC.

AWS PrivateLink needs an endpoint service and a Network Load Balancer (NLB) in every VPC that contains a database. VPC Lattice replaces those with a resource gateway and a resource configuration for each database. You deploy them the same way in every account.

Use VPC Lattice when:

  • Your databases are in AWS accounts other than your Artie account, or in VPCs that aren’t connected to the Artie VPC.
  • You want each workload account to control exactly which databases Artie reaches, through its own RAM share.
  • Your databases are on Amazon RDS or Aurora, and you want to connect with their RDS endpoint hostnames, with no NLB target groups to maintain.

VPC Lattice and PrivateLink work side by side. They are separate connection methods, and each pipeline uses one of them. For example, keep an existing PrivateLink connection for one database and use VPC Lattice for databases in other accounts.

Prerequisites

  • A BYOC deployment of Artie, and the account ID of your Artie account
  • Databases in the same AWS region as the Artie VPC
  • Permission to create VPC Lattice resource gateways, resource configurations, and AWS RAM resource shares in each workload account
  • A subnet in at least one of the Artie VPC’s availability zone IDs, in every VPC that contains a database

AWS RAM shares a resource only in the region where you created it, so the Artie VPC can reach only resource configurations in its own region. Contact Artie if your databases are in a different region.

Set up a VPC Lattice connection

Repeat steps 1 to 4 in each workload account that contains databases you want to replicate.

  1. Create a resource gateway

    In the AWS console, go to VPC > PrivateLink and Lattice > Resource gateways. Create a resource gateway in the VPC that contains your databases.

    Select subnets in as many availability zones as possible. Include at least one subnet in an availability zone ID that the Artie VPC also uses. VPC Lattice requires at least one shared availability zone. See Verify availability zone IDs overlap.

    Attach a security group that allows outbound TCP traffic to your databases on their ports, for example 5432 for PostgreSQL or 3306 for MySQL.

    Resource configurations in the same VPC can share one resource gateway. The exception is a resource gateway set to IN_VPC DNS resolution, which can’t have ARN resource configurations. See Check how the resource gateway resolves DNS.

  2. Allow the resource gateway in your database security group

    Add an inbound rule to each database’s security group. The rule allows TCP traffic on the database port from the resource gateway’s security group. Without this rule, connections from Artie time out.

  3. Create a resource configuration for each database

    Go to VPC > PrivateLink and Lattice > Resource configurations. Create one resource configuration for each database, associated with the resource gateway from step 1. The type depends on where the database runs:

    • Amazon RDS and Aurora: create an ARN resource configuration that identifies the database by its ARN.
    • Other databases, such as a self-managed database on EC2: create a single resource configuration with the database’s domain name or private IP address and port.

    For an ARN resource configuration, the database has to be private. VPC Lattice rejects a resource configuration for a publicly accessible database. Artie then connects with your usual RDS endpoint hostname.

    Artie connects through resource endpoints and doesn’t use service networks. Under Association settings, you can turn off association with shareable service networks.

  4. Share the resource configurations with your Artie account

    In the AWS RAM console, in the region of your Artie VPC, choose Create resource share. Add the resource configurations from step 3, and add your Artie account ID as a principal.

    Your Artie account gets access without an invitation when two things are true: it’s in your AWS organization, and sharing with AWS Organizations is turned on in RAM. Otherwise, the share has to allow principals outside your organization: Allow sharing with anyone in the console, or allow_external_principals = true in Terraform. Your Artie account then receives an invitation, and Artie accepts it.

  5. Send Artie the resource configuration ARNs

    Contact Artie through Slack or email. Send the ARN of each resource configuration and the database it represents.

    Artie creates a resource endpoint for each one in the Artie VPC and confirms when it is ready.

  6. Create your pipeline

    After Artie confirms the connection, create a pipeline in the dashboard. On How would you like to connect your source?, select Allowlist Artie IPs, then I’ve added Artie’s IPs. Artie then connects to the host you enter. Don’t select PrivateLink, because it replaces the host with the DNS name of an Artie PrivateLink connection.

    On the step where you enter your source credentials, enter the database hostname in Host. For ARN resource configurations, the hostname is your database’s RDS endpoint hostname. For other resource configurations, Artie sends you the hostname to use.

Example: Terraform for one workload account

If you manage many accounts, define these resources once. Deploy them to every workload account with Terraform or CloudFormation StackSets.

This example needs the AWS provider 5.85.0 or later. It shares one private RDS PostgreSQL instance with an Artie account in the same AWS organization, with sharing with AWS Organizations turned on in RAM.

HCL
terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = ">= 5.85.0"
    }
  }
}

data "aws_db_instance" "orders" {
  db_instance_identifier = "orders-prod"
}

resource "aws_security_group" "artie_resource_gateway" {
  name   = "artie-resource-gateway"
  vpc_id = "vpc-0a1b2c3d4e5f67890"

  egress {
    from_port   = 5432
    to_port     = 5432
    protocol    = "tcp"
    cidr_blocks = ["10.20.0.0/16"]
  }
}

# Allow the resource gateway to reach the database.
resource "aws_vpc_security_group_ingress_rule" "orders_from_artie" {
  security_group_id            = "sg-0d4c3b2a1f0e98765" # the database's security group
  referenced_security_group_id = aws_security_group.artie_resource_gateway.id
  ip_protocol                  = "tcp"
  from_port                    = 5432
  to_port                      = 5432
}

resource "aws_vpclattice_resource_gateway" "artie" {
  name               = "artie"
  vpc_id             = "vpc-0a1b2c3d4e5f67890"
  subnet_ids         = ["subnet-0aa11bb22cc33dd44", "subnet-0ee55ff66aa77bb88", "subnet-0cc99dd00ee11ff22"]
  security_group_ids = [aws_security_group.artie_resource_gateway.id]
}

resource "aws_vpclattice_resource_configuration" "orders" {
  name                                           = "artie-orders-prod"
  resource_gateway_identifier                    = aws_vpclattice_resource_gateway.artie.id
  type                                           = "ARN"
  allow_association_to_shareable_service_network = false

  resource_configuration_definition {
    arn_resource {
      arn = data.aws_db_instance.orders.db_instance_arn
    }
  }
}

resource "aws_ram_resource_share" "artie" {
  name                      = "artie"
  allow_external_principals = false # true unless your Artie account is in your AWS organization and RAM sharing with AWS Organizations is turned on
}

resource "aws_ram_resource_association" "orders" {
  resource_arn       = aws_vpclattice_resource_configuration.orders.arn
  resource_share_arn = aws_ram_resource_share.artie.arn
}

resource "aws_ram_principal_association" "artie" {
  principal          = "210987654321" # your Artie account
  resource_share_arn = aws_ram_resource_share.artie.arn
}

# Send these values to Artie.
output "artie_resource_share_arn" {
  description = "RAM resource share that contains the resource configurations"
  value       = aws_ram_resource_share.artie.arn
}

output "artie_resource_configurations" {
  description = "One entry per database: the resource configuration ARN and the hostname to use as the source address"
  value = {
    (aws_vpclattice_resource_configuration.orders.name) = {
      resource_configuration_arn = aws_vpclattice_resource_configuration.orders.arn
      hostname                   = data.aws_db_instance.orders.address
      port                       = data.aws_db_instance.orders.db_instance_port
    }
  }
}

After you run terraform apply, send Artie the artie_resource_share_arn and artie_resource_configurations values from terraform output -json.

Add a database to an existing connection

Create a resource configuration for the database, add it to your existing resource share, and send Artie its ARN. Artie adds a resource endpoint for it. The resource gateway stays unchanged unless the database is in a new VPC, or it’s an RDS database in a VPC whose resource gateway is set to IN_VPC DNS resolution.

Add a read replica for backfills

Create a resource configuration for the read replica, add it to the same resource share, and send Artie its ARN. In your source’s connection settings, turn on Use a read replica for backfill? and enter the replica’s hostname in Replica host. See Backfills for how Artie uses a read replica.

Troubleshooting

When a connection from Artie times out, work through these checks in order.

Verify availability zone IDs overlap

VPC Lattice requires at least one availability zone in common between the resource endpoint in the Artie VPC and your resource gateway.

Check both security groups

The resource gateway’s security group needs an outbound rule to the database port. The database’s security group needs an inbound rule from the resource gateway’s security group.

Your database sees connections coming from the resource gateway’s IP addresses, not from the Artie VPC. Rules that only allow the Artie VPC’s CIDR don’t match.

Check how the resource gateway resolves DNS

A single resource configuration can use a domain name that resolves through a Route 53 private hosted zone or your own DNS server. In that case, set the resource gateway’s Resource Config DNS Resolution to IN_VPC. You can change this setting after you create the resource gateway.

A resource gateway set to IN_VPC can’t have ARN resource configurations. Use a separate resource gateway for RDS databases in that VPC.

Billing

AWS bills each resource endpoint by the hour, plus a charge per GB of data processed, in your Artie account. See AWS PrivateLink pricing for the rates.

Each workload account also pays per GB of data processed by its resource gateway. See Amazon VPC Lattice pricing.

Was this page helpful?