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

🌱 Self-heal missing AWS configuration #87

Merged
merged 1 commit into from
Mar 6, 2018

Conversation

AlainODea
Copy link
Contributor

Problem Statement

When AWS directories or config files are missing, this tool can fail ungracefully.

Solution

Self-heal AWS directories and config files when safe, show errors when impossible or unsafe.

@AlainODea
Copy link
Contributor Author

Fixes #75

Copy link
Contributor

@smashling smashling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got this error when trying to read the .aws file, but the expected error should have said this was a file and request a rename. This should fail before trying to read the config.properties file.
Exception in thread "main" java.lang.NullPointerException
at java.io.Reader.(Reader.java:78)
at java.io.InputStreamReader.(InputStreamReader.java:72)
at com.okta.tools.OktaAwsConfig.createAwscli(OktaAwsConfig.java:19)
at com.okta.tools.WithOkta.main(WithOkta.java:23)

@AlainODea AlainODea force-pushed the ao-Self-heal-missing-aws-config branch from 217442a to 45910a0 Compare March 6, 2018 00:42
@AlainODea
Copy link
Contributor Author

Thank you, @smashling.

I originally had this change in with #92 and didn't properly test it independently.

I have rebased on master and retested and I now get the expected (and far more informative) crash.

It gives an informative error when a pathological file is where ~/.aws/ should be:

Exception in thread "main" java.lang.IllegalStateException: /Users/alain.odea/.aws exists, but is not a directory. Please rename it
	at com.okta.tools.OktaAwsCliAssumeRole.getAwsDirectory(OktaAwsCliAssumeRole.java:583)
	at com.okta.tools.OktaAwsCliAssumeRole.getAwsCredentialsFile(OktaAwsCliAssumeRole.java:559)
	at com.okta.tools.OktaAwsCliAssumeRole.updateCredentialsFile(OktaAwsCliAssumeRole.java:544)
	at com.okta.tools.OktaAwsCliAssumeRole.createAwsProfile(OktaAwsCliAssumeRole.java:522)
	at com.okta.tools.OktaAwsCliAssumeRole.run(OktaAwsCliAssumeRole.java:115)
	at com.okta.tools.WithOkta.main(WithOkta.java:23)

It gives an informative error when a pathological directory is where the credentials file should be:

Exception in thread "main" java.lang.IllegalStateException: /Users/alain.odea/.aws/credentials exists, but is not a regular file. Please rename it
	at com.okta.tools.OktaAwsCliAssumeRole.getAwsCredentialsFile(OktaAwsCliAssumeRole.java:563)
	at com.okta.tools.OktaAwsCliAssumeRole.updateCredentialsFile(OktaAwsCliAssumeRole.java:544)
	at com.okta.tools.OktaAwsCliAssumeRole.createAwsProfile(OktaAwsCliAssumeRole.java:522)
	at com.okta.tools.OktaAwsCliAssumeRole.run(OktaAwsCliAssumeRole.java:115)
	at com.okta.tools.WithOkta.main(WithOkta.java:23)

It gives an informative error when a pathological directory is where the config file should be:

Exception in thread "main" java.lang.IllegalStateException: /Users/alain.odea/.aws/config exists, but is not a regular file. Please rename it
	at com.okta.tools.OktaAwsCliAssumeRole.getAwsConfigFile(OktaAwsCliAssumeRole.java:573)
	at com.okta.tools.OktaAwsCliAssumeRole.updateConfigFile(OktaAwsCliAssumeRole.java:599)
	at com.okta.tools.OktaAwsCliAssumeRole.run(OktaAwsCliAssumeRole.java:116)
	at com.okta.tools.WithOkta.main(WithOkta.java:23)

And it silently recovers from any combination of ~/.aws/, ~/.aws/config, and ~/.aws/credentials being absent.

Copy link
Contributor

@smashling smashling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After merging the test branch with master, the detailed errors came up as expected. This change seems to work as intended.

@mraible mraible merged commit 5eef318 into oktadev:master Mar 6, 2018
AlainODea added a commit to AlainODea/okta-aws-cli-assume-role that referenced this pull request Jun 3, 2018
@AlainODea AlainODea deleted the ao-Self-heal-missing-aws-config branch August 1, 2018 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants