How to set the default region in AWS CLI

Setting a default region in AWS CLI keeps routine commands pointed at the intended AWS endpoints without repeating --region on every request. That reduces mistakes when switching between regions, prevents resources from appearing to be missing, and keeps profile-backed automation aligned with the environment it is meant to target.

The AWS CLI stores the saved region in the shared config file for the active profile, usually ~/.aws/config on Linux and macOS or %USERPROFILE%\.aws\config on Windows. The aws configure set region <region-code> command writes that value locally, aws configure get region reads it back from the profile configuration, and aws configure list shows which source is currently providing the effective region setting.

The saved profile value is only the default. A one-off --region parameter overrides both the shared config file and any region environment variables for that single command, while AWS_REGION overrides AWS_DEFAULT_REGION and the profile setting for the current shell session. That makes aws configure list the safest final check when a stored value looks correct but commands still use a different region.

Steps to set the default region in AWS CLI:

  1. Confirm that the current shell can run AWS CLI commands.
    $ aws --version
  2. Check the currently saved region for the default profile before changing it.
    $ aws configure get region

    No output means the default profile does not have an explicit saved region yet.

  3. Save the new default region for the default profile.
    $ aws configure set region ap-southeast-1

    This writes region = ap-southeast-1 under the [default] section in ~/.aws/config and creates the shared config file if it does not exist yet.

  4. Read the saved value back from the default profile.
    $ aws configure get region
    ap-southeast-1

    aws configure get reads the stored profile value directly, so it is the cleanest check that the default profile was updated.

  5. Verify which source is currently supplying the effective region in the active shell.
    $ aws configure list
    NAME       : VALUE                    : TYPE             : LOCATION
    profile    : <not set>                : None             : None
    access_key : <not set>                : None             : None
    secret_key : <not set>                : None             : None
    region     : ap-southeast-1           : config-file      : ~/.aws/config

    If the TYPE column shows env instead of config-file, the current shell is overriding the saved default with AWS_REGION or AWS_DEFAULT_REGION. A --region parameter overrides both for a single command.

  6. Save a different default region for a named profile when separate accounts or environments need separate defaults.
    $ aws configure set region us-west-2 --profile audit

    This writes the setting under [profile audit] in the shared config file and leaves the [default] profile unchanged.

  7. Verify the named profile value directly.
    $ aws configure get region --profile audit
    us-west-2

    The --profile selector changes which section is read and written, so this confirms the named profile without depending on the global default.

  8. Inspect the shared config file when the stored profile sections need to be confirmed.
    $ sed -n '1,20p' ~/.aws/config
    [default]
    region = ap-southeast-1
    
    [profile audit]
    region = us-west-2

    The region belongs in ~/.aws/config, not in ~/.aws/credentials. On Windows, inspect %USERPROFILE%\.aws\config instead, or check AWS_CONFIG_FILE if the shell overrides the default path.