-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
provider: add assume_role.0.duration
and deprecate assume_role.0.duration_seconds
#23077
Merged
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f241a1b
provider: add assume_role.0.duration and deprecate assume_role.0.dura…
anGie44 378cf2f
provider: add assume_role.0.duration and deprecate assume_role.0.dura…
anGie44 be67e1d
Update CHANGELOG for #23077
anGie44 4246ecc
add instructions for provider changes in #23007
anGie44 ffae2f6
Update duration description in website/docs/index.html.markdown
anGie44 f06bef3
Update website/docs/guides/version-4-upgrade.html.md
anGie44 7efdac4
Update internal/verify/validate.go
anGie44 dece156
Merge branch 'f-provider-assume-role-duration-changes' of ssh://githu…
anGie44 1f82a5c
update provider assume role duration validation to include min and max
anGie44 5645b42
Update 23077.txt
anGie44 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1936,11 +1936,20 @@ func assumeRoleSchema() *schema.Schema { | |
MaxItems: 1, | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"duration": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Description: "The duration of the role session, e.g. 1h. Valid time units are ns, us (or µs), ms, s, h, or m.", | ||
ValidateFunc: verify.ValidTimeDuration, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could also check for the minimum value of 15 minutes and the absolute maximum of 12 hours There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test output after updates:
|
||
ConflictsWith: []string{"assume_role.0.duration_seconds"}, | ||
}, | ||
"duration_seconds": { | ||
Type: schema.TypeInt, | ||
Optional: true, | ||
Description: "The duration, in seconds, of the role session.", | ||
ValidateFunc: validation.IntBetween(900, 43200), | ||
Type: schema.TypeInt, | ||
Optional: true, | ||
Deprecated: "Use assume_role.0.duration instead", | ||
Description: "The duration, in seconds, of the role session.", | ||
ValidateFunc: validation.IntBetween(900, 43200), | ||
ConflictsWith: []string{"assume_role.0.duration"}, | ||
}, | ||
"external_id": { | ||
Type: schema.TypeString, | ||
|
@@ -2022,6 +2031,11 @@ func endpointsSchema() *schema.Schema { | |
func expandAssumeRole(m map[string]interface{}) *awsbase.AssumeRole { | ||
assumeRole := awsbase.AssumeRole{} | ||
|
||
if v, ok := m["duration"].(string); ok && v != "" { | ||
duration, _ := time.ParseDuration(v) | ||
assumeRole.Duration = duration | ||
} | ||
|
||
if v, ok := m["duration_seconds"].(int); ok && v != 0 { | ||
assumeRole.Duration = time.Duration(v) * time.Second | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q for reviewer: This validation does not allow for empty strings...or should it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the validation functions provided by the Plugin SDK, and especially
validation.IsRFC3339Time()
, we're probably fine not checking for it.