Skip to content

Commit 314367c

Browse files
committed
move to single deployment resource
1 parent d0f96d3 commit 314367c

13 files changed

+1903
-1355
lines changed

.github/workflows/testacc.yml

+3
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ jobs:
6060
HYBRID_ORGANIZATION_ID: ckmzjm22937931d35puw3tcdo
6161
HOSTED_ORGANIZATION_API_TOKEN: ${{ secrets.DEV_HOSTED_ORGANIZATION_API_TOKEN }}
6262
HOSTED_ORGANIZATION_ID: clczfgzc3001o01kjlphpi6hv
63+
HYBRID_CLUSTER_ID: clk8h0fv1006801j8yysfybbt
64+
HYBRID_NODE_POOL_ID: clk8h0fv1006701j8ku45qtb9
6365
ASTRO_API_HOST: https://api.astronomer-dev.io
66+
TESTARGS: "-failfast"
6467
run: make testacc
6568
timeout-minutes: 10
6669

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ OAPI_CODEGEN ?= $(ENVTEST_ASSETS_DIR)/oapi-codegen
1212
# Run acceptance tests
1313
.PHONY: testacc
1414
testacc:
15-
TF_ACC=1 go test ./... -v -failfast -run TestAcc $(TESTARGS) -timeout 120m
15+
TF_ACC=1 go test ./... -v -run TestAcc $(TESTARGS) -timeout 120m
1616

1717
# Run unit tests
1818
.PHONY: test

docs/resources/standard_deployment.md docs/resources/deployment.md

+32-24
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
22
# generated by https://github.com/hashicorp/terraform-plugin-docs
3-
page_title: "astronomer_standard_deployment Resource - astronomer"
3+
page_title: "astronomer_deployment Resource - astronomer"
44
subcategory: ""
55
description: |-
6-
Standard Deployment resource
6+
Deployment resource
77
---
88

9-
# astronomer_standard_deployment (Resource)
9+
# astronomer_deployment (Resource)
1010

11-
Standard Deployment resource
11+
Deployment resource
1212

1313

1414

@@ -17,27 +17,32 @@ Standard Deployment resource
1717

1818
### Required
1919

20-
- `cloud_provider` (String) Deployment cloud provider - if changing this value, the deployment will be recreated in the new cloud provider
2120
- `contact_emails` (List of String) Deployment contact emails
22-
- `default_task_pod_cpu` (String) Deployment default task pod CPU
23-
- `default_task_pod_memory` (String) Deployment default task pod memory
2421
- `description` (String) Deployment description
2522
- `environment_variables` (Attributes List) Deployment environment variables (see [below for nested schema](#nestedatt--environment_variables))
2623
- `executor` (String) Deployment executor
2724
- `is_cicd_enforced` (Boolean) Deployment CI/CD enforced
2825
- `is_dag_deploy_enabled` (Boolean) Deployment DAG deploy enabled
29-
- `is_development_mode` (Boolean) Deployment development mode
30-
- `is_high_availability` (Boolean) Deployment high availability
3126
- `name` (String) Deployment name
32-
- `region` (String) Deployment region - if changing this value, the deployment will be recreated in the new region
33-
- `resource_quota_cpu` (String) Deployment resource quota CPU
34-
- `resource_quota_memory` (String) Deployment resource quota memory
35-
- `scheduler_size` (String) Deployment scheduler size
27+
- `type` (String) Deployment type - if changing this value, the deployment will be recreated with the new type
3628
- `workspace_id` (String) Deployment workspace identifier
3729

3830
### Optional
3931

40-
- `scaling_spec` (Attributes) Deployment scaling spec (see [below for nested schema](#nestedatt--scaling_spec))
32+
- `cloud_provider` (String) Deployment cloud provider - required for 'STANDARD' deployments. If changing this value, the deployment will be recreated in the new cloud provider
33+
- `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
34+
- `default_task_pod_cpu` (String) Deployment default task pod CPU - required for 'STANDARD' and 'DEDICATED' deployments
35+
- `default_task_pod_memory` (String) Deployment default task pod memory - required for 'STANDARD' and 'DEDICATED' deployments
36+
- `is_development_mode` (Boolean) Deployment development mode - required for 'STANDARD' and 'DEDICATED' deployments
37+
- `is_high_availability` (Boolean) Deployment high availability - required for 'STANDARD' and 'DEDICATED' deployments
38+
- `region` (String) Deployment region - required for 'STANDARD' deployments. If changing this value, the deployment will be recreated in the new region
39+
- `resource_quota_cpu` (String) Deployment resource quota CPU - required for 'STANDARD' and 'DEDICATED' deployments
40+
- `resource_quota_memory` (String) Deployment resource quota memory - required for 'STANDARD' and 'DEDICATED' deployments
41+
- `scaling_spec` (Attributes) Deployment scaling spec - only for 'STANDARD' and 'DEDICATED' deployments (see [below for nested schema](#nestedatt--scaling_spec))
42+
- `scheduler_au` (Number) Deployment scheduler AU - required for 'HYBRID' deployments
43+
- `scheduler_replicas` (Number) Deployment scheduler replicas - required for 'HYBRID' deployments
44+
- `scheduler_size` (String) Deployment scheduler size - required for 'STANDARD' and 'DEDICATED' deployments
45+
- `task_pod_node_pool_id` (String) Deployment task pod node pool identifier - required if executor is 'KUBERNETES' and type is 'HYBRID'
4146
- `worker_queues` (Attributes List) Deployment worker queues (see [below for nested schema](#nestedatt--worker_queues))
4247

4348
### Read-Only
@@ -58,7 +63,6 @@ Standard Deployment resource
5863
- `scaling_status` (Attributes) Deployment scaling status (see [below for nested schema](#nestedatt--scaling_status))
5964
- `scheduler_cpu` (String) Deployment scheduler CPU
6065
- `scheduler_memory` (String) Deployment scheduler memory
61-
- `scheduler_replicas` (Number) Deployment scheduler replicas
6266
- `status` (String) Deployment status
6367
- `status_reason` (String) Deployment status reason
6468
- `updated_at` (String) Deployment last updated timestamp
@@ -131,18 +135,22 @@ Optional:
131135

132136
Required:
133137

134-
- `astro_machine` (String)
135-
- `is_default` (Boolean)
136-
- `max_worker_count` (Number)
137-
- `min_worker_count` (Number)
138-
- `name` (String)
139-
- `worker_concurrency` (Number)
138+
- `is_default` (Boolean) Worker queue default
139+
- `max_worker_count` (Number) Worker queue max worker count
140+
- `min_worker_count` (Number) Worker queue min worker count
141+
- `name` (String) Worker queue name
142+
- `worker_concurrency` (Number) Worker queue worker concurrency
143+
144+
Optional:
145+
146+
- `astro_machine` (String) Worker queue Astro machine value - required for 'STANDARD' and 'DEDICATED' deployments
147+
- `node_pool_id` (String) Worker queue Node pool identifier - required for 'HYBRID' deployments
140148

141149
Read-Only:
142150

143-
- `id` (String)
144-
- `pod_cpu` (String)
145-
- `pod_memory` (String)
151+
- `id` (String) Worker queue identifier
152+
- `pod_cpu` (String) Worker queue pod CPU
153+
- `pod_memory` (String) Worker queue pod memory
146154

147155

148156
<a id="nestedatt--created_by"></a>

internal/provider/datasources/data_source_deployments_test.go

+58-25
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ func TestAcc_DataSourceDeployments(t *testing.T) {
2222
},
2323
ProtoV6ProviderFactories: astronomerprovider.TestAccProtoV6ProviderFactories,
2424
Steps: []resource.TestStep{
25+
//Check the data source for deployments for a hosted organization
2526
{
26-
Config: astronomerprovider.ProviderConfig(t, true) + deployments(deploymentName),
27+
Config: astronomerprovider.ProviderConfig(t, true) + hostedDeployments(deploymentName),
2728
Check: resource.ComposeTestCheckFunc(
2829
// Doing all checks in one step because we do not want to unnecessarily create multiple deployments for the data sources test
2930

@@ -84,19 +85,43 @@ func TestAcc_DataSourceDeployments(t *testing.T) {
8485
},
8586
},
8687
})
88+
89+
resource.Test(t, resource.TestCase{
90+
PreCheck: func() {
91+
astronomerprovider.TestAccPreCheck(t)
92+
},
93+
ProtoV6ProviderFactories: astronomerprovider.TestAccProtoV6ProviderFactories,
94+
Steps: []resource.TestStep{
95+
//Check the data source for deployments for a hybrid organization
96+
{
97+
Config: astronomerprovider.ProviderConfig(t, false) + hybridDeployments(),
98+
Check: resource.ComposeTestCheckFunc(
99+
// Checks that the deployments data source is not empty and checks the first deployment in the list
100+
// has some of the expected attributes
101+
checkDeployments("test_data_deployments_hybrid_no_filters", ""),
102+
),
103+
},
104+
},
105+
})
106+
}
107+
108+
func hybridDeployments() string {
109+
return `
110+
data astronomer_deployments "test_data_deployments_hybrid_no_filters" {}`
87111
}
88112

89-
func deployments(name string) string {
113+
func hostedDeployments(name string) string {
90114
return fmt.Sprintf(`
91115
resource "astronomer_workspace" "test_workspace" {
92116
name = "%v"
93117
description = "%v"
94118
cicd_enforced_default = true
95119
}
96120
97-
resource "astronomer_standard_deployment" "test_deployment_kubernetes" {
121+
resource "astronomer_deployment" "test_deployment_kubernetes" {
98122
name = "%v-1"
99123
description = "%v"
124+
type = "STANDARD"
100125
region = "us-east4"
101126
cloud_provider = "GCP"
102127
contact_emails = ["preview@astronomer.test"]
@@ -118,9 +143,10 @@ resource "astronomer_standard_deployment" "test_deployment_kubernetes" {
118143
}]
119144
}
120145
121-
resource "astronomer_standard_deployment" "test_deployment_celery" {
146+
resource "astronomer_deployment" "test_deployment_celery" {
122147
name = "%v-2"
123148
description = "%v"
149+
type = "STANDARD"
124150
region = "us-east-1"
125151
cloud_provider = "AWS"
126152
contact_emails = []
@@ -147,46 +173,46 @@ resource "astronomer_standard_deployment" "test_deployment_celery" {
147173
}
148174
149175
data astronomer_deployment "test_data_deployment_kubernetes" {
150-
depends_on = [astronomer_standard_deployment.test_deployment_kubernetes]
151-
id = astronomer_standard_deployment.test_deployment_kubernetes.id
176+
depends_on = [astronomer_deployment.test_deployment_kubernetes]
177+
id = astronomer_deployment.test_deployment_kubernetes.id
152178
}
153179
154180
data astronomer_deployment "test_data_deployment_celery" {
155-
depends_on = [astronomer_standard_deployment.test_deployment_celery]
156-
id = astronomer_standard_deployment.test_deployment_celery.id
181+
depends_on = [astronomer_deployment.test_deployment_celery]
182+
id = astronomer_deployment.test_deployment_celery.id
157183
}
158184
159185
data astronomer_deployments "test_data_deployments_no_filters" {
160-
depends_on = [astronomer_standard_deployment.test_deployment_kubernetes, astronomer_standard_deployment.test_deployment_celery]
186+
depends_on = [astronomer_deployment.test_deployment_kubernetes, astronomer_deployment.test_deployment_celery]
161187
}
162188
163189
data astronomer_deployments "test_data_deployments_workspace_ids_filter" {
164-
depends_on = [astronomer_standard_deployment.test_deployment_kubernetes, astronomer_standard_deployment.test_deployment_celery]
190+
depends_on = [astronomer_deployment.test_deployment_kubernetes, astronomer_deployment.test_deployment_celery]
165191
workspace_ids = [astronomer_workspace.test_workspace.id]
166192
}
167193
168194
data astronomer_deployments "test_data_deployments_deployment_ids_filter" {
169-
depends_on = [astronomer_standard_deployment.test_deployment_kubernetes, astronomer_standard_deployment.test_deployment_celery]
170-
deployment_ids = [astronomer_standard_deployment.test_deployment_kubernetes.id]
195+
depends_on = [astronomer_deployment.test_deployment_kubernetes, astronomer_deployment.test_deployment_celery]
196+
deployment_ids = [astronomer_deployment.test_deployment_kubernetes.id]
171197
}
172198
173199
data astronomer_deployments "test_data_deployments_names_filter" {
174-
depends_on = [astronomer_standard_deployment.test_deployment_kubernetes, astronomer_standard_deployment.test_deployment_celery]
200+
depends_on = [astronomer_deployment.test_deployment_kubernetes, astronomer_deployment.test_deployment_celery]
175201
names = ["%v-1"]
176202
}
177203
178204
data astronomer_deployments "test_data_deployments_incorrect_workspace_ids_filter" {
179-
depends_on = [astronomer_standard_deployment.test_deployment_kubernetes, astronomer_standard_deployment.test_deployment_celery]
205+
depends_on = [astronomer_deployment.test_deployment_kubernetes, astronomer_deployment.test_deployment_celery]
180206
workspace_ids = ["%v"]
181207
}
182208
183209
data astronomer_deployments "test_data_deployments_incorrect_deployment_ids_filter" {
184-
depends_on = [astronomer_standard_deployment.test_deployment_kubernetes, astronomer_standard_deployment.test_deployment_celery]
210+
depends_on = [astronomer_deployment.test_deployment_kubernetes, astronomer_deployment.test_deployment_celery]
185211
deployment_ids = ["%v"]
186212
}
187213
188214
data astronomer_deployments "test_data_deployments_incorrect_names_filter" {
189-
depends_on = [astronomer_standard_deployment.test_deployment_kubernetes, astronomer_standard_deployment.test_deployment_celery]
215+
depends_on = [astronomer_deployment.test_deployment_kubernetes, astronomer_deployment.test_deployment_celery]
190216
names = ["%v"]
191217
}
192218
`, name, utils.TestResourceDescription, name, utils.TestResourceDescription, name, utils.TestResourceDescription, name, cuid.New(), cuid.New(), cuid.New())
@@ -230,17 +256,24 @@ func checkDeployments(tfDataSourceName, deploymentName string) resource.TestChec
230256
if numDeployments == 0 {
231257
return fmt.Errorf("expected deployments to be greater or equal to 1, got %s", instanceState.Attributes["deployments.#"])
232258
}
233-
deploymentsIdx := -1
234-
for i := 0; i < numDeployments; i++ {
235-
idxName := fmt.Sprintf("deployments.%d.name", i)
236-
if instanceState.Attributes[idxName] == deploymentName {
237-
deploymentsIdx = i
238-
break
259+
260+
// If deploymentName is not set, we will check the first deployment
261+
var deploymentsIdx int
262+
if deploymentName == "" {
263+
deploymentsIdx = 0
264+
} else {
265+
for i := 0; i < numDeployments; i++ {
266+
idxName := fmt.Sprintf("deployments.%d.name", i)
267+
if instanceState.Attributes[idxName] == deploymentName {
268+
deploymentsIdx = i
269+
break
270+
}
271+
}
272+
if deploymentsIdx == -1 {
273+
return fmt.Errorf("deployment %s not found", deploymentName)
239274
}
240275
}
241-
if deploymentsIdx == -1 {
242-
return fmt.Errorf("deployment %s not found", deploymentName)
243-
}
276+
244277
description := fmt.Sprintf("deployments.%d.description", deploymentsIdx)
245278
if instanceState.Attributes[description] == "" {
246279
return fmt.Errorf("expected 'description' to be set")

0 commit comments

Comments
 (0)