func DeployExampleAppStage()

in helpers/foundation-deployer/stages/apply.go [386:426]


func DeployExampleAppStage(t testing.TB, s steps.Steps, tfvars GlobalTFVars, outputs InfraPipelineOutputs, c CommonConf) error {
	// create tfvars file
	commonTfvars := AppInfraCommonTfvars{
		InstanceRegion:    tfvars.DefaultRegion,
		RemoteStateBucket: outputs.RemoteStateBucket,
	}
	err := utils.WriteTfvars(filepath.Join(c.FoundationPath, AppInfraStep, "common.auto.tfvars"), commonTfvars)
	if err != nil {
		return err
	}
	// update backend bucket
	for _, e := range []string{"production", "non-production", "development"} {
		err = utils.ReplaceStringInFile(filepath.Join(c.FoundationPath, AppInfraStep, "business_unit_1", e, "backend.tf"), "UPDATE_APP_INFRA_BUCKET", outputs.StateBucket)
		if err != nil {
			return err
		}
	}
	//prepare policies repo
	gcpPoliciesPath := filepath.Join(c.CheckoutPath, "gcp-policies-app-infra")
	policiesConf := utils.CloneCSR(t, PoliciesRepo, gcpPoliciesPath, outputs.InfraPipeProj, c.Logger)
	policiesBranch := "main"
	err = s.RunStep("bu1-example-app.gcp-policies-app-infra", func() error {
		return preparePoliciesRepo(policiesConf, policiesBranch, c.FoundationPath, gcpPoliciesPath)
	})
	if err != nil {
		return err
	}

	conf := utils.CloneCSR(t, AppInfraRepo, filepath.Join(c.CheckoutPath, AppInfraRepo), outputs.InfraPipeProj, c.Logger)
	stageConf := StageConf{
		Stage:         AppInfraRepo,
		CICDProject:   outputs.InfraPipeProj,
		DefaultRegion: outputs.DefaultRegion,
		Step:          AppInfraStep,
		Repo:          AppInfraRepo,
		GitConf:       conf,
		Envs:          []string{"production", "non-production", "development"},
	}

	return deployStage(t, stageConf, s, c)
}