Skip to main content

MERGE TWO REPOSITORIES INTO A SHARED DATASTORE

This guide shows you how to merge two independent solo repositories into a shared datastore so they can reference each other's data.

Prerequisites

  • Two existing swamp repositories, each with its own data
  • An S3 or GCS bucket to serve as the shared backend (or a shared filesystem path)

Set up the shared backend

Create the S3 bucket if it does not exist. Then configure both repositories to use it.

In repository A:

$ swamp datastore setup extension @swamp/s3-datastore \
    --config '{"bucket":"shared-bucket","prefix":"swamp","region":"us-east-1"}'

This migrates repository A's existing local data to S3.

In repository B:

$ swamp datastore setup extension @swamp/s3-datastore \
    --skip-migration \
    --config '{"bucket":"shared-bucket","prefix":"swamp","region":"us-east-1"}'

Use --skip-migration for the second repository to avoid pushing its data before namespaces are assigned. Without namespaces, both repositories would write to the same top-level paths and overwrite each other.

Assign namespaces

In repository A:

$ swamp datastore namespace set infra
$ swamp datastore namespace migrate --confirm

In repository B:

$ swamp datastore namespace set compute
$ swamp datastore namespace migrate --confirm

Each repository's data is now scoped under its namespace.

Push repository B's data

Now that repository B has a namespace, push its local data to S3:

$ swamp datastore sync --push

Verify

From either repository:

$ swamp datastore namespace list

Both namespaces appear. Each repository can now reference the other's data using the namespace prefix syntax:

globalArguments:
  vpc_id: "${{ data.latest('infra:my-vpc', 'result').attributes.vpcId }}"