Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion internal/actions/deploy/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const profilePrefix = "draftea-"
type EnvConfig struct {
Profile string // e.g. "draftea-dev", "draftea-prod", "draftea-feature"
ExtraSLSParams string // non-empty only for feature: --param="stage=feature"
SyncSecretsDry bool // if true, sets SLS_SYNC_SECRETS_DRY=true to skip secrets sync
}

// Stage derives the stage name from the profile by stripping the profilePrefix.
Expand All @@ -21,7 +22,8 @@ var (
}

ProdEnv = EnvConfig{
Profile: profilePrefix + "prod",
Profile: profilePrefix + "prod",
SyncSecretsDry: true,
}

FeatureEnv = EnvConfig{
Expand Down
9 changes: 7 additions & 2 deletions internal/actions/deploy/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,15 @@ func DeployFunction(env EnvConfig, serviceArg string, functionNames []string) er
}
}

syncSecretsDry := "false"
if env.SyncSecretsDry {
syncSecretsDry = "true"
}

log.Info("Packaging service...")
packageScript := fmt.Sprintf(
`cd %q && env STAGE=%s AWS_ACCOUNT=%s sls package --stage %s --verbose --aws-profile %s`,
absPath, stage, accountID, stage, env.Profile,
`cd %q && env STAGE=%s AWS_ACCOUNT=%s SLS_SYNC_SECRETS_DRY=%s sls package --stage %s --verbose --aws-profile %s`,
absPath, stage, accountID, syncSecretsDry, stage, env.Profile,
)
if _, err := exec.Command(packageScript, exec.WithStdout(os.Stdout), exec.WithStderr(os.Stderr)); err != nil {
return fmt.Errorf("sls package failed: %w", err)
Expand Down
9 changes: 7 additions & 2 deletions internal/actions/deploy/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,14 @@ func deployServiceToDir(env EnvConfig, absPath, accountID string) error {
slsParams = fmt.Sprintf("%s %s", slsParams, env.ExtraSLSParams)
}

syncSecretsDry := "false"
if env.SyncSecretsDry {
syncSecretsDry = "true"
}

script := fmt.Sprintf(
`cd %q && npm install && env STAGE=%s AWS_ACCOUNT=%s SLS_PARAMS=%q npm run deploy`,
absPath, stage, accountID, slsParams,
`cd %q && npm install && env STAGE=%s AWS_ACCOUNT=%s SLS_PARAMS=%q SLS_SYNC_SECRETS_DRY=%s npm run deploy`,
absPath, stage, accountID, slsParams, syncSecretsDry,
)

_, err = exec.Command(script, exec.WithStdout(os.Stdout), exec.WithStderr(os.Stderr))
Expand Down