diff --git a/internal/resources/policy/kind/custom/recipe/tmc_custom_schema.go b/internal/resources/policy/kind/custom/recipe/tmc_custom_schema.go index 5f2462186..4a4acdf7b 100644 --- a/internal/resources/policy/kind/custom/recipe/tmc_custom_schema.go +++ b/internal/resources/policy/kind/custom/recipe/tmc_custom_schema.go @@ -20,6 +20,7 @@ import ( policyrecipecustomcommonmodel "github.com/vmware/terraform-provider-tanzu-mission-control/internal/models/policy/recipe/custom/common" recipemodels "github.com/vmware/terraform-provider-tanzu-mission-control/internal/models/recipe" "github.com/vmware/terraform-provider-tanzu-mission-control/internal/resources/policy/kind/common" + clienterrors "github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/errors" ) var TMCCustomSchema = &schema.Schema{ @@ -117,7 +118,11 @@ func ValidateCustomRecipe(config authctx.TanzuContext, customRecipe map[string]i recipeData, err := config.TMCConnection.RecipeResourceService.RecipeResourceServiceGet(recipeModel) if err != nil { - errMessages = append(errMessages, err.Error()) + // NOTE: If error is 404 not found then do not fail the planning. This fix ensures that if user tries to create the new custom template + // and assign the same template to the custom policy in a single terraform apply operation will be able to proceed, instead of failing in the planning phase. + if !clienterrors.IsNotFoundError(err) { + errMessages = append(errMessages, err.Error()) + } } else { errs := ValidateRecipeParameters(recipeData.Recipe.Spec.InputSchema, customRecipe[ParametersKey].(string))