Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions pkg/aws/s3/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const (
INDIA_VAULT = "INDIA-VAULT"
)

func ConnectAws(v *vault.VaultClient, region, accountLocation string) (*session.Session, vault.VaultSecretMap, error) {
func ConnectAws(v *vault.VaultClient, region, accountLocation string, enableS3Acceleration bool) (*session.Session, vault.VaultSecretMap, error) {
secretPath := ""
if accountLocation == US_VAULT {
secretPath = sharedAws.US_VAULT_SECRET_PATH
Expand All @@ -41,25 +41,26 @@ func ConnectAws(v *vault.VaultClient, region, accountLocation string) (*session.
secretAccessKey,
"",
),
S3UseAccelerate: aws.Bool(enableS3Acceleration),
})
session := session.Must(newSess, err)
return session, secrets, nil
}

func ConnectS3(region string) (*session.Session, *s3.S3, vault.VaultSecretMap) {
func ConnectS3(region string, enableS3Acceleration bool) (*session.Session, *s3.S3, vault.VaultSecretMap) {
vaultClient, err := vault.NewVaultClient()
if err != nil {
panic(err)
}
awsSession, secrets, err := ConnectAws(vaultClient, region, INDIA_VAULT)
awsSession, secrets, err := ConnectAws(vaultClient, region, INDIA_VAULT, enableS3Acceleration)
if err != nil {
panic(err)
}
s3Session := s3.New(awsSession)
return awsSession, s3Session, secrets
}

func GetAWSSession(vaultToken, region, accountLocation string) (*session.Session, error) {
func GetAWSSession(vaultToken, region, accountLocation string, enableS3Acceleration bool) (*session.Session, error) {
vc, err := vault.GetVaultClientByToken(vaultToken)
if err != nil {
panic(err)
Expand Down Expand Up @@ -87,6 +88,7 @@ func GetAWSSession(vaultToken, region, accountLocation string) (*session.Session
secretAccessKey,
"",
),
S3UseAccelerate: aws.Bool(enableS3Acceleration),
})
session := session.Must(newSess, err)
return session, nil
Expand Down