Skip to content

Commit

Permalink
Change aws credentials env loading
Browse files Browse the repository at this point in the history
  • Loading branch information
onee-only committed Jul 14, 2024
1 parent 66de331 commit 7498bcb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
9 changes: 5 additions & 4 deletions cmd/app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import (
"os"
"time"

"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/credentials"
"github.com/aws/aws-sdk-go-v2/service/sqs"
"github.com/docker/docker/client"
influxdb2 "github.com/influxdata/influxdb-client-go"
Expand Down Expand Up @@ -36,9 +37,9 @@ func main() {
httpClient := &http.Client{}
storage := storage.NewFSStorage(conf.WorkStoragePath)

awsConfig, err := config.LoadDefaultConfig(context.Background(), config.WithRegion(conf.AWSRegion))
if err != nil {
logger.Fatal("failed to load aws config", zap.Error(err))
awsConfig := aws.Config{
Region: "ap-northeast-2",
Credentials: credentials.NewStaticCredentialsProvider(conf.AccessKeyID, conf.SecretAccessKey, ""),
}

sqsClient := sqs.NewFromConfig(awsConfig)
Expand Down
3 changes: 3 additions & 0 deletions internal/config/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ func LoadFromEnv() {

JobQueueURL = os.Getenv("AWS_SQS_JOB_QUEUE_URL")
EventQueueURL = os.Getenv("AWS_SQS_TEST_EVENT_QUEUE_URL")

AccessKeyID = os.Getenv("AWS_ACCESS_KEY_ID")
SecretAccessKey = os.Getenv("AWS_SECRET_ACCESS_KEY")
}
3 changes: 3 additions & 0 deletions internal/config/var.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ var (
var (
JobQueueURL string
EventQueueURL string

AccessKeyID string
SecretAccessKey string
)

0 comments on commit 7498bcb

Please sign in to comment.