Skip to content

Commit c286384

Browse files
docs: update LocalStack Replicator document to add support for batch replication (#184)
1 parent 3d90db6 commit c286384

File tree

1 file changed

+82
-13
lines changed

1 file changed

+82
-13
lines changed

src/content/docs/aws/tooling/aws-replicator.mdx

Lines changed: 82 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ If you have the AWS CLI v1 installed or no installation of the AWS CLI, the foll
6464
### Trigger a replication job
6565

6666
Replication jobs can be triggered using the LocalStack CLI or an HTTP API.
67+
6768
Both methods have two steps:
6869

6970
1. Submit a replication job.
@@ -72,10 +73,10 @@ Both methods have two steps:
7273
#### Using the LocalStack CLI
7374

7475
The Replicator CLI is part of the LocalStack CLI.
76+
7577
Follow the [installation instructions](/aws/getting-started/installation/#installing-localstack-cli) to set it up.
7678

77-
To start a replication job, get the ARN of the resource to replicate.
78-
Then, trigger the job using the command:
79+
To start a replication job, get the ARN of the resource to replicate. Then, trigger the job using the command:
7980

8081
```bash showLineNumbers
8182
export LOCALSTACK_AUTH_TOKEN=<auth token>
@@ -84,10 +85,10 @@ export AWS_DEFAULT_REGION=...
8485
# export AWS_ACCESS_KEY_ID=
8586
# export AWS_SECRET_ACCESS_KEY=
8687
localstack replicator start \
87-
--resource-type <resource-type> \
88-
--resource-identifier <identifier> \
89-
[--target-account-id <account-id>] \
90-
[--target-region-name <region-name>]
88+
--resource-type <resource-type> \
89+
--resource-identifier <identifier> \
90+
[--target-account-id <account-id>] \
91+
[--target-region-name <region-name>]
9192
```
9293

9394
:::note
@@ -98,8 +99,24 @@ localstack replicator start --resource-arn <resource-arn>
9899
```
99100
:::
100101

101-
This triggers the replication job.
102-
The output will look similar to:
102+
You can also trigger batch replication jobs using the `--replication-type BATCH` flag.
103+
104+
This currently supports the `AWS::SSM::Parameter` resource type and allows you to replicate all parameters under a given path prefix.
105+
106+
For example, to replicate all parameters under `/dev/`:
107+
108+
```bash
109+
localstack replicator start \
110+
--replication-type BATCH \
111+
--resource-type AWS::SSM::Parameter \
112+
--resource-identifier /dev/
113+
```
114+
115+
The `--resource-identifier` in this case must be a path prefix (not a wildcard or glob). All parameters under that prefix will be discovered and replicated.
116+
117+
If `--replication-type` is not specified, the default is `SINGLE_RESOURCE`.
118+
119+
The command triggers a replication job. The output will look similar to:
103120

104121
```json showLineNumbers
105122
{
@@ -112,18 +129,26 @@ The output will look similar to:
112129
"identifier": "myParameter"
113130
}
114131
}
115-
```
132+
```
116133

117134
:::note
118135
- `--target-account-id` specifies the destination AWS account for replication.
119136
If not set, the resource is replicated into account `000000000000`.
137+
120138
- `--target-region-name` specifies the destination AWS region.
121139
If not set, the resource is replicated into the default region from the provided credentials.
122140
:::
123141

142+
124143
#### Using the HTTP API
125144

126-
To trigger replication via the HTTP API, send a `POST` request to `http://localhost.localstack.cloud:4566/_localstack/replicator/jobs` with the following payload:
145+
To trigger replication via the HTTP API, send a `POST` request to:
146+
147+
```bash
148+
http://localhost.localstack.cloud:4566/_localstack/replicator/jobs
149+
```
150+
151+
Use the following payload:
127152

128153
```json showLineNumbers
129154
{
@@ -143,13 +168,36 @@ To trigger replication via the HTTP API, send a `POST` request to `http://localh
143168
}
144169
```
145170

171+
To replicate multiple SSM parameters under a shared path, you can use `replication_type: "BATCH"` with the same `resource_type` and a path-style `identifier`.
172+
173+
For example:
174+
175+
```json
176+
{
177+
"replication_type": "BATCH",
178+
"replication_job_config": {
179+
"resource_type": "AWS::SSM::Parameter",
180+
"identifier": "/dev/"
181+
},
182+
"source_aws_config": {
183+
"aws_access_key_id": "...",
184+
"aws_secret_access_key": "...",
185+
"region_name": "..."
186+
}
187+
}
188+
```
189+
190+
This triggers a batch replication job that discovers and replicates all SSM parameters under the `/dev/` path prefix.
191+
192+
146193
### Check Replication Job Status
147194

148195
Replication jobs run asynchronously, so you need to poll their status to check when they finish.
149196

150197
#### Using the LocalStack CLI
151198

152199
When creating a replication job, the response includes a `job_id`.
200+
153201
Use this ID to check the job status:
154202

155203
```bash
@@ -158,7 +206,7 @@ export LOCALSTACK_AUTH_TOKEN=<auth token>
158206
localstack replicator status <job-id>
159207
```
160208

161-
This command returns the job status in JSON format, for example:
209+
This command returns the job status in JSON format. For example, here's a single-resource replication job:
162210

163211
```json showLineNumbers
164212
{
@@ -173,8 +221,29 @@ This command returns the job status in JSON format, for example:
173221
}
174222
```
175223

176-
For long-running jobs, the CLI can poll the status until the job reaches a terminal state.
177-
To wait for the job to finish, use the `--follow` flag.
224+
For a batch replication job, the output may include additional fields indicating how many resources were successfully replicated or failed:
225+
226+
```json
227+
{
228+
"job_id": "9acdc850-f71b-4474-b138-1668eb8b8396",
229+
"state": "SUCCEEDED",
230+
"error_message": null,
231+
"type": "BATCH",
232+
"replication_config": {
233+
"resource_type": "AWS::SSM::Parameter",
234+
"identifier": "/dev/"
235+
},
236+
"result": {
237+
"resources_succeeded": 2,
238+
"resources_failed": 0
239+
}
240+
}
241+
```
242+
243+
Jobs of type `BATCH` may include a `result` object with `resources_succeeded` and `resources_failed` fields.
244+
245+
For long-running jobs, the CLI can poll the status until the job reaches a terminal state. To wait for the job to finish, use the `--follow` flag.
246+
178247

179248
#### Using the HTTP API
180249

0 commit comments

Comments
 (0)