Skip to content

Commit

Permalink
fixed region for retrieving frontend env secret (#14)
Browse files Browse the repository at this point in the history
* fixed region for retrieving frontend env secret

* edited build-frontend-env code to parse through key:value representation of AWS secret

* fixed minor code cleanliness issues

---------

Co-authored-by: Samuel Liu <sliu855@gatech.edu>
  • Loading branch information
sliu526 and Samuel Liu authored Jan 9, 2024
1 parent bcc7df2 commit 552ba26
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions cmd/frontend/build_frontend_env/build-frontend-env-file.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/spf13/cobra"
"github.com/DSGT-DLP/Deep-Learning-Playground/cli/cmd/frontend" // For frontend/
"github.com/DSGT-DLP/Deep-Learning-Playground/cli/utils" // For utils/
"encoding/json"
)

var secretName string // Name of the secret in AWS Secrets Manager
Expand All @@ -33,9 +34,18 @@ var buildFrontendEnvCmd = &cobra.Command{
}

path := "./frontend"

// AWS secrets are parsed from key:value pairs in secrets manager for populating the .env file

// Adding secrets to the .env file
utils.WriteToEnvFile(secretName, *secretValue.SecretString, path)
var secretsMap map[string]string

if err := json.Unmarshal([]byte(*secretValue.SecretString), &secretsMap); err != nil {
log.Fatal("error unmarshalling json: ", err)
}

for key,value := range secretsMap {
utils.WriteToEnvFile(key, value, path)
}

// Hardcoding bucket name as a constant
utils.WriteToEnvFile("BUCKET_NAME", utils.DlpUploadBucket, path)
Expand Down
2 changes: 1 addition & 1 deletion cmd/frontend/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

const FrontendDir string = "./frontend"
const AwsRegion = "us-west-2"
const AwsRegion = "us-east-1"

// FrontendCmd represents the frontend command
var FrontendCmd = &cobra.Command{
Expand Down

0 comments on commit 552ba26

Please sign in to comment.