-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Follow up for 3691 [TargetGroupBindings can now manipulate target groups from different aws accounts] #4026
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
Merged
k8s-ci-robot
merged 4 commits into
kubernetes-sigs:main
from
zac-nixon:znixon/multi-acc-tgb
Jan 24, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ddc77cd
resolve pr comments for multi account tgb
zac-nixon 577e1b6
refactor target group lookup in webhooks to reduce code duplication
zac-nixon db09cb9
add tests and correct regex for assume role session name
zac-nixon dfae145
fix assume role tgb
zac-nixon 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| package aws | ||
|
|
||
| import ( | ||
| "context" | ||
| "github.com/aws/aws-sdk-go-v2/aws" | ||
| awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" | ||
| "github.com/aws/aws-sdk-go-v2/aws/ratelimit" | ||
| "github.com/aws/aws-sdk-go-v2/aws/retry" | ||
| "github.com/aws/aws-sdk-go-v2/config" | ||
| "github.com/aws/aws-sdk-go-v2/feature/ec2/imds" | ||
| smithymiddleware "github.com/aws/smithy-go/middleware" | ||
| "sigs.k8s.io/aws-load-balancer-controller/pkg/aws/throttle" | ||
| awsmetrics "sigs.k8s.io/aws-load-balancer-controller/pkg/metrics/aws" | ||
| "sigs.k8s.io/aws-load-balancer-controller/pkg/version" | ||
| ) | ||
|
|
||
| const ( | ||
| userAgent = "elbv2.k8s.aws" | ||
| ) | ||
|
|
||
| func NewAWSConfigGenerator(cfg CloudConfig, ec2IMDSEndpointMode imds.EndpointModeState, metricsCollector *awsmetrics.Collector) AWSConfigGenerator { | ||
| return &awsConfigGeneratorImpl{ | ||
| cfg: cfg, | ||
| ec2IMDSEndpointMode: ec2IMDSEndpointMode, | ||
| metricsCollector: metricsCollector, | ||
| } | ||
|
|
||
| } | ||
|
|
||
| // AWSConfigGenerator is responsible for generating an aws config based on the running environment | ||
| type AWSConfigGenerator interface { | ||
| GenerateAWSConfig(optFns ...func(*config.LoadOptions) error) (aws.Config, error) | ||
| } | ||
|
|
||
| type awsConfigGeneratorImpl struct { | ||
| cfg CloudConfig | ||
| ec2IMDSEndpointMode imds.EndpointModeState | ||
| metricsCollector *awsmetrics.Collector | ||
| } | ||
|
|
||
| func (gen *awsConfigGeneratorImpl) GenerateAWSConfig(optFns ...func(*config.LoadOptions) error) (aws.Config, error) { | ||
|
|
||
| defaultOpts := []func(*config.LoadOptions) error{ | ||
| config.WithRegion(gen.cfg.Region), | ||
| config.WithRetryer(func() aws.Retryer { | ||
| return retry.NewStandard(func(o *retry.StandardOptions) { | ||
| o.RateLimiter = ratelimit.None | ||
| o.MaxAttempts = gen.cfg.MaxRetries | ||
| }) | ||
| }), | ||
| config.WithEC2IMDSEndpointMode(gen.ec2IMDSEndpointMode), | ||
| config.WithAPIOptions([]func(stack *smithymiddleware.Stack) error{ | ||
| awsmiddleware.AddUserAgentKeyValue(userAgent, version.GitVersion), | ||
| }), | ||
| } | ||
|
|
||
| defaultOpts = append(defaultOpts, optFns...) | ||
|
|
||
| awsConfig, err := config.LoadDefaultConfig(context.TODO(), | ||
| defaultOpts..., | ||
| ) | ||
|
|
||
| if err != nil { | ||
| return aws.Config{}, err | ||
| } | ||
|
|
||
| if gen.cfg.ThrottleConfig != nil { | ||
| throttler := throttle.NewThrottler(gen.cfg.ThrottleConfig) | ||
| awsConfig.APIOptions = append(awsConfig.APIOptions, func(stack *smithymiddleware.Stack) error { | ||
| return throttle.WithSDKRequestThrottleMiddleware(throttler)(stack) | ||
| }) | ||
| } | ||
|
|
||
| if gen.metricsCollector != nil { | ||
| awsConfig.APIOptions = awsmetrics.WithSDKMetricCollector(gen.metricsCollector, awsConfig.APIOptions) | ||
| } | ||
|
|
||
| return awsConfig, nil | ||
| } | ||
|
|
||
| var _ AWSConfigGenerator = &awsConfigGeneratorImpl{} |
Oops, something went wrong.
Oops, something went wrong.
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.
Removed this. Trying to get the tool fixed to generate this properly, but it will make the CR huge