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

Unexpected changes for digitalocean_app #1075

Open
razum90 opened this issue Nov 11, 2023 · 0 comments
Open

Unexpected changes for digitalocean_app #1075

razum90 opened this issue Nov 11, 2023 · 0 comments
Labels

Comments

@razum90
Copy link
Contributor

razum90 commented Nov 11, 2023

Bug Report

I am getting unexpected changes after creating digitalocean_app.

This is my tf config:

resource "digitalocean_app" "project" {
  for_each = var.environments

  spec {
    name   = "project-${each.key}"
    region = var.region

    domain {
      name = var.environments[each.key].domain
    }

    alert {
      rule = "DEPLOYMENT_FAILED"
    }

    service {
      name               = "api"
      instance_count     = 1
      instance_size_slug = "basic-xxs"

      image {
        registry_type = "DOCR"
        repository    = "api"
        tag           = "0.0.1"
        deploy_on_push {
          enabled = var.environments[each.key].web.deploy_on_push
        }
      }

      http_port = 8080

      alert {
        value    = 75
        operator = "GREATER_THAN"
        window   = "TEN_MINUTES"
        rule     = "CPU_UTILIZATION"
      }

      env {
        key   = "QUARKUS_DATASOURCE_JDBC_URL"
        value = "jdbc:postgresql://${digitalocean_database_cluster.db-cluster[each.key].host}:${digitalocean_database_cluster.db-cluster[each.key].port}/${digitalocean_database_db.db[each.key].name}"
      }

      env {
        key   = "QUARKUS_DATASOURCE_USERNAME"
        value = digitalocean_database_cluster.db-cluster[each.key].user
      }

      env {
        key   = "QUARKUS_DATASOURCE_PASSWORD"
        value = digitalocean_database_cluster.db-cluster[each.key].password
        type  = "SECRET"
      }

      env {
        key   = "API_KEY"
        value = var.api_key
        type  = "SECRET"
      }
    }

    static_site {
      name          = "web"
      build_command = "npm run build"

      source_dir = "web/"

      github {
        branch         = "main"
        deploy_on_push = true
        repo           = "username/project"
      }
    }

    database {
      name         = digitalocean_database_db.db[each.key].name
      db_name      = digitalocean_database_db.db[each.key].name
      cluster_name = digitalocean_database_cluster.db-cluster[each.key].name
      production   = var.environments[each.key].production_db
    }

    ingress {
      rule {
        component {
          name = "api"
        }
        match {
          path {
            prefix = "/api"
          }
        }
      }

      rule {
        component {
          name = "web"
        }

        match {
          path {
            prefix = "/"
          }
        }
      }
    }
  }
}

After applying it and doing unrelated updates to my terraform config, I get this:

  # digitalocean_app.project["prod"] will be updated in-place
  ~ resource "digitalocean_app" "project" {
        id                   = "xxx"
        # (6 unchanged attributes hidden)

      ~ spec {
          ~ features = [
              - "buildpack-stack=ubuntu-22",
            ]
            name     = "project-prod"
          ~ region   = "fra" -> "fra1"
            # (1 unchanged attribute hidden)

          ~ service {
                name               = "api"
                # (4 unchanged attributes hidden)

              - env {
                  # At least one attribute in this block is (or was) sensitive,
                  # so its contents will not be displayed.
                }
              - env {
                  # At least one attribute in this block is (or was) sensitive,
                  # so its contents will not be displayed.
                }
              - env {
                  # At least one attribute in this block is (or was) sensitive,
                  # so its contents will not be displayed.
                }
              - env {
                  # At least one attribute in this block is (or was) sensitive,
                  # so its contents will not be displayed.
                }
              + env {
                  # At least one attribute in this block is (or was) sensitive,
                  # so its contents will not be displayed.
                }
              + env {
                  # At least one attribute in this block is (or was) sensitive,
                  # so its contents will not be displayed.
                }
              + env {
                  # At least one attribute in this block is (or was) sensitive,
                  # so its contents will not be displayed.
                }
              + env {
                  # At least one attribute in this block is (or was) sensitive,
                  # so its contents will not be displayed.
                }

                # (2 unchanged blocks hidden)
            }

            # (5 unchanged blocks hidden)
        }
    }

  1. The region is all of a sudden fra which does not exist in your docs.
  2. It's trying to recreate my environment variables for some reason.

If I try to change to fra the db cluster creation complains:

╷
│ Error: Error creating database cluster: POST https://api.digitalocean.com/v2/databases: 412 (request "8bf6fc7c-aacc-4654-b29e-d3206e8651cd") At this time, we're unable to create a cluster of that size in that region
│ 
│   with digitalocean_database_cluster.db-cluster["dev"],
│   on digitalocean.tf line 52, in resource "digitalocean_database_cluster" "db-cluster":
│   52: resource "digitalocean_database_cluster" "db-cluster" {
│ 
╵

Affected Resource(s)

  • digitalocean_app

Might be more, have not investigated.

Terraform version
1.6.3

terraform {
  required_providers {
    digitalocean = {
      source  = "digitalocean/digitalocean"
      version = "~> 2.0"
    }
  }
}
@razum90 razum90 added the bug label Nov 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant