diff --git a/.changelog/1146.txt b/.changelog/1146.txt new file mode 100644 index 000000000..07506ab9e --- /dev/null +++ b/.changelog/1146.txt @@ -0,0 +1,4 @@ +```release-note:breaking-change +waypoint: Add new required field for no-code module ID to Waypoint template and +add-on definition resources. +``` \ No newline at end of file diff --git a/docs/data-sources/waypoint_add_on_definition.md b/docs/data-sources/waypoint_add_on_definition.md index 475650652..9dde1ad46 100644 --- a/docs/data-sources/waypoint_add_on_definition.md +++ b/docs/data-sources/waypoint_add_on_definition.md @@ -30,6 +30,7 @@ The Waypoint Add-on Definition data source retrieves information on a given Add- - `terraform_agent_pool_id` (String) The ID of the Terraform agent pool. - `terraform_cloud_workspace_details` (Attributes) Terraform Cloud Workspace details. (see [below for nested schema](#nestedatt--terraform_cloud_workspace_details)) - `terraform_execution_mode` (String) The execution mode for the Terraform Cloud workspace. +- `terraform_no_code_module_id` (String) The ID of the Terraform no-code module to use for running Terraform operations - `terraform_no_code_module_source` (String) Terraform No Code Module source - `variable_options` (Attributes List) List of variable options for the Add-on Definition. (see [below for nested schema](#nestedatt--variable_options)) diff --git a/docs/data-sources/waypoint_template.md b/docs/data-sources/waypoint_template.md index 19eaea79a..aa4540bb2 100644 --- a/docs/data-sources/waypoint_template.md +++ b/docs/data-sources/waypoint_template.md @@ -30,6 +30,7 @@ The Waypoint Template data source retrieves information on a given Template. - `terraform_agent_pool_id` (String) Terraform agent pool ID - `terraform_cloud_workspace_details` (Attributes) Terraform Cloud Workspace details (see [below for nested schema](#nestedatt--terraform_cloud_workspace_details)) - `terraform_execution_mode` (String) Terraform execution mode +- `terraform_no_code_module_id` (String) The ID of the Terraform no-code module to use for running Terraform operations - `terraform_no_code_module_source` (String) Terraform No Code Module source - `variable_options` (Attributes List) List of variable options for the template (see [below for nested schema](#nestedatt--variable_options)) diff --git a/docs/resources/waypoint_add_on_definition.md b/docs/resources/waypoint_add_on_definition.md index 57a1a7619..d7d0270e1 100644 --- a/docs/resources/waypoint_add_on_definition.md +++ b/docs/resources/waypoint_add_on_definition.md @@ -19,6 +19,7 @@ Waypoint Add-on Definition resource - `description` (String) A longer description of the Add-on Definition. - `name` (String) The name of the Add-on Definition. - `summary` (String) A short summary of the Add-on Definition. +- `terraform_no_code_module_id` (String) The ID of the Terraform no-code module to use for running Terraform operations. This is in the format of 'nocode-'. - `terraform_no_code_module_source` (String) Terraform Cloud no-code Module Source, expected to be in one of the following formats: "app.terraform.io/hcp_waypoint_example/ecs-advanced-microservice/aws" or "private/hcp_waypoint_example/ecs-advanced-microservice/aws". - `terraform_project_id` (String) The ID of the Terraform Cloud Project to create workspaces in. The ID is found on the Terraform Cloud Project settings page. diff --git a/docs/resources/waypoint_template.md b/docs/resources/waypoint_template.md index 06fc3341b..c07f6ca3a 100644 --- a/docs/resources/waypoint_template.md +++ b/docs/resources/waypoint_template.md @@ -18,6 +18,7 @@ Waypoint Template resource - `name` (String) The name of the Template. - `summary` (String) A brief description of the template, up to 110 characters. +- `terraform_no_code_module_id` (String) The ID of the Terraform no-code module to use for running Terraform operations. This is in the format of 'nocode-'. - `terraform_no_code_module_source` (String) Terraform Cloud No-Code Module details - `terraform_project_id` (String) The ID of the Terraform Cloud Project to create workspaces in. The ID is found on the Terraform Cloud Project settings page. diff --git a/internal/provider/waypoint/data_source_waypoint_add_on_definition.go b/internal/provider/waypoint/data_source_waypoint_add_on_definition.go index cb9daa9c7..dd89872c3 100644 --- a/internal/provider/waypoint/data_source_waypoint_add_on_definition.go +++ b/internal/provider/waypoint/data_source_waypoint_add_on_definition.go @@ -46,6 +46,7 @@ type DataSourceAddOnDefinitionModel struct { TerraformCloudWorkspace *tfcWorkspace `tfsdk:"terraform_cloud_workspace_details"` TerraformNoCodeModuleSource types.String `tfsdk:"terraform_no_code_module_source"` + TerraformNoCodeModuleID types.String `tfsdk:"terraform_no_code_module_id"` TerraformVariableOptions []*tfcVariableOption `tfsdk:"variable_options"` TerraformExecutionMode types.String `tfsdk:"terraform_execution_mode"` TerraformAgentPoolID types.String `tfsdk:"terraform_agent_pool_id"` @@ -150,6 +151,10 @@ func (d *DataSourceAddOnDefinition) Schema(ctx context.Context, req datasource.S Computed: true, Description: "The ID of the Terraform agent pool.", }, + "terraform_no_code_module_id": schema.StringAttribute{ + Computed: true, + Description: "The ID of the Terraform no-code module to use for running Terraform operations", + }, }, } } @@ -212,6 +217,9 @@ func (d *DataSourceAddOnDefinition) Read(ctx context.Context, req datasource.Rea state.Summary = types.StringValue(definition.Summary) state.Description = types.StringValue(definition.Description) state.TerraformNoCodeModuleSource = types.StringValue(definition.ModuleSource) + state.TerraformNoCodeModuleID = types.StringValue(definition.ModuleID) + state.TerraformExecutionMode = types.StringValue(definition.TfExecutionMode) + state.TerraformAgentPoolID = types.StringValue(definition.TfAgentPoolID) if definition.TerraformCloudWorkspaceDetails != nil { tfcWorkspace := &tfcWorkspace{ diff --git a/internal/provider/waypoint/data_source_waypoint_add_on_definition_test.go b/internal/provider/waypoint/data_source_waypoint_add_on_definition_test.go index b4301e7d8..78aebb11c 100644 --- a/internal/provider/waypoint/data_source_waypoint_add_on_definition_test.go +++ b/internal/provider/waypoint/data_source_waypoint_add_on_definition_test.go @@ -40,6 +40,7 @@ func TestAccWaypointData_Add_On_Definition_basic(t *testing.T) { Config: testDataAddOnDefinitionConfig(name), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(dataSourceName, "name", name), + resource.TestCheckResourceAttr(dataSourceName, "terraform_no_code_module_id", "nocode-7ZQjQoaPXvzs6Hvp"), resource.TestCheckResourceAttr(dataSourceName, "terraform_execution_mode", "remote"), ), }, diff --git a/internal/provider/waypoint/data_source_waypoint_template.go b/internal/provider/waypoint/data_source_waypoint_template.go index a8c1e0704..3d59e3dac 100644 --- a/internal/provider/waypoint/data_source_waypoint_template.go +++ b/internal/provider/waypoint/data_source_waypoint_template.go @@ -46,6 +46,7 @@ type DataSourceTemplateModel struct { TerraformCloudWorkspace *tfcWorkspace `tfsdk:"terraform_cloud_workspace_details"` TerraformNoCodeModuleSource types.String `tfsdk:"terraform_no_code_module_source"` + TerraformNoCodeModuleID types.String `tfsdk:"terraform_no_code_module_id"` VariableOptions []*tfcVariableOption `tfsdk:"variable_options"` TerraformExecutionMode types.String `tfsdk:"terraform_execution_mode"` TerraformAgentPoolID types.String `tfsdk:"terraform_agent_pool_id"` @@ -150,6 +151,10 @@ func (d *DataSourceTemplate) Schema(ctx context.Context, req datasource.SchemaRe Computed: true, Description: "Terraform agent pool ID", }, + "terraform_no_code_module_id": schema.StringAttribute{ + Computed: true, + Description: "The ID of the Terraform no-code module to use for running Terraform operations", + }, }, } } @@ -211,6 +216,7 @@ func (d *DataSourceTemplate) Read(ctx context.Context, req datasource.ReadReques data.ProjectID = types.StringValue(client.Config.ProjectID) data.Summary = types.StringValue(appTemplate.Summary) data.TerraformNoCodeModuleSource = types.StringValue(appTemplate.ModuleSource) + data.TerraformNoCodeModuleID = types.StringValue(appTemplate.ModuleID) if appTemplate.TerraformCloudWorkspaceDetails != nil { tfcWorkspace := &tfcWorkspace{ diff --git a/internal/provider/waypoint/data_source_waypoint_template_test.go b/internal/provider/waypoint/data_source_waypoint_template_test.go index 66c4ac138..4b67c656c 100644 --- a/internal/provider/waypoint/data_source_waypoint_template_test.go +++ b/internal/provider/waypoint/data_source_waypoint_template_test.go @@ -40,6 +40,7 @@ func TestAccWaypointData_Template_basic(t *testing.T) { Config: testDataAppTemplateConfig(name), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(dataSourceName, "name", name), + resource.TestCheckResourceAttr(dataSourceName, "terraform_no_code_module_id", "nocode-7ZQjQoaPXvzs6Hvp"), resource.TestCheckResourceAttr(dataSourceName, "terraform_execution_mode", "remote"), ), }, diff --git a/internal/provider/waypoint/resource_waypoint_add_on_definition.go b/internal/provider/waypoint/resource_waypoint_add_on_definition.go index aff1feac4..baedfc520 100644 --- a/internal/provider/waypoint/resource_waypoint_add_on_definition.go +++ b/internal/provider/waypoint/resource_waypoint_add_on_definition.go @@ -50,6 +50,7 @@ type AddOnDefinitionResourceModel struct { TerraformProjectID types.String `tfsdk:"terraform_project_id"` TerraformCloudWorkspace types.Object `tfsdk:"terraform_cloud_workspace_details"` TerraformNoCodeModuleSource types.String `tfsdk:"terraform_no_code_module_source"` + TerraformNoCodeModuleID types.String `tfsdk:"terraform_no_code_module_id"` TerraformVariableOptions []*tfcVariableOption `tfsdk:"variable_options"` TerraformExecutionMode types.String `tfsdk:"terraform_execution_mode"` TerraformAgentPoolID types.String `tfsdk:"terraform_agent_pool_id"` @@ -184,6 +185,10 @@ func (r *AddOnDefinitionResource) Schema(ctx context.Context, req resource.Schem "running Terraform operations. This is only applicable when" + " the execution mode is set to 'agent'.", }, + "terraform_no_code_module_id": schema.StringAttribute{ + Required: true, + Description: "The ID of the Terraform no-code module to use for running Terraform operations. This is in the format of 'nocode-'.", + }, }, } } @@ -268,14 +273,17 @@ func (r *AddOnDefinitionResource) Create(ctx context.Context, req resource.Creat } modelBody := &waypointModels.HashicorpCloudWaypointWaypointServiceCreateAddOnDefinitionBody{ - Name: plan.Name.ValueString(), - Summary: plan.Summary.ValueString(), - Description: plan.Description.ValueString(), - Labels: stringLabels, - ModuleSource: plan.TerraformNoCodeModuleSource.ValueString(), - VariableOptions: varOpts, - TfExecutionMode: plan.TerraformExecutionMode.ValueString(), - TfAgentPoolID: plan.TerraformAgentPoolID.ValueString(), + AddOnDefinition: &waypointModels.HashicorpCloudWaypointAddOnDefinition{ + Name: plan.Name.ValueString(), + Summary: plan.Summary.ValueString(), + Description: plan.Description.ValueString(), + Labels: stringLabels, + ModuleSource: plan.TerraformNoCodeModuleSource.ValueString(), + VariableOptions: varOpts, + TfExecutionMode: plan.TerraformExecutionMode.ValueString(), + TfAgentPoolID: plan.TerraformAgentPoolID.ValueString(), + ModuleID: plan.TerraformNoCodeModuleID.ValueString(), + }, } if !plan.TerraformCloudWorkspace.IsNull() && !plan.TerraformCloudWorkspace.IsUnknown() { @@ -294,7 +302,7 @@ func (r *AddOnDefinitionResource) Create(ctx context.Context, req resource.Creat // Set a default if none provided workspaceDetails.TerraformProjectID = plan.TerraformProjectID } - modelBody.TerraformCloudWorkspaceDetails = &waypointModels.HashicorpCloudWaypointTerraformCloudWorkspaceDetails{ + modelBody.AddOnDefinition.TerraformCloudWorkspaceDetails = &waypointModels.HashicorpCloudWaypointTerraformCloudWorkspaceDetails{ Name: workspaceDetails.Name.ValueString(), ProjectID: workspaceDetails.TerraformProjectID.ValueString(), } @@ -302,14 +310,14 @@ func (r *AddOnDefinitionResource) Create(ctx context.Context, req resource.Creat // Decode the base64 encoded readme markdown template to see if it is encoded readmeBytes, err := base64.StdEncoding.DecodeString(plan.ReadmeMarkdownTemplate.ValueString()) - // If there is an error, we assume that it is because the string is not encoded. This is ok and - // we will just use the string as is in the ReadmeTemplate field of the model. - // Eventually the ReadMeMarkdownTemplate field will be deprecated, so the default behavior will be to + // If there is an error, we assume that it is because the string is not encoded. + // This is ok, and we will just use the string as is in the ReadmeTemplate field of the model. + // Eventually, the ReadmeMarkdownTemplate field will be deprecated, so the default behavior will be to // expect the readme to not be encoded if err != nil { - modelBody.ReadmeTemplate = plan.ReadmeMarkdownTemplate.ValueString() + modelBody.AddOnDefinition.ReadmeTemplate = plan.ReadmeMarkdownTemplate.ValueString() } else { - modelBody.ReadmeMarkdownTemplate = readmeBytes + modelBody.AddOnDefinition.ReadmeMarkdownTemplate = readmeBytes } params := &waypoint_service.WaypointServiceCreateAddOnDefinitionParams{ @@ -337,6 +345,7 @@ func (r *AddOnDefinitionResource) Create(ctx context.Context, req resource.Creat plan.OrgID = types.StringValue(orgID) plan.Summary = types.StringValue(addOnDefinition.Summary) plan.TerraformNoCodeModuleSource = types.StringValue(addOnDefinition.ModuleSource) + plan.TerraformNoCodeModuleID = types.StringValue(addOnDefinition.ModuleID) plan.Description = types.StringValue(addOnDefinition.Description) // set plan.description if it's not null or addOnDefinition.description is not empty @@ -431,6 +440,7 @@ func (r *AddOnDefinitionResource) Read(ctx context.Context, req resource.ReadReq state.ProjectID = types.StringValue(client.Config.ProjectID) state.Summary = types.StringValue(definition.Summary) state.TerraformNoCodeModuleSource = types.StringValue(definition.ModuleSource) + state.TerraformNoCodeModuleID = types.StringValue(definition.ModuleID) state.Description = types.StringValue(definition.Description) // set plan.description if it's not null or addOnDefinition.description is not empty @@ -540,14 +550,17 @@ func (r *AddOnDefinitionResource) Update(ctx context.Context, req resource.Updat // TODO: add support for Tags modelBody := &waypointModels.HashicorpCloudWaypointWaypointServiceUpdateAddOnDefinitionBody{ - Name: plan.Name.ValueString(), - Summary: plan.Summary.ValueString(), - Description: plan.Description.ValueString(), - Labels: stringLabels, - ModuleSource: plan.TerraformNoCodeModuleSource.ValueString(), - VariableOptions: varOpts, - TfExecutionMode: plan.TerraformExecutionMode.ValueString(), - TfAgentPoolID: plan.TerraformAgentPoolID.ValueString(), + AddOnDefinition: &waypointModels.HashicorpCloudWaypointAddOnDefinition{ + Name: plan.Name.ValueString(), + Summary: plan.Summary.ValueString(), + Description: plan.Description.ValueString(), + Labels: stringLabels, + ModuleSource: plan.TerraformNoCodeModuleSource.ValueString(), + ModuleID: plan.TerraformNoCodeModuleSource.ValueString(), + VariableOptions: varOpts, + TfExecutionMode: plan.TerraformExecutionMode.ValueString(), + TfAgentPoolID: plan.TerraformAgentPoolID.ValueString(), + }, } if !plan.TerraformCloudWorkspace.IsNull() && !plan.TerraformCloudWorkspace.IsUnknown() { @@ -566,7 +579,7 @@ func (r *AddOnDefinitionResource) Update(ctx context.Context, req resource.Updat // Grab the top level project ID if this was not provided workspaceDetails.TerraformProjectID = plan.TerraformProjectID } - modelBody.TerraformCloudWorkspaceDetails = &waypointModels.HashicorpCloudWaypointTerraformCloudWorkspaceDetails{ + modelBody.AddOnDefinition.TerraformCloudWorkspaceDetails = &waypointModels.HashicorpCloudWaypointTerraformCloudWorkspaceDetails{ Name: workspaceDetails.Name.ValueString(), ProjectID: workspaceDetails.TerraformProjectID.ValueString(), } @@ -574,14 +587,14 @@ func (r *AddOnDefinitionResource) Update(ctx context.Context, req resource.Updat // Decode the base64 encoded readme markdown template to see if it is encoded readmeBytes, err := base64.StdEncoding.DecodeString(plan.ReadmeMarkdownTemplate.ValueString()) - // If there is an error, we assume that it is because the string is not encoded. This is ok and + // If there is an error, we assume that it is because the string is not encoded. This is ok, and // we will just use the string as is in the ReadmeTemplate field of the model. - // Eventually the ReadMeMarkdownTemplate field will be deprecated, so the default behavior will be to + // Eventually, the ReadMeMarkdownTemplate field will be deprecated, so the default behavior will be to // expect the readme to not be encoded if err != nil { - modelBody.ReadmeTemplate = plan.ReadmeMarkdownTemplate.ValueString() + modelBody.AddOnDefinition.ReadmeTemplate = plan.ReadmeMarkdownTemplate.ValueString() } else { - modelBody.ReadmeMarkdownTemplate = readmeBytes + modelBody.AddOnDefinition.ReadmeMarkdownTemplate = readmeBytes } params := &waypoint_service.WaypointServiceUpdateAddOnDefinitionParams{ diff --git a/internal/provider/waypoint/resource_waypoint_add_on_definition_test.go b/internal/provider/waypoint/resource_waypoint_add_on_definition_test.go index 80fcab975..577aa537b 100644 --- a/internal/provider/waypoint/resource_waypoint_add_on_definition_test.go +++ b/internal/provider/waypoint/resource_waypoint_add_on_definition_test.go @@ -35,6 +35,7 @@ func TestAccWaypoint_Add_On_Definition_basic(t *testing.T) { testAccCheckWaypointAddOnDefinitionExists(t, resourceName, &addOnDefinitionModel), testAccCheckWaypointAddOnDefinitionName(t, &addOnDefinitionModel, name), resource.TestCheckResourceAttr(resourceName, "name", name), + resource.TestCheckResourceAttr(resourceName, "terraform_no_code_module_id", "nocode-7ZQjQoaPXvzs6Hvp"), resource.TestCheckResourceAttr(resourceName, "terraform_execution_mode", "remote"), ), }, @@ -134,6 +135,7 @@ resource "hcp_waypoint_add_on_definition" "test" { summary = "some summary for fun" description = "some description for fun" terraform_no_code_module_source = "private/waypoint-tfc-testing/waypoint-template-starter/null" + terraform_no_code_module_id = "nocode-7ZQjQoaPXvzs6Hvp" terraform_project_id = "prj-gfVyPJ2q2Aurn25o" terraform_cloud_workspace_details = { name = "Default Project" diff --git a/internal/provider/waypoint/resource_waypoint_add_on_test.go b/internal/provider/waypoint/resource_waypoint_add_on_test.go index 116eb183f..0e28cd1ac 100644 --- a/internal/provider/waypoint/resource_waypoint_add_on_test.go +++ b/internal/provider/waypoint/resource_waypoint_add_on_test.go @@ -191,6 +191,7 @@ resource "hcp_waypoint_template" "test" { summary = "some summary for fun" readme_markdown_template = base64encode("# Some Readme") terraform_no_code_module_source = "private/waypoint-tfc-testing/waypoint-template-starter/null" + terraform_no_code_module_id = "nocode-7ZQjQoaPXvzs6Hvp" terraform_project_id = "prj-gfVyPJ2q2Aurn25o" terraform_cloud_workspace_details = { name = "Default Project" @@ -209,6 +210,7 @@ resource "hcp_waypoint_add_on_definition" "test" { summary = "some summary for fun" description = "some description for fun" terraform_no_code_module_source = "private/waypoint-tfc-testing/waypoint-template-starter/null" + terraform_no_code_module_id = "nocode-7ZQjQoaPXvzs6Hvp" terraform_project_id = "prj-gfVyPJ2q2Aurn25o" terraform_cloud_workspace_details = { name = "Default Project" @@ -230,6 +232,7 @@ resource "hcp_waypoint_template" "test" { summary = "some summary for fun" readme_markdown_template = base64encode("# Some Readme") terraform_no_code_module_source = "private/waypoint-tfc-testing/waypoint-template-starter/null" + terraform_no_code_module_id = "nocode-7ZQjQoaPXvzs6Hvp" terraform_project_id = "prj-gfVyPJ2q2Aurn25o" terraform_cloud_workspace_details = { name = "Default Project" @@ -249,6 +252,7 @@ resource "hcp_waypoint_add_on_definition" "test_var_opts" { description = "some description for fun" readme_markdown_template = base64encode("# Some Readme") terraform_no_code_module_source = "private/waypoint-tfc-testing/waypoint-vault-dweller/null" + terraform_no_code_module_id = "nocode-JSMkg9ztLBYgg1eW" terraform_project_id = "prj-gfVyPJ2q2Aurn25o" terraform_cloud_workspace_details = { name = "Default Project" @@ -311,6 +315,7 @@ resource "hcp_waypoint_template" "test" { summary = "some summary for fun" readme_markdown_template = base64encode("# Some Readme") terraform_no_code_module_source = "private/waypoint-tfc-testing/waypoint-template-starter/null" + terraform_no_code_module_id = "nocode-7ZQjQoaPXvzs6Hvp" terraform_project_id = "prj-gfVyPJ2q2Aurn25o" terraform_cloud_workspace_details = { name = "Default Project" @@ -330,6 +335,7 @@ resource "hcp_waypoint_add_on_definition" "test_var_opts" { description = "some description" readme_markdown_template = base64encode("# Some Readme") terraform_no_code_module_source = "private/waypoint-tfc-testing/waypoint-vault-dweller/null" + terraform_no_code_module_id = "nocode-JSMkg9ztLBYgg1eW" terraform_project_id = "prj-gfVyPJ2q2Aurn25o" terraform_cloud_workspace_details = { name = "Default Project" diff --git a/internal/provider/waypoint/resource_waypoint_application_test.go b/internal/provider/waypoint/resource_waypoint_application_test.go index d4c1e8760..a7254349f 100644 --- a/internal/provider/waypoint/resource_waypoint_application_test.go +++ b/internal/provider/waypoint/resource_waypoint_application_test.go @@ -193,6 +193,7 @@ resource "hcp_waypoint_template" "test" { summary = "some summary for fun" readme_markdown_template = base64encode("# Some Readme") terraform_no_code_module_source = "private/waypoint-tfc-testing/waypoint-template-starter/null" + terraform_no_code_module_id = "nocode-7ZQjQoaPXvzs6Hvp" terraform_project_id = "prj-gfVyPJ2q2Aurn25o" terraform_cloud_workspace_details = { name = "Default Project" @@ -214,6 +215,7 @@ resource "hcp_waypoint_template" "test_var_opts" { summary = "some summary for fun" readme_markdown_template = base64encode("# Some Readme") terraform_no_code_module_source = "private/waypoint-tfc-testing/waypoint-vault-dweller/null" + terraform_no_code_module_id = "nocode-JSMkg9ztLBYgg1eW" terraform_project_id = "prj-gfVyPJ2q2Aurn25o" terraform_cloud_workspace_details = { name = "Default Project" @@ -273,6 +275,7 @@ resource "hcp_waypoint_template" "test_var_opts" { summary = "some summary for fun" readme_markdown_template = base64encode("# Some Readme") terraform_no_code_module_source = "private/waypoint-tfc-testing/waypoint-vault-dweller/null" + terraform_no_code_module_id = "nocode-JSMkg9ztLBYgg1eW" terraform_project_id = "prj-gfVyPJ2q2Aurn25o" terraform_cloud_workspace_details = { name = "Default Project" diff --git a/internal/provider/waypoint/resource_waypoint_template.go b/internal/provider/waypoint/resource_waypoint_template.go index e9d7de9b3..8605fd056 100644 --- a/internal/provider/waypoint/resource_waypoint_template.go +++ b/internal/provider/waypoint/resource_waypoint_template.go @@ -54,6 +54,7 @@ type TemplateResourceModel struct { TerraformProjectID types.String `tfsdk:"terraform_project_id"` TerraformCloudWorkspace *tfcWorkspace `tfsdk:"terraform_cloud_workspace_details"` TerraformNoCodeModuleSource types.String `tfsdk:"terraform_no_code_module_source"` + TerraformNoCodeModuleID types.String `tfsdk:"terraform_no_code_module_id"` TerraformVariableOptions []*tfcVariableOption `tfsdk:"variable_options"` TerraformExecutionMode types.String `tfsdk:"terraform_execution_mode"` TerraformAgentPoolID types.String `tfsdk:"terraform_agent_pool_id"` @@ -213,6 +214,14 @@ func (r *TemplateResource) Schema(ctx context.Context, req resource.SchemaReques " this template. Required if terraform_execution_mode is " + "set to 'agent'.", }, + "terraform_no_code_module_id": schema.StringAttribute{ + Required: true, + Description: "The ID of the Terraform no-code module to use for" + + " running Terraform operations. This is in the format of 'nocode-'.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplace(), + }, + }, }, } } @@ -303,6 +312,7 @@ func (r *TemplateResource) Create(ctx context.Context, req resource.CreateReques Labels: strLabels, Description: plan.Description.ValueString(), ModuleSource: plan.TerraformNoCodeModuleSource.ValueString(), + ModuleID: plan.TerraformNoCodeModuleID.ValueString(), TerraformCloudWorkspaceDetails: tfWsDetails, VariableOptions: varOpts, TfExecutionMode: plan.TerraformExecutionMode.ValueString(), @@ -313,9 +323,9 @@ func (r *TemplateResource) Create(ctx context.Context, req resource.CreateReques // Decode the base64 encoded readme markdown template to see if it is encoded readmeBytes, err := base64.StdEncoding.DecodeString(plan.ReadmeMarkdownTemplate.ValueString()) - // If there is an error, we assume that it is because the string is not encoded. This is ok and - // we will just use the string as is in the ReadmeTemplate field of the model. - // Eventually the ReadMeMarkdownTemplate field will be deprecated, so the default behavior will be to + // If there is an error, we assume that it is because the string is not encoded. + // This is ok, and we will just use the string as is in the ReadmeTemplate field of the model. + // Eventually, the ReadmeMarkdownTemplate field will be deprecated, so the default behavior will be to // expect the readme to not be encoded if err != nil { modelBody.ApplicationTemplate.ReadmeTemplate = plan.ReadmeMarkdownTemplate.ValueString() @@ -473,6 +483,7 @@ func (r *TemplateResource) Read(ctx context.Context, req resource.ReadRequest, r data.ProjectID = types.StringValue(client.Config.ProjectID) data.Summary = types.StringValue(appTemplate.Summary) data.TerraformNoCodeModuleSource = types.StringValue(appTemplate.ModuleSource) + data.TerraformNoCodeModuleID = types.StringValue(appTemplate.ModuleID) if appTemplate.TerraformCloudWorkspaceDetails != nil { data.TerraformProjectID = types.StringValue(appTemplate.TerraformCloudWorkspaceDetails.ProjectID) @@ -585,6 +596,7 @@ func (r *TemplateResource) Update(ctx context.Context, req resource.UpdateReques Labels: strLabels, Description: plan.Description.ValueString(), ModuleSource: plan.TerraformNoCodeModuleSource.ValueString(), + ModuleID: plan.TerraformNoCodeModuleID.ValueString(), TerraformCloudWorkspaceDetails: tfWsDetails, VariableOptions: varOpts, TfExecutionMode: plan.TerraformExecutionMode.ValueString(), diff --git a/internal/provider/waypoint/resource_waypoint_template_test.go b/internal/provider/waypoint/resource_waypoint_template_test.go index 6840d3547..e40597dc2 100644 --- a/internal/provider/waypoint/resource_waypoint_template_test.go +++ b/internal/provider/waypoint/resource_waypoint_template_test.go @@ -37,6 +37,7 @@ func TestAccWaypoint_Template_basic(t *testing.T) { testAccCheckWaypointTemplateExists(t, resourceName, &appTemplateModel), testAccCheckWaypointTemplateName(t, &appTemplateModel, name), resource.TestCheckResourceAttr(resourceName, "name", name), + resource.TestCheckResourceAttr(resourceName, "terraform_no_code_module_id", "nocode-7ZQjQoaPXvzs6Hvp"), resource.TestCheckResourceAttr(resourceName, "terraform_execution_mode", "remote"), ), }, @@ -159,6 +160,7 @@ resource "hcp_waypoint_template" "test" { summary = "some summary for fun" readme_markdown_template = base64encode("# Some Readme") terraform_no_code_module_source = "private/waypoint-tfc-testing/waypoint-template-starter/null" + terraform_no_code_module_id = "nocode-7ZQjQoaPXvzs6Hvp" terraform_project_id = "prj-gfVyPJ2q2Aurn25o" terraform_cloud_workspace_details = { name = "Default Project" @@ -176,6 +178,7 @@ resource "hcp_waypoint_template" "var_opts_test" { summary = "A template with a variable with options." readme_markdown_template = base64encode("# Some Readme") terraform_no_code_module_source = "private/waypoint-tfc-testing/waypoint-vault-dweller/null" + terraform_no_code_module_id = "nocode-JSMkg9ztLBYgg1eW" terraform_project_id = "prj-gfVyPJ2q2Aurn25o" terraform_cloud_workspace_details = { name = "Default Project" @@ -186,7 +189,12 @@ resource "hcp_waypoint_template" "var_opts_test" { name = "vault_dweller_name" variable_type = "string" user_editable = true - options = [] + options = [ + "lucy", + "courier", + "lone-wanderer", + "sole-survivor", + ] }, { name = "faction"