All Tools View Categories About Contact Privacy

Cross-Account ARN Generator

Swap the account id in an ARN while keeping everything else exactly the same.

Runs entirely in your browser — both account ids stay on this page.

About Cross-Account ARN Generator

Moving a resource reference from one AWS account to another on paper — updating a cross-account trust policy, rewriting a Terraform variable, copying an example into a different environment’s runbook — usually means retyping an ARN by hand and hoping the account id is the only thing that changed. Cross-Account ARN Generator does that substitution mechanically: give it a source ARN and a target 12-digit account id, and it rebuilds the ARN with only the account field swapped, leaving the partition, service, region, resource type and resource id exactly as they were.

The swap works by parsing the source ARN with the same field-splitting logic used across these ARN tools — the fixed header up to the fifth colon becomes partition, service, region and account, and everything after that is the resource, split into a resource type and resource id on whichever of / or : appears first. Only the account field from that breakdown is replaced; the resource type, resource id, and the separator between them are carried over unchanged, so a Lambda alias like function:my-func:PROD or a nested IAM role path like role/service-role/my-role survives the swap intact rather than getting mangled by a naive find-and-replace on the account digits.

Because a wrong or malformed account id defeats the entire point of the tool, the target account id is checked before anything is generated: it must be exactly 12 digits, the shape every real AWS account id has. Typing anything else — too few digits, letters, a placeholder like XXXXXXXXXXXX — produces a specific error naming what was typed, rather than silently building an ARN with a bogus account segment.

Not every ARN has an account field to begin with. S3 bucket ARNs are the clearest example — arn:aws:s3:::my-bucket has nothing between its fourth and fifth colons, because S3 bucket names are globally unique and AWS does not scope them by account in the ARN itself. IAM ARNs likewise sometimes carry no region. Rather than fabricating an account segment where none belongs, or silently producing an ARN that looks plausible but is not what a cross-account swap should mean for that service, the tool detects the empty account field and explains directly that a swap is not applicable here and why — so you are not misled into thinking the resulting ARN reflects a real per-account resource when it does not.

The result is shown as a before/after comparison: the parsed source ARN, the target and source account ids side by side, and the newly built ARN string with a one-click copy. This is deliberately a narrow, mechanical tool — it does not check whether the target account exists, whether you have access to it, or whether the resource actually exists there, since none of that is knowable without contacting AWS, which this page never does. What it does guarantee is that the only thing changed between the source and result ARNs is the account id, everything else is preserved exactly, and any case where that guarantee cannot hold — a malformed source, an invalid target, or an ARN with no account segment — is called out explicitly instead of producing a silently wrong answer.

Everything runs client-side. Given that both the source ARN and the target account id here are frequently real AWS account numbers, nothing you type is ever sent anywhere.

Features

  • Account-only substitution — partition, service, region, resource type and resource id are all preserved unchanged.
  • 12-digit target validation — the exact shape AWS requires for account ids, checked before generating anything.
  • No-op detection for ARNs with an empty account field (e.g. S3), with a plain-language explanation instead of a silently wrong result.
  • Malformed source ARN detection, reusing the shared ARN parser’s specific error messages.
  • Resource id fidelity — multi-segment resource ids (Lambda aliases, nested IAM role paths, S3 object keys) survive the swap intact.
  • Before/after comparison panel showing source and target accounts and the generated ARN.
  • Copy the generated ARN with one click.
  • Sample data and one-click clear.
  • 100% client-side — nothing is uploaded, ever.

How to Use

  1. Paste the source ARN into the input box, or click Load sample.
  2. Type the target account id — exactly 12 digits, no dashes or spaces.
  3. Click Generate.
  4. Read the before/after panel — the source ARN, the target account, and the newly built ARN.
  5. If it can’t swap, read why — a bad target account id, a malformed source ARN, or a source ARN with no account field to replace.
  6. Copy the generated ARN for use in a policy, script, or runbook.

Examples

Example 1 — IAM role, straightforward swap. Source arn:aws:iam::123456789012:role/my-role with target account 999988887777 produces arn:aws:iam::999988887777:role/my-role.

Example 2 — Lambda alias preserved. Source arn:aws:lambda:eu-west-1:123456789012:function:my-func:PROD with target 111122223333 produces arn:aws:lambda:eu-west-1:111122223333:function:my-func:PROD — the :PROD alias suffix is untouched.

Example 3 — invalid target account. Typing 12345 as the target account for any source ARN produces an error stating the id must be exactly 12 digits.

Example 4 — S3 ARN, no account field to swap. Source arn:aws:s3:::my-bucket/key.txt with any target account produces an explanation that this ARN has no account segment, so a swap is not applicable — not a fabricated result.

Example 5 — malformed source. Pasting arn:aws:s3 as the source produces the parser’s specific error (too few colon-separated fields) instead of attempting a swap.

Benefits

  • No manual retyping — the resource part of the ARN is never touched by hand.
  • Guards against a bad target account id before anything is generated.
  • Never fabricates an account segment where the ARN legitimately has none.
  • Preserves multi-part resource ids exactly, including aliases and nested paths.
  • Clear before/after view for reviewing a swap before pasting it into a policy.
  • Private — both account ids involved stay in your browser.

Frequently Asked Questions

What does this tool actually do?
It takes one ARN and a target 12-digit AWS account id, and rebuilds the ARN with only the account field replaced — partition, service, region, resource type, and resource id are all carried over unchanged. It is meant for moving a resource identifier between accounts on paper (a cross-account IAM policy, a Terraform variable, a runbook) without retyping the whole ARN by hand.
Does it check that the target account actually exists or owns the resource?
No — it cannot, since it never contacts AWS. It only checks that the target account id you typed is exactly 12 digits, which is the shape every real AWS account id has. Whether that account is real, and whether the resource actually exists there, is on you to verify.
What happens if I paste an ARN whose account field is already empty, like an S3 bucket ARN?
S3 bucket ARNs (and a few other resource types) legitimately have no account segment — <code>arn:aws:s3:::my-bucket</code> has nothing between the fourth and fifth colons. Since there is no account field to replace, the tool refuses to silently fabricate one and instead explains that a swap is not applicable for this ARN, rather than producing a technically-valid-looking but meaningless result.
What if the target account id I type is not 12 digits?
You get a specific error stating the id must be exactly 12 digits, quoting what you typed — no ARN is generated from an invalid target.
What if the ARN I paste is malformed?
The source ARN is parsed first; if it does not meet the minimum ARN shape (starts with <code>arn:</code>, at least 6 colon-separated fields) you get the parser’s specific error and no swap is attempted.
Does it preserve resource ids that contain colons or slashes, like a Lambda alias or an S3 key?
Yes — the resource type and resource id (and the separator between them, <code>/</code> or <code>:</code>) are carried over exactly as parsed from the source ARN, so <code>function:my-func:PROD</code> or <code>role/service-role/my-role</code> stay intact with only the account changed.
Can I see the before and after side by side?
Yes, a before/after panel shows the parsed source ARN and the generated ARN, plus the specific account ids being swapped.
Can I copy the generated ARN?
Yes, a Copy button copies the resulting ARN string once a valid swap has been generated.
Does this validate the new account id’s format the same way the ARN Parser does?
It checks the exact-12-digits rule, which is the account id format AWS enforces everywhere. It does not re-run the ARN Parser’s broader validation (partition/region/service checks) on the result, since those fields are unchanged from the source ARN.
Is my ARN or account id sent anywhere?
No. Everything runs locally in your browser with no network requests, which matters since both the source and target values here are real AWS account ids.