diff --git a/client/project.go b/client/project.go index e5633e85..79ae2c31 100644 --- a/client/project.go +++ b/client/project.go @@ -225,6 +225,7 @@ type ResourceConfigResponse struct { FunctionDefaultTimeout *int64 `json:"functionDefaultTimeout"` Fluid bool `json:"fluid"` ElasticConcurrencyEnabled bool `json:"elasticConcurrencyEnabled"` + BuildMachineType *string `json:"buildMachineType"` } type ResourceConfig struct { @@ -232,6 +233,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/vercel/data_source_project.go b/vercel/data_source_project.go index 1963ecaf..a76eac9b 100644 --- a/vercel/data_source_project.go +++ b/vercel/data_source_project.go @@ -393,6 +393,14 @@ For more detailed information, please see the [Vercel documentation](https://ver Optional: true, Computed: true, }, + "build_machine_type": schema.StringAttribute{ + Description: "When `on_demand_concurrent_builds` is enabled, choose the build machine: `standard` (4 vCPU, 8 GB) or `enhanced` (8 vCPU, 16GB)", + Optional: true, + Computed: true, + Validators: []validator.String{ + stringvalidator.OneOf("standard", "enhanced"), + }, + }, }, } } @@ -437,6 +445,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) { @@ -503,6 +512,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/resource_project.go b/vercel/resource_project.go index bbd55e52..922cd05f 100644 --- a/vercel/resource_project.go +++ b/vercel/resource_project.go @@ -579,6 +579,15 @@ 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: "When `on_demand_concurrent_builds` is enabled, choose the build machine: `standard` (4 vCPU, 8 GB) or `enhanced` (8 vCPU, 16GB)", + Optional: true, + Computed: true, + Validators: []validator.String{ + stringvalidator.OneOf("standard", "enhanced"), + }, + PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}, + }, }, } } @@ -631,6 +640,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 { @@ -750,7 +760,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 @@ -831,7 +841,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 } @@ -1083,7 +1093,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 } @@ -1101,6 +1111,11 @@ func (r *ResourceConfig) toClientResourceConfig(onDemandConcurrentBuilds types.B if !onDemandConcurrentBuilds.IsUnknown() { resourceConfig.ElasticConcurrencyEnabled = onDemandConcurrentBuilds.ValueBoolPointer() } + if !buildMachineType.IsUnknown() && *resourceConfig.ElasticConcurrencyEnabled { + // `build_machine_type` can only be set when `on_demand_concurrent_builds` + // is enabled. + resourceConfig.BuildMachineType = buildMachineType.ValueStringPointer() + } return resourceConfig } @@ -1472,6 +1487,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 }