-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for aws clients provider
- Loading branch information
1 parent
ebc3c25
commit 0353352
Showing
6 changed files
with
127 additions
and
28 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package aws | ||
|
||
import ( | ||
"context" | ||
"github.com/aws/aws-sdk-go-v2/aws" | ||
"github.com/aws/aws-sdk-go-v2/service/ec2" | ||
"github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2" | ||
"sigs.k8s.io/aws-load-balancer-controller/pkg/aws/endpoints" | ||
) | ||
|
||
type defaultAWSClientsProvider struct { | ||
ec2Client *ec2.Client | ||
elbv2Client *elasticloadbalancingv2.Client | ||
} | ||
|
||
func NewDefaultAWSClientsProvider(cfg aws.Config, endpointsResolver *endpoints.Resolver) (*defaultAWSClientsProvider, error) { | ||
customEndpoint := endpointsResolver.EndpointFor(ec2.ServiceID) | ||
ec2Client := ec2.NewFromConfig(cfg, func(o *ec2.Options) { | ||
if customEndpoint != nil { | ||
o.BaseEndpoint = customEndpoint | ||
} | ||
}) | ||
return &defaultAWSClientsProvider{ | ||
ec2Client: ec2Client, | ||
elbv2Client: nil, | ||
}, nil | ||
} | ||
|
||
func (p *defaultAWSClientsProvider) GetEC2Client(ctx context.Context, operationName string) (*ec2.Client, error) { | ||
return p.ec2Client, nil | ||
} |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package provider | ||
|
||
import ( | ||
"context" | ||
"github.com/aws/aws-sdk-go-v2/service/ec2" | ||
) | ||
|
||
type AWSClientsProvider interface { | ||
GetEC2Client(ctx context.Context, operationName string) (*ec2.Client, error) | ||
} |
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