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

[extension/sigv4authextension] Make sts_region default to region if value not provided #14630

Merged
merged 2 commits into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .chloggen/sigv4_default_stsregion.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: sigv4authextension

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Have "sts_region" default to "region" if not provided

# One or more tracking issues related to the change
issues: [14573]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
1 change: 1 addition & 0 deletions extension/sigv4authextension/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ The configuration fields are as follows:
* `arn`: The Amazon Resource Name (ARN) of a role to assume
* `session_name`: **Optional**. The name of a role session
* `sts_region`: The AWS region where STS is used to assumed the configured role
* Note that if a role is intended to be assumed, and `sts_region` is not provided, then `sts_region` will default to the value for `region` if `region` is provided
* `region`: **Optional**. The AWS region for the service you are exporting to for AWS Sigv4. This is differentiated from `sts_region` to handle cross region authentication
* Note that an attempt will be made to obtain a valid region from the endpoint of the service you are exporting to
* [List of AWS regions](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.RegionsAndAvailabilityZones.html)
Expand Down
4 changes: 4 additions & 0 deletions extension/sigv4authextension/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ var _ config.Extension = (*Config)(nil)
// We aim to catch most errors here to ensure that we
// fail early and to avoid revalidating static data.
func (cfg *Config) Validate() error {
Copy link
Member

Choose a reason for hiding this comment

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

Validate should not modify the configuration. Since you are already doing that below, I am not going to block merging this PR because of it, but I would like you to create an issue to move this and the credsProvider line below to Unmarshal

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will take care of this early next week!

if cfg.AssumeRole.STSRegion == "" && cfg.Region != "" {
cfg.AssumeRole.STSRegion = cfg.Region
}

credsProvider, err := getCredsProviderFromConfig(cfg)
if err != nil {
return fmt.Errorf("could not retrieve credential provider: %w", err)
Expand Down
1 change: 1 addition & 0 deletions extension/sigv4authextension/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func TestLoadConfig(t *testing.T) {
Service: "service",
AssumeRole: AssumeRole{
SessionName: "role_session_name",
STSRegion: "region",
},
// Ensure creds are the same for load config test; tested in extension_test.go
credsProvider: cfg.(*Config).credsProvider,
Expand Down