Skip to content

Commit

Permalink
set aws env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
amit-shekhar committed Jul 3, 2023
1 parent e0cd2fa commit ed2757f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion canned/dynamodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func NewDynamoDB(ctx context.Context) (*DynamoDB, error) {

host, _ := container.Host(ctx)
port, _ := container.MappedPort(ctx, "8000")
accessKey, secretKey, region := "awsaccesskey", "awssecretkey", "ap-southeast-1"
accessKey, secretKey, region := getAWSConfig()
endpoint := fmt.Sprintf("http://%s:%s", host, port.Port())

dynamoClient, err := newDynamoClient(endpoint, accessKey, secretKey, region)
Expand Down
2 changes: 1 addition & 1 deletion canned/localstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func NewLocalstack(ctx context.Context) (*Localstack, error) {

host, _ := container.Host(ctx)
port, _ := container.MappedPort(ctx, "4566")
accessKey, secretKey, region := "awsaccesskey", "awssecretkey", "ap-southeast-1"
accessKey, secretKey, region := getAWSConfig()
endpoint := fmt.Sprintf("http://%s:%s", host, port.Port())

awsSession, err := newAWSSession(accessKey, secretKey, endpoint, region)
Expand Down
2 changes: 1 addition & 1 deletion canned/minio.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type Minio struct {

func NewMinio(ctx context.Context) (*Minio, error) {
os.Setenv("TC_HOST", "localhost")
accessKey, secretKey, region := "awsaccesskey", "awssecretkey", "ap-southeast-1"
accessKey, secretKey, region := getAWSConfig()

req := testcontainers.ContainerRequest{
Image: getEnvString("MINIO_CONTAINER_IMAGE", "minio/minio:RELEASE.2023-05-18T00-05-36Z"),
Expand Down
2 changes: 1 addition & 1 deletion canned/sqs.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func NewSQS(ctx context.Context) (*SQS, error) {

host, _ := container.Host(ctx)
port, _ := container.MappedPort(ctx, "9324")
accessKey, secretKey, region := "awsaccesskey", "awssecretkey", "ap-southeast-1"
accessKey, secretKey, region := getAWSConfig()
endpoint := fmt.Sprintf("http://%s:%s", host, port.Port())

sqsClient, err := newSQSClient(endpoint, accessKey, secretKey, region)
Expand Down
8 changes: 8 additions & 0 deletions canned/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ func getEnvString(variable string, defaultValue string) string {
return val
}

func getAWSConfig() (string, string, string) {
accessKey := getEnvString("AWS_ACCESS_KEY_ID", "awsaccesskey")
secretKey := getEnvString("AWS_SECRET_ACCESS_KEY", "awssecretkey")
region := getEnvString("AWS_REGION", "ap-southeast-1")

return accessKey, secretKey, region
}

func getBasicAuth() string {
username := os.Getenv("CONTAINER_REGISTRY_USERNAME")
password := os.Getenv("CONTAINER_REGISTRY_PASSWORD")
Expand Down

0 comments on commit ed2757f

Please sign in to comment.