in e2etestrunner/setuptf/setuptf.go [160:203]
func ApplyPersistent(
ctx context.Context,
projectID string,
autoApprove bool,
logger *log.Logger,
) error {
logger.Println("Applying any changes to persistent resources")
// Run terraform init
cmd := initCommand(ctx, projectID)
cmd.Dir = tfPersistentDir
if err := runWithOutput(cmd, logger); err != nil {
return err
}
// Select default terraform workspace
cmd = exec.CommandContext(ctx, "terraform", "workspace", "select", "default")
cmd.Dir = tfPersistentDir
if err := runWithOutput(cmd, logger); err != nil {
return err
}
// Run terraform apply
cmd = exec.CommandContext(
ctx,
"terraform",
"apply",
"-input=false",
// lock may not be acquired immediately in CI if there are multiple
// jobs, but should only be a short wait
"-lock-timeout=10m",
fmt.Sprintf("-var=project_id=%v", projectID),
)
if autoApprove {
cmd.Args = append(cmd.Args, "-auto-approve")
} else {
cmd.Stdin = os.Stdin
}
cmd.Dir = tfPersistentDir
if err := runWithOutput(cmd, logger); err != nil {
return err
}
return nil
}