Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stable documented output formats #17

Closed
simonw opened this issue Nov 6, 2021 · 5 comments
Closed

Stable documented output formats #17

simonw opened this issue Nov 6, 2021 · 5 comments
Labels
enhancement New feature or request
Milestone

Comments

@simonw
Copy link
Owner

simonw commented Nov 6, 2021

Before 1.0 I want to have stable output formats - in particular for the create command.

I want to provide:

  • JSON (the current default is OK here)
  • INI style config that can be written to ~/.AWS
  • Shell syntax that sets environment variables
@simonw simonw added the enhancement New feature or request label Nov 6, 2021
@simonw simonw added this to the 1.0 milestone Nov 6, 2021
@simonw
Copy link
Owner Author

simonw commented Nov 9, 2021

Logging messages go to stderr, so even though they are displayed by default if the user does this it will work as expected:

% s3-credentials create hello-simon-world-bucket-2 --format ini --create-bucket > ini.txt
Created user: s3.read-write.hello-simon-world-bucket-2 with permissions boundary: arn:aws:iam::aws:policy/AmazonS3FullAccess
Attached policy s3.read-write.hello-simon-world-bucket-2 to user s3.read-write.hello-simon-world-bucket-2
Created access key for user: s3.read-write.hello-simon-world-bucket-2
% cat ini.txt 
aws_access_key_id=AKIAWXFXAIOZADC3B4RA
aws_secret_access_key=acdecuec/lfz56oo4jE2+glHJIAeKmhS3zgXUF2Nc9

simonw added a commit that referenced this issue Nov 9, 2021
@simonw
Copy link
Owner Author

simonw commented Nov 9, 2021

With ini in there I don't actually need the one that outputs shell environment variable syntax, because the ini format works for that already.

% source ini.txt 
% echo $aws_access_key_id
AKIAWXFXAIOZKGXI4PVO

@simonw simonw closed this as completed Nov 9, 2021
@simonw
Copy link
Owner Author

simonw commented Nov 10, 2021

% cat ini.txt 
aws_access_key_id=AKIAWXFXAIOZADC3B4RA
aws_secret_access_key=acdecuec/lfz56oo4jE2+glHJIAeKmhS3zgXUF2Nc9

It turns out this isn't actually a valid INI file - in as much as Python's configparser standard library module refuses to handle it because it's missing the header:

>>> p = configparser.ConfigParser()
>>> p.read("ini.txt")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/simon/.pyenv/versions/3.10.0/lib/python3.10/configparser.py", line 698, in read
    self._read(fp, filename)
  File "/Users/simon/.pyenv/versions/3.10.0/lib/python3.10/configparser.py", line 1086, in _read
    raise MissingSectionHeaderError(fpname, lineno, line)
configparser.MissingSectionHeaderError: File contains no section headers.
file: 'ini.txt', line: 1
'aws_access_key_id=AKIAWXFXAIOZKGXI4PVO\n'

@simonw simonw reopened this Nov 10, 2021
@simonw
Copy link
Owner Author

simonw commented Nov 10, 2021

On https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html#cli-configure-files-where the example uses a [default] section header in ~/.aws/credentials:

[default]
aws_access_key_id=AKIAIOSFODNN7EXAMPLE
aws_secret_access_key=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

This would break the source ini.txt trick from #17 (comment) so I maybe do need a --format env option for outputting environment variables.

@simonw simonw closed this as completed Nov 11, 2021
@simonw
Copy link
Owner Author

simonw commented Nov 11, 2021

I forgot to add --format ini support to --duration in #27.

@simonw simonw reopened this Nov 11, 2021
@simonw simonw closed this as completed in f444ef1 Nov 11, 2021
simonw added a commit that referenced this issue Nov 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant