# 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.
