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

Remove ValidateConfig from API token resource to allow dynamic creation #184

Merged
merged 33 commits into from
Jan 9, 2025

Conversation

vandyliu
Copy link
Collaborator

@vandyliu vandyliu commented Jan 8, 2025

Description

🎟 Issue(s)

#183

🧪 Functional Testing

Tested against dev.

➜  clusters git:(main) ✗ terraform apply                                                                                                   [25/01/8|11:38AM]
╷
│ Warning: Provider development overrides are in effect
│ 
│ The following provider development overrides are set in the CLI configuration:
│  - astronomer/astro in /Users/vandy/astronomer/terraform-provider-astro/bin
│ 
│ The behavior may therefore not match any released version of the provider and applying changes may cause the state to become incompatible with published
│ releases.
╵
astro_deployment.dedicated: Refreshing state... [id=cm4u8i184000301kr13q4ublc]

Note: Objects have changed outside of Terraform

Terraform detected the following changes made outside of Terraform since the last "terraform apply" which may have affected this plan:

  # astro_deployment.dedicated has been deleted
  - resource "astro_deployment" "dedicated" {
      - id                         = "cm4u8i184000301kr13q4ublc" -> null
      - name                       = "test-wq-deployment" -> null
        # (39 unchanged attributes hidden)
    }


Unless you have made equivalent changes to your configuration, or ignored the relevant attributes using ignore_changes, the following plan may include
actions to undo or respond to these changes.

────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # astro_api_token.deployment_tokens["admin"] will be created
  + resource "astro_api_token" "deployment_tokens" {
      + created_at   = (known after apply)
      + created_by   = (known after apply)
      + description  = "deployment api token description"
      + end_at       = (known after apply)
      + id           = (known after apply)
      + last_used_at = (known after apply)
      + name         = "test-wq-deployment-deployment-token-admin-DEPLOYMENT_ADMIN"
      + roles        = [
          + {
              + entity_id   = (known after apply)
              + entity_type = "DEPLOYMENT"
              + role        = "DEPLOYMENT_ADMIN"
            },
        ]
      + short_token  = (known after apply)
      + start_at     = (known after apply)
      + token        = (sensitive value)
      + type         = "DEPLOYMENT"
      + updated_at   = (known after apply)
      + updated_by   = (known after apply)
    }

  # astro_deployment.dedicated will be created
  + resource "astro_deployment" "dedicated" {
      + airflow_version             = (known after apply)
      + astro_runtime_version       = (known after apply)
      + cloud_provider              = "AWS"
      + cluster_id                  = (known after apply)
      + contact_emails              = [
          + "[email protected]",
        ]
      + created_at                  = (known after apply)
      + created_by                  = (known after apply)
      + dag_tarball_version         = (known after apply)
      + default_task_pod_cpu        = "0.25"
      + default_task_pod_memory     = "0.5Gi"
      + description                 = "Test deployment"
      + desired_dag_tarball_version = (known after apply)
      + environment_variables       = []
      + executor                    = "CELERY"
      + external_ips                = (known after apply)
      + id                          = (known after apply)
      + image_repository            = (known after apply)
      + image_tag                   = (known after apply)
      + image_version               = (known after apply)
      + is_cicd_enforced            = false
      + is_dag_deploy_enabled       = true
      + is_development_mode         = true
      + is_high_availability        = false
      + name                        = "test-wq-deployment"
      + namespace                   = (known after apply)
      + oidc_issuer_url             = (known after apply)
      + region                      = "us-east-1"
      + resource_quota_cpu          = "10"
      + resource_quota_memory       = "20Gi"
      + scaling_status              = (known after apply)
      + scheduler_cpu               = (known after apply)
      + scheduler_memory            = (known after apply)
      + scheduler_replicas          = (known after apply)
      + scheduler_size              = "SMALL"
      + status                      = (known after apply)
      + status_reason               = (known after apply)
      + type                        = "STANDARD"
      + updated_at                  = (known after apply)
      + updated_by                  = (known after apply)
      + webserver_airflow_api_url   = (known after apply)
      + webserver_ingress_hostname  = (known after apply)
      + webserver_url               = (known after apply)
      + worker_queues               = [
          + {
              + astro_machine      = "A10"
              + is_default         = true
              + max_worker_count   = 3
              + min_worker_count   = 1
              + name               = "default"
              + pod_cpu            = (known after apply)
              + pod_memory         = (known after apply)
              + worker_concurrency = 10
            },
        ]
      + workload_identity           = (known after apply)
      + workspace_id                = "cm4rl55w8000501ghao8mnkwd"
    }

Plan: 2 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

astro_deployment.dedicated: Creating...
astro_deployment.dedicated: Creation complete after 1s [id=cm5oayevs011u01jtdco5az52]
astro_api_token.deployment_tokens["admin"]: Creating...
astro_api_token.deployment_tokens["admin"]: Creation complete after 1s [id=cm5oayfl7012a01jtutnzstoz]

Apply complete! Resources: 2 added, 0 changed, 0 destroyed.

📸 Screenshots

Screenshot 2025-01-08 at 11 39 53 AM

📋 Checklist

  • Added/updated applicable tests
  • Added/updated examples in the examples/ directory
  • Updated any related documentation

@vandyliu vandyliu marked this pull request as ready for review January 9, 2025 00:11
@vandyliu vandyliu requested a review from a team as a code owner January 9, 2025 00:11
Copy link
Collaborator

@ichung08 ichung08 left a comment

Choose a reason for hiding this comment

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

left a few comments and questions - can you also paste the tf resource block you used for testing?

@vandyliu
Copy link
Collaborator Author

vandyliu commented Jan 9, 2025

left a few comments and questions - can you also paste the tf resource block you used for testing?

resource "astro_api_token" "deployment_tokens" {
  for_each    = local.deployment_tokens
  name        = "${astro_deployment.dedicated.name}-deployment-token-${each.key}-${each.value}"
  description = "deployment api token description"
  type        = "DEPLOYMENT"
  roles = [{
    role = each.value
    entity_id   = astro_deployment.dedicated.id
    entity_type = "DEPLOYMENT"
  }
  ]
}

locals {
  deployment_tokens = {
    admin = "DEPLOYMENT_ADMIN"
  }
}

Copy link
Collaborator

@ichung08 ichung08 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 making the changes! lgtm

@vandyliu vandyliu merged commit 010f856 into main Jan 9, 2025
9 checks passed
@vandyliu vandyliu deleted the remove-validate-config-api-tokens branch January 9, 2025 18:06
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.

2 participants