common-fate / granted

The easiest way to access your cloud.
https://granted.dev
MIT License
1.06k stars 93 forks source link

Default AWS profile's s3 configuration is reformatted when using `granted registry sync` #502

Closed shwethaumashanker closed 12 months ago

shwethaumashanker commented 1 year ago

Context from slack message:

emuller: Hi Granted team,

I recently ran into an issue and wanted to reach out to see if I might be doing something wrong, or if this is, in fact, a bug. My default AWS profile has some S3 configuration options set, and that default profile is not being managed by Granted Registry, but the rest of my AWS config file is. When Granted Registry sync runs and replaces the managed section, it also reformats the default profile's S3 configuration and removes some whitespace, which makes the configuration invalid. I believe this is related to the S3 configuration syntax being non-standard.

Before Granted Registry sync:

max_concurrent_requests = 100
max_queue_size = 10000

After:

s3 =
max_concurrent_requests = 100
max_queue_size = 10000

Steps to reproduce - assuming you have a registry setup and it doesn't manage the default profile in ~/.aws/config.

aws configure set s3.max_concurrent_requests 100 --profile=default
aws configure set s3.max_queue_size 1000 --profile=default
granted registry sync

Afterwards, AWS CLI commands fail with an error message like this:

'str' object has no attribute 'get'

I believe this is because the AWS CLI is expecting the S3 configuration to deserialize into a Python dictionary, and without the indentation, it is deserializing into an empty string.