Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deployment resource #9

Merged
merged 25 commits into from
Apr 17, 2024
Merged

Add deployment resource #9

merged 25 commits into from
Apr 17, 2024

Conversation

vandyliu
Copy link
Collaborator

@vandyliu vandyliu commented Apr 15, 2024

Description

  • adds deployment resource and some basic acceptance tests for standard and hybrid deployments
  • will add acceptance tests for dedicated deployments once dedicated_cluster_resource is implemented
  • adds deployment data source and deployments data source acceptance tests

🎟 Issue(s)

#10

🧪 Functional Testing

Hosted deployment config

resource "astronomer_deployment" "test_deployment1" {
    name = "tf--1"
    description = "%v"
    type = "DEDICATED"
    cluster_id = "clv17vgft000801kkydsws63x"
    contact_emails = ["[email protected]"]
    default_task_pod_cpu = "0.25"
    default_task_pod_memory = "0.5Gi"
    executor = "KUBERNETES"
    is_cicd_enforced = true
    is_dag_deploy_enabled = true
    is_development_mode = false
    is_high_availability = true
    resource_quota_cpu = "10"
    resource_quota_memory = "20Gi"
    scheduler_size = "SMALL"
    workspace_id = astronomer_workspace.test_workspace.id
    environment_variables = [{
        key = "key1"
        value = "value1"
        is_secret = false
    }]
}

resource "astronomer_deployment" "test_deployment2" {
    name = "tf--2"
    description = "%v"
    type = "STANDARD"
    cloud_provider = "AWS"
    region = "us-east-1"
    contact_emails = []
    default_task_pod_cpu = "0.25"
    default_task_pod_memory = "0.5Gi"
    executor = "CELERY"
    is_cicd_enforced = true
    is_dag_deploy_enabled = true
    is_development_mode = false
    is_high_availability = false
    resource_quota_cpu = "10"
    resource_quota_memory = "20Gi"
    scheduler_size = "SMALL"
    workspace_id = astronomer_workspace.test_workspace.id
    environment_variables = []
    worker_queues = [{
        name = "default"
        is_default = true
        astro_machine = "A5"
        max_worker_count = 10
        min_worker_count = 0
        worker_concurrency = 1
    }]
}

Hybrid deployment config

resource "astronomer_deployment" "test_deployment1" {
        name = "tf--1"
        description = "%v"
        type = "HYBRID"
        cluster_id = "clnp86ly5000401ndagu20g81"
        task_pod_node_pool_id = "clnp86ly5000301ndzfxz895w"
        contact_emails = ["[email protected]"]
        executor = "KUBERNETES"
        is_cicd_enforced = true
        is_dag_deploy_enabled = true
        scheduler_replicas = 1
        scheduler_au = 5
        workspace_id = astronomer_workspace.test_workspace.id
        environment_variables = [{
            key = "key1"
            value = "value1"
            is_secret = false
        }]
    }

📸 Screenshots

📋 Checklist

  • Rebased from the main (or release if patching) branch (before testing)
  • Ran make test before taking out of draft
  • Ran make fmt before taking out of draft
  • Added/updated applicable tests
  • Tested against Astro-API (if necessary).
  • Communicated to/tagged owners of respective clients potentially impacted by these changes.
  • Updated any related documentation

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved into data_worksapces_test.go since code is similar and we can check both in same test using same workspace resource

"github.com/stretchr/testify/assert"
)

func TestUnit_Validators_ListIsCuids(t *testing.T) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't need this anymore since there's actually a list validator we can use

if request.ConfigValue.IsNull() || request.ConfigValue.IsUnknown() {
return
}

value := request.ConfigValue.String()
value := request.ConfigValue.ValueString()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.ValueString() gives us the actual string str
.String() gives us "str"

@vandyliu vandyliu closed this Apr 15, 2024
@vandyliu vandyliu reopened this Apr 15, 2024
@vandyliu vandyliu marked this pull request as ready for review April 15, 2024 16:30
@vandyliu vandyliu requested review from sunkickr and a team as code owners April 15, 2024 16:30
<!-- schema generated by tfplugindocs -->
## Schema

### Required
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we just writing these manually every time?

Copy link
Collaborator Author

@vandyliu vandyliu Apr 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its generated by tfplugindocs (line 1) made by make build
defined by our schema

@@ -0,0 +1,190 @@
---
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

general question, is it conventional to have separate data sources to each of the oneof types?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i cant find many examples since it seems that most of the time the API matches the terraform provider in terms of resources.
Let me take a stab at making it all the same (ie. deployment_resource) to see what complexities it may bring up

@vandyliu vandyliu marked this pull request as draft April 15, 2024 19:14
@vandyliu vandyliu changed the title Add standard deployment resource Add deployment resource Apr 15, 2024
@vandyliu vandyliu marked this pull request as ready for review April 15, 2024 23:33
@vandyliu vandyliu requested a review from fredzhy April 15, 2024 23:34
README.md Outdated Show resolved Hide resolved
- `webserver_airflow_api_url` (String) Deployment webserver Airflow API URL
- `webserver_ingress_hostname` (String) Deployment webserver ingress hostname
- `webserver_url` (String) Deployment webserver URL
- `workload_identity` (String) Deployment workload identity. This value can be changed via the Astro API if applicable.
Copy link

@kushalmalani kushalmalani Apr 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be required? I believe a user can update this via cli

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its a weird one because it is auto-generated if no input
furthermore it can only be done for certain deployments like aws hybrid deployments and gcp hosted deployments so we cant have it be required nor optional

if we set it to optional and it is blank then terraform will complain because the astro api sets it but terraform expects it to be blank

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would the user do if they use aws hybrid dpeloyments and want to update workload_identity. Dont want to block this PR because of this, but something for us to think about

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they can update it via API and the value will be left alone if terraform ever does any updates

Copy link

@fredzhy fredzhy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the walk through yesterday, i think we can merge this and start internal testing

@vandyliu vandyliu requested a review from kushalmalani April 17, 2024 19:51
Copy link

@kushalmalani kushalmalani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks

@vandyliu vandyliu merged commit ef74459 into main Apr 17, 2024
5 checks passed
@vandyliu vandyliu deleted the standard-dep-resource branch April 17, 2024 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants