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

make AWS_ROLE_SESSION_NAME optional #265

Merged
merged 6 commits into from
Mar 31, 2021
Merged

make AWS_ROLE_SESSION_NAME optional #265

merged 6 commits into from
Mar 31, 2021

Conversation

kolia
Copy link
Contributor

@kolia kolia commented Dec 15, 2020

AWS docs indicate that it should be optional.
If unspecified, a default is set and warning logged.

@mattBrzezinski
Copy link
Member

bors r+

bors bot added a commit that referenced this pull request Dec 15, 2020
265: make AWS_ROLE_SESSION_NAME optional r=mattBrzezinski a=kolia

AWS docs indicate that it should be optional.
If unspecified, a default is set and warning logged.

Co-authored-by: kolia <kolia.sadeghi@beacon.bio>
@bors
Copy link
Contributor

bors bot commented Dec 15, 2020

Build failed:

src/AWSCredentials.jl Outdated Show resolved Hide resolved
@mattBrzezinski
Copy link
Member

bors r+

bors bot added a commit that referenced this pull request Jan 12, 2021
265: make AWS_ROLE_SESSION_NAME optional r=mattBrzezinski a=kolia

AWS docs indicate that it should be optional.
If unspecified, a default is set and warning logged.

Co-authored-by: kolia <kolia.sadeghi@beacon.bio>
@bors
Copy link
Contributor

bors bot commented Jan 12, 2021

Build failed:

@mattBrzezinski
Copy link
Member

Bump.

@kolia
Copy link
Contributor Author

kolia commented Feb 26, 2021

Is the build failure on julia 1.3 a blocker? Seems to have to do with auth expiration times not changing as expected, I'm not understanding what that has to do with this PR or with the julia version.

src/AWSCredentials.jl Outdated Show resolved Hide resolved
@kolia
Copy link
Contributor Author

kolia commented Mar 1, 2021

The module is already using Dates, I just manually confirmed that role-based auth works with and without setting a session name after applying @omus 's suggestion.

kolia and others added 4 commits March 29, 2021 16:26
AWS docs indicate that it should be optional.
If unspecified, a default is set and warning logged.
Co-authored-by: Curtis Vogt <curtis.vogt@gmail.com>
Co-authored-by: Curtis Vogt <curtis.vogt@gmail.com>
@omus
Copy link
Member

omus commented Mar 29, 2021

bors try

bors bot added a commit that referenced this pull request Mar 29, 2021
@bors
Copy link
Contributor

bors bot commented Mar 29, 2021

try

Build failed:

@omus
Copy link
Member

omus commented Mar 29, 2021

After running into this issue myself I realized that the warning would get old very quickly. In order to improve the situation I added the role name into the default session name. Using this and automatically restricting the role session name to 64 characters (the session name limit) I think the default is definitely good enough that we don't need to promote having users specify their own role names.

@omus
Copy link
Member

omus commented Mar 29, 2021

bors try

bors bot added a commit that referenced this pull request Mar 29, 2021
@bors
Copy link
Contributor

bors bot commented Mar 29, 2021

@omus
Copy link
Member

omus commented Mar 29, 2021

bors try

bors bot added a commit that referenced this pull request Mar 29, 2021
@bors
Copy link
Contributor

bors bot commented Mar 29, 2021

@omus
Copy link
Member

omus commented Mar 29, 2021

I've validated this behaviour works correctly in a live AWS session

@omus
Copy link
Member

omus commented Mar 30, 2021

@mattBrzezinski do you want to give this another look over?

@mattBrzezinski
Copy link
Member

@mattBrzezinski do you want to give this another look over?

Yeah I can take a look at this tonight / tomorrow morning and merge it in afterwards!

_role_session_name(
"AWS.jl-role-",
basename(role_arn),
"-" * Dates.format(@mock(now(UTC)), dateformat"yyyymmdd\THHMMSS\Z"),
Copy link
Member

Choose a reason for hiding this comment

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

Dates.format(@mock(now(UTC)), dateformat"yyyymmdd\THHMMSS\Z")

Maybe we pull this out as an internal function, a similar piece of code already exists in test/runtests.jl

Copy link
Member

Choose a reason for hiding this comment

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

I'll look into that. Do you happen to know why that test function uses lowercase?

Copy link
Member

Choose a reason for hiding this comment

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

Not sure this is ported over from AWSCore.jl, the only difference here is that the t becomes lowercase. I assume this is to increase readability. Removing the lowercase call wouldn't affect anything in terms of running on the AWS account, feel free to remove it.

julia> using Dates

julia> Dates.format(now(Dates.UTC), dateformat"yyyymmdd\THHMMSSsss\Z")
"20210331T145218874Z"

julia> lowercase(Dates.format(now(Dates.UTC), dateformat"yyyymmdd\THHMMSSsss\Z"))
"20210331t145225679z"

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure it's worth it to refactor this into a separate function. The _now_formatted function includes milliseconds (which we could use here) and there are several different DateFormats used throughout the repo already:

src/AWS.jl:224:    query["Expires"] = Dates.format(time + Dates.Minute(2), dateformat"yyyy-mm-dd\THH:MM:SS\Z")
src/AWS.jl:246:    date = Dates.format(time, dateformat"yyyymmdd")
src/AWS.jl:247:    datetime = Dates.format(time, dateformat"yyyymmdd\THHMMSS\Z")
src/AWSCredentials.jl:482:            "-" * Dates.format(@mock(now(UTC)), dateformat"yyyymmdd\THHMMSS\Z"),
test/AWS.jl:49:    date = Dates.format(time, dateformat"yyyymmdd")
test/AWS.jl:88:        expected_x_amz_date = Dates.format(time, dateformat"yyyymmdd\THHMMSS\Z")
test/runtests.jl:33:    return lowercase(Dates.format(now(Dates.UTC), dateformat"yyyymmdd\THHMMSSsss\Z"))

As some of these formats are required to be specific to follow spec and others are just there to make identifiers unique I think there isn't a point in extracting this date formatting code. I could see some further refactoring of the _role_session_name to automatically add a timestamp suffix and possibly use it with other AWS services that support names

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense!

Copy link
Member

@mattBrzezinski mattBrzezinski left a comment

Choose a reason for hiding this comment

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

LGTM, just had one question and a very minor refactor for dates.

test/AWSCredentials.jl Show resolved Hide resolved
@mattBrzezinski
Copy link
Member

bors r+

@bors
Copy link
Contributor

bors bot commented Mar 31, 2021

@bors bors bot merged commit 670a618 into JuliaCloud:master Mar 31, 2021
@omus omus deleted the ks/role_session_name_optional branch March 31, 2021 18:50
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.

3 participants