aws / aws/aws-cli

configure set mishandles profile-prefixed dotted varnames (inconsistent with configure get)

Open
#10,313 1 comment 0 reactions 1 assignee Claimed by @RyanFitzSimmonsAK View on GitHub
bug configure investigating p2
Dominant language
Python
Stars
17.3k
Forks
4.6k
Avg merge
1d 2h
Merged PRs (30d)
13

Description

### Describe the bug

`aws configure get` and `aws configure set` parse profile-prefixed dotted varnames differently.

When using a varname like `emr-dev.emr.instance_profile`, where `emr-dev` is an existing profile in the config file, `configure get` reads the correct nested value from `[profile emr-dev]`. `configure set` does not apply the same logic and can write to the wrong section and key (for example `[default]` with `emr-dev = my_ip` instead of nested `emr.instance_profile` under `[profile emr-dev]`).

This makes set/get inconsistent and can silently corrupt or misplace configuration.

### Regression Issue

- [ ] Select this option if this issue appears to be a regression.

### Expected Behavior

`aws configure set` should accept the same profile-prefixed dotted varname syntax as `configure get`.

For example:

aws configure set emr-dev.emr.instance_profile my_ip

should write:

[profile emr-dev]
emr =
instance_profile = my_ip

and:

aws configure get emr-dev.emr.instance_profile

should return `my_ip`.

### Current Behavior

`configure set` treats the first segment as a config key name instead of a profile name when the varname has three or more dot-separated parts and does not use the `default.` or `profile.` prefix.

Example:

aws configure set emr-dev.emr.instance_profile my_ip

can result in:

[default]
emr-dev = my_ip

instead of the expected nested value under `[profile emr-dev]`.

No CLI error is shown; the command may exit successfully while writing the wrong config structure.

### Reproduction Steps

1. Create `~/.aws/config` (or set `AWS_CONFIG_FILE`) with:

[profile emr-dev]
region = us-west-1

2. Run:

aws configure set emr-dev.emr.instance_profile my_ip

3. Open the config file and inspect the result.

4. Run:

aws configure get emr-dev.emr.instance_profile

5. Compare with the working explicit form:

aws configure set profile.emr-dev.emr.instance_profile my_ip

or:

aws configure set emr.instance_profile my_ip --profile emr-dev

### Possible Solution

Mirror the profile detection logic from `awscli/customizations/configure/get.py` in `awscli/customizations/configure/set.py`.

When the first segment of a dotted varname is `default` or exists in `session.full_config['profiles']`, treat it as the profile name, then map remaining segments to the config key and nested value (same nesting depth as `configure set` already uses for `default.s3.signature_version` and `profile.foo.s3.signature_version`).

### Additional Information/Context

- Affects AWS CLI v1 `configure` customization only.
- `configure get` already implements this pattern (see `_get_dotted_config_value` in `get.py`).
- Workarounds: use `profile...` or set with `--profile` and a two-part varname (e.g. `emr.instance_profile`).
- Related component: `awscli/customizations/configure/set.py`

### CLI version used

aws-cli/1.45.8

### Environment details (OS name and version, etc.)

Windows 10/11 Python 3.x (bundled with CLI install method)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.