Describe the bug
The aws-cli command:
aws configure set ... -profile SomeNewProfileNameHere
creates a new profile if the specified profile "SomeNewProfileNameHere" doesn't exist.
The problem is that if the file ends without a new-line, the command will append the new profile right after the last character in the file breaking the credentials configuration file.
Expected Behavior
The aws configure set command should add a new line if required so that it doesn't break the config file.
Current Behavior
The aws configure set command is appending blindly the new profile at the end of the file without adding a new line.
Reproduction Steps
Start with a config file like this: \.aws\credentials:
[default]
region=eu-west-1
[OtherProfile]
region=eu-west-1
after running:
aws configure set aws_secret_access_key 12345 --profile SomeNewProfileNameHere
[default]
region=eu-west-1
[OtherProfile]
region=eu-west-1[SomeNewProfileNameHere]
aws_secret_access_key = 12345
Which is invalid!
It should be:
[default]
region=eu-west-1
[OtherProfile]
region=eu-west-1
[SomeNewProfileNameHere]
aws_secret_access_key = 12345
Possible Solution
Add a new line always when adding a new profile to the credentials file.
Additional Information/Context
No response
CLI version used
aws-cli/2.4.25 Python/3.8.8 Windows/10 exe/AMD64 prompt/off
Environment details (OS name and version, etc.)
Windows/10 updated 2022-04-12
Describe the bug
The aws-cli command:
aws configure set ... -profile SomeNewProfileNameHerecreates a new profile if the specified profile "SomeNewProfileNameHere" doesn't exist.
The problem is that if the file ends without a new-line, the command will append the new profile right after the last character in the file breaking the credentials configuration file.
Expected Behavior
The
aws configure setcommand should add a new line if required so that it doesn't break the config file.Current Behavior
The
aws configure setcommand is appending blindly the new profile at the end of the file without adding a new line.Reproduction Steps
Start with a config file like this:
\.aws\credentials:after running:
aws configure set aws_secret_access_key 12345 --profile SomeNewProfileNameHereWhich is invalid!
It should be:
Possible Solution
Add a new line always when adding a new profile to the credentials file.
Additional Information/Context
No response
CLI version used
aws-cli/2.4.25 Python/3.8.8 Windows/10 exe/AMD64 prompt/off
Environment details (OS name and version, etc.)
Windows/10 updated 2022-04-12