Skip to content

Linking an environment group detaches it from other services #43

@ahmadabdelhalim

Description

@ahmadabdelhalim

Hey team,

I'm facing an issue with linking environment groups. the current implementation attempts to link an environment group to the PR environment upon deployment. However, there’s a bug with the Render provider that detaches the environment group from the previous services and applies it only to the newly deployed one. This causes the previous services to fail, requiring you to manually link the environment group through the UI for both the web and worker services. My theory is that the render provider only gets the services from this array

  service_ids  = [
    render_web_service.pr_web_service.id,
    render_background_worker.pr_worker_service.id,
  ]

ignoring all other services. is there a quick solution for this issue?

data "render_env_group" "staging" {
  id = var.staging_env_group_id
}

resource "render_postgres" "pr_postgres_database" {
  name         = "${var.pr_branch}-database"
  plan         = "basic_256mb"
  disk_size_gb = 10
  region       = "frankfurt"
  version      = "16"
}

resource "render_web_service" "pr_web_service" {
  name               = "${var.pr_branch}-web"
  plan               = "standard"
  region             = "frankfurt"
  start_command      = "bundle exec puma -C config/puma.rb"
  health_check_path  = "/health"

  pre_deploy_command = <<-EOT
    DEMO_DATABASE_URL=${var.demo_database_url} bundle exec rake db:import_demo
  EOT

  runtime_source = {
    native_runtime = {
      auto_deploy   = true
      branch        = var.pr_branch
      build_command = "./bin/review-app.sh"
      repo_url      = "test"
      runtime       = "ruby"
    }
  }

  maintenance_mode = {
    enabled = false
    uri     = ""
  }

  env_vars = {
    DATABASE_URL = {
      value = render_postgres.pr_postgres_database.connection_info.internal_connection_string
    }
  }
}

resource "render_background_worker" "pr_worker_service" {
  name          = "${var.pr_branch}-worker"
  plan          = "standard"
  region        = "frankfurt"
  start_command = "bundle exec sidekiq"

  runtime_source = {
    native_runtime = {
      auto_deploy   = true
      branch        = var.pr_branch
      build_command = "./bin/review-app.sh"
      repo_url      = "test"
      runtime       = "ruby"
    }
  }

  env_vars = {
    DATABASE_URL = {
      value = render_postgres.pr_postgres_database.connection_info.internal_connection_string
    }
  }
}

resource "render_env_group_link" "pr_services_env_link" {
  env_group_id = data.render_env_group.staging.id
  service_ids  = [
    render_web_service.pr_web_service.id,
    render_background_worker.pr_worker_service.id,
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions