diff --git a/client/project.go b/client/project.go index 9c84a9be..f650093e 100644 --- a/client/project.go +++ b/client/project.go @@ -231,6 +231,7 @@ type ResourceConfigResponse struct { FunctionDefaultTimeout *int64 `json:"functionDefaultTimeout"` Fluid bool `json:"fluid"` ElasticConcurrencyEnabled bool `json:"elasticConcurrencyEnabled"` + BuildMachineType string `json:"buildMachineType"` } type ResourceConfig struct { @@ -238,6 +239,7 @@ type ResourceConfig struct { FunctionDefaultTimeout *int64 `json:"functionDefaultTimeout,omitempty"` Fluid *bool `json:"fluid,omitempty"` ElasticConcurrencyEnabled *bool `json:"elasticConcurrencyEnabled,omitempty"` + BuildMachineType *string `json:"buildMachineType,omitempty"` } // GetProject retrieves information about an existing project from Vercel. diff --git a/docs/data-sources/project.md b/docs/data-sources/project.md index 1b8719c1..c6cc396b 100644 --- a/docs/data-sources/project.md +++ b/docs/data-sources/project.md @@ -33,6 +33,7 @@ data "vercel_project" "example" { ### Optional +- `build_machine_type` (String) The build machine type to use for this project. - `on_demand_concurrent_builds` (Boolean) Instantly scale build capacity to skip the queue, even if all build slots are in use. You can also choose a larger build machine; charges apply per minute if it exceeds your team's default. - `team_id` (String) The team ID the project exists beneath. Required when configuring a team resource if a default team has not been set in the provider. diff --git a/docs/resources/project.md b/docs/resources/project.md index 9eedbc8b..cac30915 100644 --- a/docs/resources/project.md +++ b/docs/resources/project.md @@ -58,6 +58,7 @@ resource "vercel_project" "example" { - `auto_assign_custom_domains` (Boolean) Automatically assign custom production domains after each Production deployment via merge to the production branch or Vercel CLI deploy with --prod. Defaults to `true` - `automatically_expose_system_environment_variables` (Boolean) Vercel provides a set of Environment Variables that are automatically populated by the System, such as the URL of the Deployment or the name of the Git branch deployed. To expose them to your Deployments, enable this field - `build_command` (String) The build command for this project. If omitted, this value will be automatically detected. +- `build_machine_type` (String) The build machine type to use for this project. Must be one of "enhanced". - `customer_success_code_visibility` (Boolean) Allows Vercel Customer Support to inspect all Deployments' source code in this project to assist with debugging. - `dev_command` (String) The dev command for this project. If omitted, this value will be automatically detected. - `directory_listing` (Boolean) If no index file is present within a directory, the directory contents will be displayed. diff --git a/vercel/data_source_project.go b/vercel/data_source_project.go index 5c41af71..107724bc 100644 --- a/vercel/data_source_project.go +++ b/vercel/data_source_project.go @@ -394,6 +394,11 @@ For more detailed information, please see the [Vercel documentation](https://ver Optional: true, Computed: true, }, + "build_machine_type": schema.StringAttribute{ + Description: "The build machine type to use for this project.", + Optional: true, + Computed: true, + }, }, } } @@ -438,6 +443,7 @@ type ProjectDataSource struct { ResourceConfig types.Object `tfsdk:"resource_config"` NodeVersion types.String `tfsdk:"node_version"` OnDemandConcurrentBuilds types.Bool `tfsdk:"on_demand_concurrent_builds"` + BuildMachineTYpe types.String `tfsdk:"build_machine_type"` } func convertResponseToProjectDataSource(ctx context.Context, response client.ProjectResponse, plan Project, environmentVariables []client.EnvironmentVariable) (ProjectDataSource, error) { @@ -504,6 +510,7 @@ func convertResponseToProjectDataSource(ctx context.Context, response client.Pro ResourceConfig: project.ResourceConfig, NodeVersion: project.NodeVersion, OnDemandConcurrentBuilds: project.OnDemandConcurrentBuilds, + BuildMachineTYpe: project.BuildMachineType, }, nil } diff --git a/vercel/data_source_project_test.go b/vercel/data_source_project_test.go index c38054b0..3c9fbe29 100644 --- a/vercel/data_source_project_test.go +++ b/vercel/data_source_project_test.go @@ -59,6 +59,7 @@ func TestAcc_ProjectDataSource(t *testing.T) { resource.TestCheckResourceAttr("data.vercel_project.test", "oidc_token_config.enabled", "true"), resource.TestCheckResourceAttr("data.vercel_project.test", "oidc_token_config.issuer_mode", "team"), resource.TestCheckResourceAttr("data.vercel_project.test", "on_demand_concurrent_builds", "true"), + resource.TestCheckResourceAttr("data.vercel_project.test", "build_machine_type", "enhanced"), ), }, }, @@ -141,6 +142,7 @@ resource "vercel_project" "test" { issuer_mode = "team" } on_demand_concurrent_builds = true + build_machine_type = "enhanced" } data "vercel_project" "test" { diff --git a/vercel/resource_project.go b/vercel/resource_project.go index 77b93548..e626b5cd 100644 --- a/vercel/resource_project.go +++ b/vercel/resource_project.go @@ -583,6 +583,14 @@ At this time you cannot use a Vercel Project resource with in-line ` + "`environ Computed: true, PlanModifiers: []planmodifier.Bool{boolplanmodifier.UseStateForUnknown()}, }, + "build_machine_type": schema.StringAttribute{ + Description: "The build machine type to use for this project. Must be one of \"enhanced\".", + Optional: true, + Computed: true, + Validators: []validator.String{ + stringvalidator.OneOf("enhanced"), + }, + }, }, } } @@ -635,6 +643,7 @@ type Project struct { SkewProtection types.String `tfsdk:"skew_protection"` ResourceConfig types.Object `tfsdk:"resource_config"` OnDemandConcurrentBuilds types.Bool `tfsdk:"on_demand_concurrent_builds"` + BuildMachineType types.String `tfsdk:"build_machine_type"` } type GitComments struct { @@ -754,7 +763,7 @@ func (p *Project) toCreateProjectRequest(ctx context.Context, envs []Environment PublicSource: p.PublicSource.ValueBoolPointer(), RootDirectory: p.RootDirectory.ValueStringPointer(), ServerlessFunctionRegion: p.ServerlessFunctionRegion.ValueString(), - ResourceConfig: resourceConfig.toClientResourceConfig(p.OnDemandConcurrentBuilds), + ResourceConfig: resourceConfig.toClientResourceConfig(p.OnDemandConcurrentBuilds, p.BuildMachineType), EnablePreviewFeedback: oneBoolPointer(p.EnablePreviewFeedback, p.PreviewComments), EnableProductionFeedback: p.EnableProductionFeedback.ValueBoolPointer(), }, diags @@ -835,7 +844,7 @@ func (p *Project) toUpdateProjectRequest(ctx context.Context, oldName string) (r DirectoryListing: p.DirectoryListing.ValueBool(), SkewProtectionMaxAge: toSkewProtectionAge(p.SkewProtection), GitComments: gc.toUpdateProjectRequest(), - ResourceConfig: resourceConfig.toClientResourceConfig(p.OnDemandConcurrentBuilds), + ResourceConfig: resourceConfig.toClientResourceConfig(p.OnDemandConcurrentBuilds, p.BuildMachineType), NodeVersion: p.NodeVersion.ValueString(), }, nil } @@ -1087,7 +1096,7 @@ func (p *Project) resourceConfig(ctx context.Context) (rc *ResourceConfig, diags return rc, diags } -func (r *ResourceConfig) toClientResourceConfig(onDemandConcurrentBuilds types.Bool) *client.ResourceConfig { +func (r *ResourceConfig) toClientResourceConfig(onDemandConcurrentBuilds types.Bool, buildMachineType types.String) *client.ResourceConfig { if r == nil { return nil } @@ -1105,6 +1114,9 @@ func (r *ResourceConfig) toClientResourceConfig(onDemandConcurrentBuilds types.B if !onDemandConcurrentBuilds.IsUnknown() { resourceConfig.ElasticConcurrencyEnabled = onDemandConcurrentBuilds.ValueBoolPointer() } + if !buildMachineType.IsUnknown() { + resourceConfig.BuildMachineType = buildMachineType.ValueStringPointer() + } return resourceConfig } @@ -1476,6 +1488,7 @@ func convertResponseToProject(ctx context.Context, response client.ProjectRespon ResourceConfig: resourceConfig, NodeVersion: types.StringValue(response.NodeVersion), OnDemandConcurrentBuilds: types.BoolValue(response.ResourceConfig.ElasticConcurrencyEnabled), + BuildMachineType: types.StringValue(response.ResourceConfig.BuildMachineType), }, nil } diff --git a/vercel/resource_project_test.go b/vercel/resource_project_test.go index 8be8cfc8..2437d54f 100644 --- a/vercel/resource_project_test.go +++ b/vercel/resource_project_test.go @@ -83,6 +83,7 @@ func TestAcc_Project(t *testing.T) { resource.TestCheckResourceAttr("vercel_project.test", "resource_config.function_default_cpu_type", "standard"), resource.TestCheckResourceAttr("vercel_project.test", "resource_config.function_default_timeout", "60"), resource.TestCheckResourceAttr("vercel_project.test", "on_demand_concurrent_builds", "true"), + resource.TestCheckResourceAttr("vercel_project.test", "build_machine_type", "enhanced"), ), }, // Update testing @@ -100,6 +101,7 @@ func TestAcc_Project(t *testing.T) { resource.TestCheckResourceAttr("vercel_project.test", "enable_preview_feedback", "false"), resource.TestCheckResourceAttr("vercel_project.test", "enable_production_feedback", "true"), resource.TestCheckResourceAttr("vercel_project.test", "on_demand_concurrent_builds", "false"), + resource.TestCheckResourceAttr("vercel_project.test", "build_machine_type", ""), ), }, // Test mutual exclusivity validation @@ -1066,6 +1068,7 @@ resource "vercel_project" "test" { } ] on_demand_concurrent_builds = true + build_machine_type = "enhanced" } `, projectSuffix) }