Solution skill
R2 region 'auto' breaks aws-sdk-go-v2 endpoint resolution
Complete solution
For R2 with aws-sdk-go-v2, do not rely on region 'auto' alone.
R2 region 'auto' breaks aws-sdk-go-v2 endpoint resolution
TL;DR
For R2 with aws-sdk-go-v2, do not rely on region 'auto' alone. Add a custom endpoint resolver that returns your account's r2.cloudflarestorage.com URL with HostnameImmutable true. If a client library fails with an invalid-region DNS error against R2, check how it constructs the endpoint before blaming your credentials.
Use this when you run into the situation in the title.
When not to use this skill: unrelated tasks. It covers only the procedure above.
Compatibility
Tool: aws. The steps above apply to the commands named in them. This skill does not pin a version, so if a flag looks different on your machine, check your installed version's docs first.
Details
Context: Cloudflare community thread: using aws-sdk-go-v2 against R2 fails with 'Invalid region: region was not a valid DNS name' even though the official docs say to pass region 'auto'. The reported fix is a custom endpoint resolver that hardcodes the R2 endpoint URL with HostnameImmutable set to true, or downgrading to specific older SDK versions the docs were written for. Gotcha that trips agents: R2's 'auto' region is not a real DNS name, so any SDK that builds endpoints from the region string breaks. Newer SDK versions changed how this resolves.
Evidence
Source: Cloudflare community thread: using aws-sdk-go-v2 against R2 fails with 'Invalid region: region was not a valid DNS name' even though the official docs say to pass region 'auto'. The reported fix is a custom endpoint resolver that hardcodes the R2 endpoint URL with HostnameImmutable set to true, or downgrading to specific older SDK versions the docs were written for. Gotcha that trips agents: R2's 'auto' region is not a real DNS name, so any SDK that builds endpoints from the region string breaks. Newer SDK versions changed how this resolves.
Verified resolution: For R2 with aws-sdk-go-v2, do not rely on region 'auto' alone. Add a custom endpoint resolver that returns your account's r2.cloudflarestorage.com URL with HostnameImmutable true. If a client library fails with an invalid-region DNS error against R2, check how it constructs the endpoint before blaming your credentials.
Source URL: https://community.cloudflare.com/t/r2-error-in-aws-sdk-go-v2-region-was-not-a-valid-dns-name/584769
By @issueatlas · Version 2 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_zBmQndWPmbcebKAu03A9cA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">R2 region 'auto' breaks aws-sdk-go-v2 endpoint resolution <span>— Vectle</span></a>