Skip to content

Commit 5297168

Browse files
authoredApr 19, 2024
Allow is_development_mode to be updated from true to false (#26)
1 parent ef74459 commit 5297168

File tree

6 files changed

+122
-43
lines changed

6 files changed

+122
-43
lines changed
 

‎docs/resources/deployment.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ resource "astronomer_deployment" "hybrid" {
108108
- `cluster_id` (String) Deployment cluster identifier - required for 'HYBRID' and 'DEDICATED' deployments. If changing this value, the deployment will be recreated in the new cluster
109109
- `default_task_pod_cpu` (String) Deployment default task pod CPU - required for 'STANDARD' and 'DEDICATED' deployments
110110
- `default_task_pod_memory` (String) Deployment default task pod memory - required for 'STANDARD' and 'DEDICATED' deployments
111-
- `is_development_mode` (Boolean) Deployment development mode - required for 'STANDARD' and 'DEDICATED' deployments
111+
- `is_development_mode` (Boolean) Deployment development mode - required for 'STANDARD' and 'DEDICATED' deployments. If changing from 'False' to 'True', the deployment will be recreated
112112
- `is_high_availability` (Boolean) Deployment high availability - required for 'STANDARD' and 'DEDICATED' deployments
113113
- `region` (String) Deployment region - required for 'STANDARD' deployments. If changing this value, the deployment will be recreated in the new region
114114
- `resource_quota_cpu` (String) Deployment resource quota CPU - required for 'STANDARD' and 'DEDICATED' deployments

‎internal/clients/iam/api.gen.go

+48-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎internal/clients/platform/api.gen.go

+25
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎internal/provider/resources/resource_deployment.go

+16-18
Original file line numberDiff line numberDiff line change
@@ -401,15 +401,14 @@ func (r *DeploymentResource) Update(
401401
Executor: platform.UpdateStandardDeploymentRequestExecutor(data.Executor.ValueString()),
402402
IsCicdEnforced: data.IsCicdEnforced.ValueBool(),
403403
IsDagDeployEnabled: data.IsDagDeployEnabled.ValueBool(),
404-
// TODO: Uncomment once this https://github.com/astronomer/astro/pull/19471 is merged
405-
//IsDevelopmentMode: data.IsDevelopmentMode.ValueBoolPointer(),
406-
IsHighAvailability: data.IsHighAvailability.ValueBool(),
407-
Name: data.Name.ValueString(),
408-
ResourceQuotaCpu: data.ResourceQuotaCpu.ValueString(),
409-
ResourceQuotaMemory: data.ResourceQuotaMemory.ValueString(),
410-
SchedulerSize: platform.UpdateStandardDeploymentRequestSchedulerSize(data.SchedulerSize.ValueString()),
411-
Type: platform.UpdateStandardDeploymentRequestTypeSTANDARD,
412-
WorkspaceId: data.WorkspaceId.ValueString(),
404+
IsDevelopmentMode: data.IsDevelopmentMode.ValueBoolPointer(),
405+
IsHighAvailability: data.IsHighAvailability.ValueBool(),
406+
Name: data.Name.ValueString(),
407+
ResourceQuotaCpu: data.ResourceQuotaCpu.ValueString(),
408+
ResourceQuotaMemory: data.ResourceQuotaMemory.ValueString(),
409+
SchedulerSize: platform.UpdateStandardDeploymentRequestSchedulerSize(data.SchedulerSize.ValueString()),
410+
Type: platform.UpdateStandardDeploymentRequestTypeSTANDARD,
411+
WorkspaceId: data.WorkspaceId.ValueString(),
413412
}
414413

415414
// contact emails
@@ -459,15 +458,14 @@ func (r *DeploymentResource) Update(
459458
Executor: platform.UpdateDedicatedDeploymentRequestExecutor(data.Executor.ValueString()),
460459
IsCicdEnforced: data.IsCicdEnforced.ValueBool(),
461460
IsDagDeployEnabled: data.IsDagDeployEnabled.ValueBool(),
462-
// TODO: Uncomment once this https://github.com/astronomer/astro/pull/19471 is merged
463-
//IsDevelopmentMode: data.IsDevelopmentMode.ValueBoolPointer(),
464-
IsHighAvailability: data.IsHighAvailability.ValueBool(),
465-
Name: data.Name.ValueString(),
466-
ResourceQuotaCpu: data.ResourceQuotaCpu.ValueString(),
467-
ResourceQuotaMemory: data.ResourceQuotaMemory.ValueString(),
468-
SchedulerSize: platform.UpdateDedicatedDeploymentRequestSchedulerSize(data.SchedulerSize.ValueString()),
469-
Type: platform.UpdateDedicatedDeploymentRequestTypeDEDICATED,
470-
WorkspaceId: data.WorkspaceId.ValueString(),
461+
IsDevelopmentMode: data.IsDevelopmentMode.ValueBoolPointer(),
462+
IsHighAvailability: data.IsHighAvailability.ValueBool(),
463+
Name: data.Name.ValueString(),
464+
ResourceQuotaCpu: data.ResourceQuotaCpu.ValueString(),
465+
ResourceQuotaMemory: data.ResourceQuotaMemory.ValueString(),
466+
SchedulerSize: platform.UpdateDedicatedDeploymentRequestSchedulerSize(data.SchedulerSize.ValueString()),
467+
Type: platform.UpdateDedicatedDeploymentRequestTypeDEDICATED,
468+
WorkspaceId: data.WorkspaceId.ValueString(),
471469
}
472470

473471
// contact emails

‎internal/provider/resources/resource_deployment_test.go

+19
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,25 @@ func TestAcc_ResourceDeploymentStandard(t *testing.T) {
213213
testAccCheckDeploymentExistence(t, awsDeploymentName, true, true),
214214
),
215215
},
216+
// Change is_development_mode back to false (will not recreate)
217+
{
218+
Config: astronomerprovider.ProviderConfig(t, true) + standardDeployment(standardDeploymentInput{
219+
Name: awsDeploymentName,
220+
Description: utils.TestResourceDescription,
221+
Region: "us-east-1",
222+
CloudProvider: "AWS",
223+
Executor: "KUBERNETES",
224+
SchedulerSize: "SMALL",
225+
IncludeEnvironmentVariables: false,
226+
IsDevelopmentMode: false,
227+
}),
228+
Check: resource.ComposeTestCheckFunc(
229+
resource.TestCheckResourceAttr(awsResourceVar, "scheduler_size", "SMALL"),
230+
resource.TestCheckResourceAttr(awsResourceVar, "is_development_mode", "false"),
231+
// Check via API that deployment exists
232+
testAccCheckDeploymentExistence(t, awsDeploymentName, true, true),
233+
),
234+
},
216235
// Import existing deployment and check it is correctly imported - https://stackoverflow.com/questions/68824711/how-can-i-test-terraform-import-in-acceptance-tests
217236
{
218237
ResourceName: awsResourceVar,

‎internal/provider/schemas/deployment.go

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package schemas
22

33
import (
4+
"context"
45
"regexp"
56

67
"github.com/astronomer/astronomer-terraform-provider/internal/clients/platform"
@@ -252,12 +253,20 @@ func DeploymentResourceSchemaAttributes() map[string]resourceSchema.Attribute {
252253
Optional: true,
253254
},
254255
"is_development_mode": resourceSchema.BoolAttribute{
255-
MarkdownDescription: "Deployment development mode - required for 'STANDARD' and 'DEDICATED' deployments",
256+
MarkdownDescription: "Deployment development mode - required for 'STANDARD' and 'DEDICATED' deployments. If changing from 'False' to 'True', the deployment will be recreated",
256257
Optional: true,
257258
PlanModifiers: []planmodifier.Bool{
258-
// Remove once this https://github.com/astronomer/astro/pull/19471 is merged
259-
// Would recreate the deployment if this attribute changes
260-
boolplanmodifier.RequiresReplaceIfConfigured(),
259+
boolplanmodifier.RequiresReplaceIf(
260+
func(_ context.Context, req planmodifier.BoolRequest, resp *boolplanmodifier.RequiresReplaceIfFuncResponse) {
261+
prevIsDevelopmentMode := req.StateValue.ValueBool()
262+
newIsDevelopmentMode := req.ConfigValue.ValueBool()
263+
if prevIsDevelopmentMode == false && newIsDevelopmentMode == true {
264+
resp.RequiresReplace = true
265+
}
266+
},
267+
"Converting a non-development mode deployment to a development mode deployment is not allowed. Therefore, the deployment will be recreated as a development-mode deployment",
268+
"Converting a non-development mode deployment to a development mode deployment is not allowed. Therefore, the deployment will be recreated as a development-mode deployment",
269+
),
261270
},
262271
},
263272
"resource_quota_cpu": resourceSchema.StringAttribute{

0 commit comments

Comments
 (0)
Failed to load comments.