diff --git a/docs/data-sources/project_function_cpu.md b/docs/data-sources/project_function_cpu.md deleted file mode 100644 index 0f948eb3..00000000 --- a/docs/data-sources/project_function_cpu.md +++ /dev/null @@ -1,45 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "vercel_project_function_cpu Data Source - terraform-provider-vercel" -subcategory: "" -description: |- - ~> This data source has been deprecated and no longer works. Please use the vercel_project data source and its resource_config attribute instead. - Provides information about a Project's Function CPU setting. - This controls the maximum amount of CPU utilization your Serverless Functions can use while executing. Standard is optimal for most frontend workloads. You can override this per function using the vercel.json file. ---- - -# vercel_project_function_cpu (Data Source) - -~> This data source has been deprecated and no longer works. Please use the `vercel_project` data source and its `resource_config` attribute instead. - -Provides information about a Project's Function CPU setting. - -This controls the maximum amount of CPU utilization your Serverless Functions can use while executing. Standard is optimal for most frontend workloads. You can override this per function using the vercel.json file. - -## Example Usage - -```terraform -data "vercel_project" "example" { - name = "example" -} - -data "vercel_project_function_cpu" "example" { - project_id = data.vercel_project.example.id -} -``` - - -## Schema - -### Required - -- `project_id` (String) The ID of the Project to read the Function CPU setting for. - -### Optional - -- `team_id` (String) The ID of the team the Project exists under. Required when configuring a team resource if a default team has not been set in the provider. - -### Read-Only - -- `cpu` (String) The amount of CPU available to your Serverless Functions. Should be one of 'basic' (0.6vCPU), 'standard' (1vCPU) or 'performance' (1.7vCPUs). -- `id` (String) The ID of the resource. diff --git a/docs/resources/project_function_cpu.md b/docs/resources/project_function_cpu.md deleted file mode 100644 index d1b59242..00000000 --- a/docs/resources/project_function_cpu.md +++ /dev/null @@ -1,60 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "vercel_project_function_cpu Resource - terraform-provider-vercel" -subcategory: "" -description: |- - ~> This resource has been deprecated and no longer works. Please use the vercel_project resource and its resource_config attribute instead. - Provides a Function CPU resource for a Project. - This controls the maximum amount of CPU utilization your Serverless Functions can use while executing. Standard is optimal for most frontend workloads. You can override this per function using the vercel.json file. - A new Deployment is required for your changes to take effect. ---- - -# vercel_project_function_cpu (Resource) - -~> This resource has been deprecated and no longer works. Please use the `vercel_project` resource and its `resource_config` attribute instead. - -Provides a Function CPU resource for a Project. - -This controls the maximum amount of CPU utilization your Serverless Functions can use while executing. Standard is optimal for most frontend workloads. You can override this per function using the vercel.json file. - -A new Deployment is required for your changes to take effect. - -## Example Usage - -```terraform -resource "vercel_project" "example" { - name = "example" -} - -resource "vercel_project_function_cpu" "example" { - project_id = vercel_project.example.id - cpu = "performance" -} -``` - - -## Schema - -### Required - -- `cpu` (String) The amount of CPU available to your Serverless Functions. Should be one of 'basic' (0.6vCPU), 'standard' (1vCPU) or 'performance' (1.7vCPUs). -- `project_id` (String) The ID of the Project to adjust the CPU for. - -### Optional - -- `team_id` (String) The ID of the team the Project exists under. Required when configuring a team resource if a default team has not been set in the provider. - -### Read-Only - -- `id` (String) The ID of the resource. - -## Import - -Import is supported using the following syntax: - -```shell -# You can import via the team_id and project_id. -# - team_id can be found in the team `settings` tab in the Vercel UI. -# - project_id can be found in the project `settings` tab in the Vercel UI. -terraform import vercel_project_function_cpu.example team_xxxxxxxxxxxxxxxxxxxxxxxx/prj_xxxxxxxxxxxxxxxxxxxxxxxxxxxx -``` diff --git a/examples/data-sources/vercel_project_function_cpu/data-source.tf b/examples/data-sources/vercel_project_function_cpu/data-source.tf deleted file mode 100644 index 7e34053b..00000000 --- a/examples/data-sources/vercel_project_function_cpu/data-source.tf +++ /dev/null @@ -1,7 +0,0 @@ -data "vercel_project" "example" { - name = "example" -} - -data "vercel_project_function_cpu" "example" { - project_id = data.vercel_project.example.id -} diff --git a/examples/resources/vercel_project_function_cpu/import.sh b/examples/resources/vercel_project_function_cpu/import.sh deleted file mode 100644 index 59885053..00000000 --- a/examples/resources/vercel_project_function_cpu/import.sh +++ /dev/null @@ -1,4 +0,0 @@ -# You can import via the team_id and project_id. -# - team_id can be found in the team `settings` tab in the Vercel UI. -# - project_id can be found in the project `settings` tab in the Vercel UI. -terraform import vercel_project_function_cpu.example team_xxxxxxxxxxxxxxxxxxxxxxxx/prj_xxxxxxxxxxxxxxxxxxxxxxxxxxxx diff --git a/examples/resources/vercel_project_function_cpu/resource.tf b/examples/resources/vercel_project_function_cpu/resource.tf deleted file mode 100644 index 399cbfba..00000000 --- a/examples/resources/vercel_project_function_cpu/resource.tf +++ /dev/null @@ -1,8 +0,0 @@ -resource "vercel_project" "example" { - name = "example" -} - -resource "vercel_project_function_cpu" "example" { - project_id = vercel_project.example.id - cpu = "performance" -} diff --git a/vercel/data_source_project_function_cpu.go b/vercel/data_source_project_function_cpu.go deleted file mode 100644 index 701fe2e1..00000000 --- a/vercel/data_source_project_function_cpu.go +++ /dev/null @@ -1,121 +0,0 @@ -package vercel - -import ( - "context" - "fmt" - - "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/vercel/terraform-provider-vercel/client" -) - -// Ensure the implementation satisfies the expected interfaces. -var ( - _ datasource.DataSource = &projectFunctionCPUDataSource{} - _ datasource.DataSourceWithConfigure = &projectFunctionCPUDataSource{} -) - -func newProjectFunctionCPUDataSource() datasource.DataSource { - return &projectFunctionCPUDataSource{} -} - -type projectFunctionCPUDataSource struct { - client *client.Client -} - -func (d *projectFunctionCPUDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_project_function_cpu" -} - -func (d *projectFunctionCPUDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { - // Prevent panic if the provider has not been configured. - if req.ProviderData == nil { - return - } - - client, ok := req.ProviderData.(*client.Client) - if !ok { - resp.Diagnostics.AddError( - "Unexpected Data Source Configure Type", - fmt.Sprintf("Expected *client.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), - ) - return - } - - d.client = client -} - -func (r *projectFunctionCPUDataSource) Schema(_ context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = schema.Schema{ - DeprecationMessage: "This data source is deprecated and no longer works. Please use the `vercel_project` data source and its `resource_config` attribute instead.", - Description: ` -~> This data source has been deprecated and no longer works. Please use the ` + "`vercel_project`" + ` data source and its ` + "`resource_config`" + ` attribute instead. - -Provides information about a Project's Function CPU setting. - -This controls the maximum amount of CPU utilization your Serverless Functions can use while executing. Standard is optimal for most frontend workloads. You can override this per function using the vercel.json file. -`, - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Description: "The ID of the resource.", - Computed: true, - }, - "project_id": schema.StringAttribute{ - Description: "The ID of the Project to read the Function CPU setting for.", - Required: true, - }, - "team_id": schema.StringAttribute{ - Optional: true, - Computed: true, - Description: "The ID of the team the Project exists under. Required when configuring a team resource if a default team has not been set in the provider.", - }, - "cpu": schema.StringAttribute{ - Description: "The amount of CPU available to your Serverless Functions. Should be one of 'basic' (0.6vCPU), 'standard' (1vCPU) or 'performance' (1.7vCPUs).", - Computed: true, - }, - }, - } -} - -func (d *projectFunctionCPUDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - resp.Diagnostics.Append( - diag.NewErrorDiagnostic("`vercel_project_function_cpu` data source deprecated", "use `vercel_project` data source and its `resource_config` attribute instead"), - ) - var config ProjectFunctionCPU - diags := req.Config.Get(ctx, &config) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - out, err := d.client.GetProjectFunctionCPU(ctx, config.ProjectID.ValueString(), config.TeamID.ValueString()) - if client.NotFound(err) { - resp.State.RemoveResource(ctx) - return - } - if err != nil { - resp.Diagnostics.AddError( - "Error reading project Function CPU", - fmt.Sprintf("Could not get Project Function CPU %s %s, unexpected error: %s", - config.TeamID.ValueString(), - config.ProjectID.ValueString(), - err, - ), - ) - return - } - - result := convertResponseToProjectFunctionCPU(out) - tflog.Info(ctx, "read project function cpu", map[string]interface{}{ - "team_id": result.TeamID.ValueString(), - "project_id": result.ProjectID.ValueString(), - }) - - diags = resp.State.Set(ctx, result) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } -} diff --git a/vercel/data_source_project_function_cpu_test.go b/vercel/data_source_project_function_cpu_test.go deleted file mode 100644 index cc6f62b8..00000000 --- a/vercel/data_source_project_function_cpu_test.go +++ /dev/null @@ -1,81 +0,0 @@ -package vercel_test - -import ( - "fmt" - "testing" - - "github.com/hashicorp/terraform-plugin-testing/helper/acctest" - "github.com/hashicorp/terraform-plugin-testing/helper/resource" -) - -func TestAcc_ProjectFunctionCPUDataSource(t *testing.T) { - t.Skip("the resource is deprecated and tests should be removed in the next release") - name := acctest.RandString(16) - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, - Steps: []resource.TestStep{ - { - Config: testAccProjectFunctionCPUDataSourceConfig(name, teamIDConfig()), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("data.vercel_project_function_cpu.basic", "cpu", "basic"), - resource.TestCheckResourceAttr("data.vercel_project_function_cpu.standard", "cpu", "standard"), - resource.TestCheckResourceAttr("data.vercel_project_function_cpu.performance", "cpu", "performance"), - ), - }, - }, - }) -} - -func testAccProjectFunctionCPUDataSourceConfig(name, teamID string) string { - return fmt.Sprintf(` -resource "vercel_project" "basic" { - name = "test-acc-%[1]s" - %[2]s -} - -resource "vercel_project_function_cpu" "basic" { - project_id = vercel_project.basic.id - cpu = "basic" - %[2]s -} - -data "vercel_project_function_cpu" "basic" { - project_id = vercel_project_function_cpu.basic.project_id - %[2]s -} - -resource "vercel_project" "standard" { - name = "test-acc-%[1]s-standard" - %[2]s -} - -resource "vercel_project_function_cpu" "standard" { - project_id = vercel_project.standard.id - cpu = "standard" - %[2]s -} - -data "vercel_project_function_cpu" "standard" { - project_id = vercel_project_function_cpu.standard.project_id - %[2]s -} - -resource "vercel_project" "performance" { - name = "test-acc-%[1]s-performance" - %[2]s -} - -resource "vercel_project_function_cpu" "performance" { - project_id = vercel_project.performance.id - cpu = "performance" - %[2]s -} - -data "vercel_project_function_cpu" "performance" { - project_id = vercel_project_function_cpu.performance.project_id - %[2]s -} - -`, name, teamID) -} diff --git a/vercel/provider.go b/vercel/provider.go index f741f3f4..c03076d9 100644 --- a/vercel/provider.go +++ b/vercel/provider.go @@ -63,7 +63,6 @@ func (p *vercelProvider) Resources(_ context.Context) []func() resource.Resource newProjectDeploymentRetentionResource, newProjectDomainResource, newProjectEnvironmentVariableResource, - newProjectFunctionCPUResource, newProjectResource, newSharedEnvironmentVariableResource, newWebhookResource, @@ -86,7 +85,6 @@ func (p *vercelProvider) DataSources(_ context.Context) []func() datasource.Data newProjectDataSource, newProjectDeploymentRetentionDataSource, newProjectDirectoryDataSource, - newProjectFunctionCPUDataSource, newSharedEnvironmentVariableDataSource, } } diff --git a/vercel/resource_project_function_cpu.go b/vercel/resource_project_function_cpu.go deleted file mode 100644 index 31732b25..00000000 --- a/vercel/resource_project_function_cpu.go +++ /dev/null @@ -1,266 +0,0 @@ -package vercel - -import ( - "context" - "fmt" - - "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/resource" - "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/vercel/terraform-provider-vercel/client" -) - -// Ensure the implementation satisfies the expected interfaces. -var ( - _ resource.Resource = &projectFunctionCPUResource{} - _ resource.ResourceWithConfigure = &projectFunctionCPUResource{} - _ resource.ResourceWithImportState = &projectFunctionCPUResource{} -) - -func newProjectFunctionCPUResource() resource.Resource { - return &projectFunctionCPUResource{} -} - -type projectFunctionCPUResource struct { - client *client.Client -} - -func (r *projectFunctionCPUResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_project_function_cpu" -} - -func (r *projectFunctionCPUResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { - // Prevent panic if the provider has not been configured. - if req.ProviderData == nil { - return - } - - client, ok := req.ProviderData.(*client.Client) - if !ok { - resp.Diagnostics.AddError( - "Unexpected Resource Configure Type", - fmt.Sprintf("Expected *client.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), - ) - return - } - - r.client = client -} - -// Schema returns the schema information for an alias resource. -func (r *projectFunctionCPUResource) Schema(_ context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { - resp.Schema = schema.Schema{ - DeprecationMessage: "This resource is deprecated and no longer works. Please use the `vercel_project` resource and its `resource_config` attribute instead.", - Description: ` -~> This resource has been deprecated and no longer works. Please use the ` + "`vercel_project`" + ` resource and its ` + "`resource_config`" + ` attribute instead. - -Provides a Function CPU resource for a Project. - -This controls the maximum amount of CPU utilization your Serverless Functions can use while executing. Standard is optimal for most frontend workloads. You can override this per function using the vercel.json file. - -A new Deployment is required for your changes to take effect. -`, - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Description: "The ID of the resource.", - Computed: true, - PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}, - }, - "project_id": schema.StringAttribute{ - Description: "The ID of the Project to adjust the CPU for.", - Required: true, - PlanModifiers: []planmodifier.String{stringplanmodifier.RequiresReplace()}, - }, - "team_id": schema.StringAttribute{ - Optional: true, - Computed: true, - Description: "The ID of the team the Project exists under. Required when configuring a team resource if a default team has not been set in the provider.", - PlanModifiers: []planmodifier.String{stringplanmodifier.RequiresReplaceIfConfigured(), stringplanmodifier.UseStateForUnknown()}, - }, - "cpu": schema.StringAttribute{ - Description: "The amount of CPU available to your Serverless Functions. Should be one of 'basic' (0.6vCPU), 'standard' (1vCPU) or 'performance' (1.7vCPUs).", - Required: true, - }, - }, - } -} - -type ProjectFunctionCPU struct { - ID types.String `tfsdk:"id"` - ProjectID types.String `tfsdk:"project_id"` - TeamID types.String `tfsdk:"team_id"` - CPU types.String `tfsdk:"cpu"` -} - -func convertResponseToProjectFunctionCPU(response client.ProjectFunctionCPU) ProjectFunctionCPU { - return ProjectFunctionCPU{ - ID: types.StringValue(response.ProjectID), - TeamID: toTeamID(response.TeamID), - ProjectID: types.StringValue(response.ProjectID), - CPU: types.StringPointerValue(response.CPU), - } -} - -func (r *projectFunctionCPUResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - resp.Diagnostics.Append( - diag.NewErrorDiagnostic("`vercel_project_function_cpu` resource deprecated", "use `vercel_project` resource and its `resource_config` attribute instead"), - ) - - var plan ProjectFunctionCPU - diags := req.Plan.Get(ctx, &plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - out, err := r.client.UpdateProjectFunctionCPU(ctx, client.ProjectFunctionCPURequest{ - ProjectID: plan.ProjectID.ValueString(), - CPU: plan.CPU.ValueString(), - TeamID: plan.TeamID.ValueString(), - }) - if err != nil { - resp.Diagnostics.AddError( - "Error updating project Function CPU", - "Could not update function CPU, unexpected error: "+err.Error(), - ) - return - } - - result := convertResponseToProjectFunctionCPU(out) - tflog.Info(ctx, "created project function cpu", map[string]interface{}{ - "team_id": plan.TeamID.ValueString(), - "project_id": plan.ProjectID.ValueString(), - "cpu": result.CPU.ValueString(), - }) - - diags = resp.State.Set(ctx, result) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } -} - -func (r *projectFunctionCPUResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { - resp.Diagnostics.Append( - diag.NewErrorDiagnostic("`vercel_project_function_cpu` resource deprecated", "use `vercel_project` resource and its `resource_config` attribute instead"), - ) - var state ProjectFunctionCPU - diags := req.State.Get(ctx, &state) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - out, err := r.client.GetProjectFunctionCPU(ctx, state.ProjectID.ValueString(), state.TeamID.ValueString()) - if client.NotFound(err) { - resp.State.RemoveResource(ctx) - return - } - if err != nil { - resp.Diagnostics.AddError( - "Error reading project Function CPU", - fmt.Sprintf("Could not get Project Function CPU %s %s, unexpected error: %s", - state.TeamID.ValueString(), - state.ProjectID.ValueString(), - err, - ), - ) - return - } - - result := convertResponseToProjectFunctionCPU(out) - tflog.Info(ctx, "read project function cpu", map[string]interface{}{ - "team_id": result.TeamID.ValueString(), - "project_id": result.ProjectID.ValueString(), - }) - - diags = resp.State.Set(ctx, result) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } -} - -func (r *projectFunctionCPUResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { - resp.Diagnostics.Append( - diag.NewErrorDiagnostic("`vercel_project_function_cpu` resource deprecated", "use `vercel_project` resource and its `resource_config` attribute instead"), - ) - var plan ProjectFunctionCPU - diags := req.Plan.Get(ctx, &plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - out, err := r.client.UpdateProjectFunctionCPU(ctx, client.ProjectFunctionCPURequest{ - ProjectID: plan.ProjectID.ValueString(), - CPU: plan.CPU.ValueString(), - TeamID: plan.TeamID.ValueString(), - }) - if err != nil { - resp.Diagnostics.AddError( - "Error updating project Function CPU", - "Could not update function CPU, unexpected error: "+err.Error(), - ) - return - } - - result := convertResponseToProjectFunctionCPU(out) - tflog.Info(ctx, "created project function cpu", map[string]interface{}{ - "team_id": plan.TeamID.ValueString(), - "project_id": plan.ProjectID.ValueString(), - "cpu": result.CPU.ValueString(), - }) - - diags = resp.State.Set(ctx, result) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } -} - -func (r *projectFunctionCPUResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { - resp.Diagnostics.Append( - diag.NewErrorDiagnostic("`vercel_project_function_cpu` resource deprecated", "use `vercel_project` resource and its `resource_config` attribute instead"), - ) - tflog.Info(ctx, "deleted project function cpu", map[string]interface{}{}) -} - -func (r *projectFunctionCPUResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { - teamID, projectID, ok := splitInto1Or2(req.ID) - if !ok { - resp.Diagnostics.AddError( - "Error importing Project Function CPU", - fmt.Sprintf("Invalid id '%s' specified. should be in format \"team_id/project_id\" or \"project_id\"", req.ID), - ) - } - - out, err := r.client.GetProjectFunctionCPU(ctx, projectID, teamID) - if err != nil { - resp.Diagnostics.AddError( - "Error reading Project Function CPU", - fmt.Sprintf("Could not get Project Function CPU %s %s, unexpected error: %s", - teamID, - projectID, - err, - ), - ) - return - } - - result := convertResponseToProjectFunctionCPU(out) - tflog.Info(ctx, "import project function cpu", map[string]interface{}{ - "team_id": result.TeamID.ValueString(), - "project_id": result.ProjectID.ValueString(), - }) - - diags := resp.State.Set(ctx, result) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } -} diff --git a/vercel/resource_project_function_cpu_test.go b/vercel/resource_project_function_cpu_test.go deleted file mode 100644 index 7713754e..00000000 --- a/vercel/resource_project_function_cpu_test.go +++ /dev/null @@ -1,120 +0,0 @@ -package vercel_test - -import ( - "fmt" - "testing" - - "github.com/hashicorp/terraform-plugin-testing/helper/acctest" - "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/terraform" -) - -func TestAcc_ProjectFunctionCPUResource(t *testing.T) { - t.Skip("the resource is deprecated and tests should be removed in the next release") - name := acctest.RandString(16) - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, - Steps: []resource.TestStep{ - { - Config: testAccProjectFunctionCPUResourceConfig(name, teamIDConfig()), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("vercel_project_function_cpu.basic", "cpu", "basic"), - resource.TestCheckResourceAttr("vercel_project_function_cpu.standard", "cpu", "standard"), - resource.TestCheckResourceAttr("vercel_project_function_cpu.performance", "cpu", "performance"), - ), - }, - { - ImportState: true, - ResourceName: "vercel_project_function_cpu.basic", - ImportStateIdFunc: func(s *terraform.State) (string, error) { - rs, ok := s.RootModule().Resources["vercel_project_function_cpu.basic"] - if !ok { - return "", fmt.Errorf("resource not found") - } - return fmt.Sprintf("%s/%s", rs.Primary.Attributes["team_id"], rs.Primary.ID), nil - }, - }, - { - ImportState: true, - ResourceName: "vercel_project_function_cpu.standard", - ImportStateIdFunc: func(s *terraform.State) (string, error) { - rs, ok := s.RootModule().Resources["vercel_project_function_cpu.standard"] - if !ok { - return "", fmt.Errorf("resource not found") - } - return fmt.Sprintf("%s/%s", rs.Primary.Attributes["team_id"], rs.Primary.ID), nil - }, - }, - { - ImportState: true, - ResourceName: "vercel_project_function_cpu.performance", - ImportStateIdFunc: func(s *terraform.State) (string, error) { - rs, ok := s.RootModule().Resources["vercel_project_function_cpu.performance"] - if !ok { - return "", fmt.Errorf("resource not found") - } - return fmt.Sprintf("%s/%s", rs.Primary.Attributes["team_id"], rs.Primary.ID), nil - }, - }, - { - Config: testAccProjectFunctionCPUResourceConfigUpdated(name, teamIDConfig()), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("vercel_project_function_cpu.basic", "cpu", "performance"), - ), - }, - }, - }) -} - -func testAccProjectFunctionCPUResourceConfig(name, teamID string) string { - return fmt.Sprintf(` -resource "vercel_project" "basic" { - name = "test-acc-%[1]s" - %[2]s -} - -resource "vercel_project_function_cpu" "basic" { - project_id = vercel_project.basic.id - cpu = "basic" - %[2]s -} - -resource "vercel_project" "standard" { - name = "test-acc-%[1]s-standard" - %[2]s -} - -resource "vercel_project_function_cpu" "standard" { - project_id = vercel_project.standard.id - cpu = "standard" - %[2]s -} - -resource "vercel_project" "performance" { - name = "test-acc-%[1]s-performance" - %[2]s -} - -resource "vercel_project_function_cpu" "performance" { - project_id = vercel_project.performance.id - cpu = "performance" - %[2]s -} -`, name, teamID) -} - -func testAccProjectFunctionCPUResourceConfigUpdated(name, teamID string) string { - return fmt.Sprintf(` -resource "vercel_project" "basic" { - name = "test-acc-%[1]s" - %[2]s -} - -resource "vercel_project_function_cpu" "basic" { - project_id = vercel_project.basic.id - cpu = "performance" - %[2]s -} -`, name, teamID) -}