fix credential usage
Signed-off-by: Fabiano Graças <fabiano.gracas@faro.com>
This commit is contained in:
parent
c6d7cdd6d7
commit
e9c6d0021b
5 changed files with 13 additions and 30 deletions
|
|
@ -43,7 +43,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/aws/aws-sdk-go-v2/aws"
|
||||
"github.com/aws/aws-sdk-go-v2/credentials"
|
||||
|
||||
"github.com/vmware/vmware-go-kcl-v2/clientlibrary/metrics"
|
||||
"github.com/vmware/vmware-go-kcl-v2/logger"
|
||||
|
|
@ -174,10 +173,10 @@ type (
|
|||
KinesisEndpoint string
|
||||
|
||||
// KinesisCredentials is used to access Kinesis
|
||||
KinesisCredentials *credentials.StaticCredentialsProvider
|
||||
KinesisCredentials aws.CredentialsProvider
|
||||
|
||||
// DynamoDBCredentials is used to access DynamoDB
|
||||
DynamoDBCredentials *credentials.StaticCredentialsProvider
|
||||
DynamoDBCredentials aws.CredentialsProvider
|
||||
|
||||
// TableName is name of the dynamo db table for managing kinesis stream default to ApplicationName
|
||||
TableName string
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ import (
|
|||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/aws/aws-sdk-go-v2/credentials"
|
||||
"github.com/aws/aws-sdk-go-v2/aws"
|
||||
|
||||
"github.com/vmware/vmware-go-kcl-v2/clientlibrary/metrics"
|
||||
"github.com/vmware/vmware-go-kcl-v2/clientlibrary/utils"
|
||||
|
|
@ -55,13 +55,13 @@ func NewKinesisClientLibConfig(applicationName, streamName, regionName, workerID
|
|||
|
||||
// NewKinesisClientLibConfigWithCredential creates a default KinesisClientLibConfiguration based on the required fields and unique credentials.
|
||||
func NewKinesisClientLibConfigWithCredential(applicationName, streamName, regionName, workerID string,
|
||||
creds *credentials.StaticCredentialsProvider) *KinesisClientLibConfiguration {
|
||||
creds aws.CredentialsProvider) *KinesisClientLibConfiguration {
|
||||
return NewKinesisClientLibConfigWithCredentials(applicationName, streamName, regionName, workerID, creds, creds)
|
||||
}
|
||||
|
||||
// NewKinesisClientLibConfigWithCredentials creates a default KinesisClientLibConfiguration based on the required fields and specific credentials for each service.
|
||||
func NewKinesisClientLibConfigWithCredentials(applicationName, streamName, regionName, workerID string,
|
||||
kinesisCreds, dynamodbCreds *credentials.StaticCredentialsProvider) *KinesisClientLibConfiguration {
|
||||
kinesisCreds, dynamodbCreds aws.CredentialsProvider) *KinesisClientLibConfiguration {
|
||||
checkIsValueNotEmpty("ApplicationName", applicationName)
|
||||
checkIsValueNotEmpty("StreamName", streamName)
|
||||
checkIsValueNotEmpty("RegionName", regionName)
|
||||
|
|
|
|||
|
|
@ -35,8 +35,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/aws/aws-sdk-go-v2/aws"
|
||||
"github.com/aws/aws-sdk-go-v2/credentials"
|
||||
|
||||
cwatch "github.com/aws/aws-sdk-go-v2/service/cloudwatch"
|
||||
"github.com/aws/aws-sdk-go-v2/service/cloudwatch/types"
|
||||
|
||||
|
|
@ -51,7 +49,7 @@ type MonitoringService struct {
|
|||
streamName string
|
||||
workerID string
|
||||
region string
|
||||
credentials *credentials.StaticCredentialsProvider
|
||||
credentials aws.CredentialsProvider
|
||||
logger logger.Logger
|
||||
|
||||
// control how often to publish to CloudWatch
|
||||
|
|
@ -76,13 +74,13 @@ type cloudWatchMetrics struct {
|
|||
}
|
||||
|
||||
// NewMonitoringService returns a Monitoring service publishing metrics to CloudWatch.
|
||||
func NewMonitoringService(region string, creds *credentials.StaticCredentialsProvider) *MonitoringService {
|
||||
func NewMonitoringService(region string, creds aws.CredentialsProvider) *MonitoringService {
|
||||
return NewMonitoringServiceWithOptions(region, creds, logger.GetDefaultLogger(), DefaultCloudwatchMetricsBufferDuration)
|
||||
}
|
||||
|
||||
// NewMonitoringServiceWithOptions returns a Monitoring service publishing metrics to
|
||||
// CloudWatch with the provided credentials, buffering duration and logger.
|
||||
func NewMonitoringServiceWithOptions(region string, creds *credentials.StaticCredentialsProvider, logger logger.Logger, bufferDur time.Duration) *MonitoringService {
|
||||
func NewMonitoringServiceWithOptions(region string, creds aws.CredentialsProvider, logger logger.Logger, bufferDur time.Duration) *MonitoringService {
|
||||
return &MonitoringService{
|
||||
region: region,
|
||||
credentials: creds,
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ import (
|
|||
"github.com/aws/aws-sdk-go-v2/aws"
|
||||
"github.com/aws/aws-sdk-go-v2/aws/retry"
|
||||
awsConfig "github.com/aws/aws-sdk-go-v2/config"
|
||||
"github.com/aws/aws-sdk-go-v2/credentials"
|
||||
"github.com/aws/aws-sdk-go-v2/service/kinesis"
|
||||
|
||||
chk "github.com/vmware/vmware-go-kcl-v2/clientlibrary/checkpoint"
|
||||
|
|
@ -171,11 +170,7 @@ func (w *Worker) initialize() error {
|
|||
cfg, err := awsConfig.LoadDefaultConfig(
|
||||
context.TODO(),
|
||||
awsConfig.WithRegion(w.regionName),
|
||||
awsConfig.WithCredentialsProvider(
|
||||
credentials.NewStaticCredentialsProvider(
|
||||
w.kclConfig.KinesisCredentials.Value.AccessKeyID,
|
||||
w.kclConfig.KinesisCredentials.Value.SecretAccessKey,
|
||||
w.kclConfig.KinesisCredentials.Value.SessionToken)),
|
||||
awsConfig.WithCredentialsProvider(w.kclConfig.KinesisCredentials),
|
||||
awsConfig.WithEndpointResolver(resolver),
|
||||
awsConfig.WithRetryer(func() aws.Retryer {
|
||||
return retry.AddWithMaxBackoffDelay(retry.NewStandard(), retry.DefaultMaxBackoff)
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ import (
|
|||
"github.com/aws/aws-sdk-go-v2/aws"
|
||||
"github.com/aws/aws-sdk-go-v2/aws/retry"
|
||||
awsConfig "github.com/aws/aws-sdk-go-v2/config"
|
||||
"github.com/aws/aws-sdk-go-v2/credentials"
|
||||
"github.com/aws/aws-sdk-go-v2/service/dynamodb"
|
||||
"github.com/aws/aws-sdk-go-v2/service/kinesis"
|
||||
"github.com/aws/aws-sdk-go-v2/service/kinesis/types"
|
||||
|
|
@ -42,7 +41,7 @@ import (
|
|||
const specstr = `{"name":"kube-qQyhk","networking":{"containerNetworkCidr":"10.2.0.0/16"},"orgName":"BVT-Org-cLQch","projectName":"project-tDSJd","serviceLevel":"DEVELOPER","size":{"count":1},"version":"1.8.1-4"}`
|
||||
|
||||
// NewKinesisClient to create a Kinesis Client.
|
||||
func NewKinesisClient(t *testing.T, regionName, endpoint string, creds *credentials.StaticCredentialsProvider) *kinesis.Client {
|
||||
func NewKinesisClient(t *testing.T, regionName, endpoint string, creds aws.CredentialsProvider) *kinesis.Client {
|
||||
// create session for Kinesis
|
||||
t.Logf("Creating Kinesis client")
|
||||
|
||||
|
|
@ -57,11 +56,7 @@ func NewKinesisClient(t *testing.T, regionName, endpoint string, creds *credenti
|
|||
cfg, err := awsConfig.LoadDefaultConfig(
|
||||
context.TODO(),
|
||||
awsConfig.WithRegion(regionName),
|
||||
awsConfig.WithCredentialsProvider(
|
||||
credentials.NewStaticCredentialsProvider(
|
||||
creds.Value.AccessKeyID,
|
||||
creds.Value.SecretAccessKey,
|
||||
creds.Value.SessionToken)),
|
||||
awsConfig.WithCredentialsProvider(creds),
|
||||
awsConfig.WithEndpointResolver(resolver),
|
||||
awsConfig.WithRetryer(func() aws.Retryer {
|
||||
return retry.AddWithMaxBackoffDelay(retry.NewStandard(), retry.DefaultMaxBackoff)
|
||||
|
|
@ -77,7 +72,7 @@ func NewKinesisClient(t *testing.T, regionName, endpoint string, creds *credenti
|
|||
}
|
||||
|
||||
// NewDynamoDBClient to create a Kinesis Client.
|
||||
func NewDynamoDBClient(t *testing.T, regionName, endpoint string, creds *credentials.StaticCredentialsProvider) *dynamodb.Client {
|
||||
func NewDynamoDBClient(t *testing.T, regionName, endpoint string, creds aws.CredentialsProvider) *dynamodb.Client {
|
||||
resolver := aws.EndpointResolverFunc(func(service, region string) (aws.Endpoint, error) {
|
||||
return aws.Endpoint{
|
||||
PartitionID: "aws",
|
||||
|
|
@ -89,11 +84,7 @@ func NewDynamoDBClient(t *testing.T, regionName, endpoint string, creds *credent
|
|||
cfg, err := awsConfig.LoadDefaultConfig(
|
||||
context.TODO(),
|
||||
awsConfig.WithRegion(regionName),
|
||||
awsConfig.WithCredentialsProvider(
|
||||
credentials.NewStaticCredentialsProvider(
|
||||
creds.Value.AccessKeyID,
|
||||
creds.Value.SecretAccessKey,
|
||||
creds.Value.SessionToken)),
|
||||
awsConfig.WithCredentialsProvider(creds),
|
||||
awsConfig.WithEndpointResolver(resolver),
|
||||
awsConfig.WithRetryer(func() aws.Retryer {
|
||||
return retry.AddWithMaxBackoffDelay(retry.NewStandard(), retry.DefaultMaxBackoff)
|
||||
|
|
|
|||
Loading…
Reference in a new issue