# Error waiting for Creating FlexibleAppVersion

**URL:** <https://discuss.hashicorp.com/t/error-waiting-for-creating-flexibleappversion/30604>\
**Category:** Terraform\
**Created:** [October 12, 2021, 2:01pm UTC](https://discuss.hashicorp.com/t/error-waiting-for-creating-flexibleappversion/30604 "2021-10-12T14:01:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![branburciaga](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/branburciaga/32/17028_2.png) [@branburciaga](https://discuss.hashicorp.com/u/branburciaga)\
**Post date:** [October 12, 2021, 2:01pm UTC](https://discuss.hashicorp.com/t/error-waiting-for-creating-flexibleappversion/30604/1 "2021-10-12T14:01:58Z")

</div>

I have a GCP project utilizing a variety of services: GC Functions, Firestore, VPC Connector, Storage Buckets, App Engine, Compute Engine. I use Terraform for deployment.

I decided to add a message queue using Google Tasks Queue, and run it on App Engine.

There is a nodejs handler function I put into an `archive_file` before attempting to deploy it to App Engine. I do this for my GC Function and it works great.

From my research it looks like I need Terraform resource `app_engine_standard_app_version` or `app_engine_flexible_app_version` to run my handler function on my App Engine.

When I try to create this resource via `terraform apply` I get an error. Neither flexible or standard works.

**TFE Code**

```auto
locals {
  timestamp = formatdate("YYMMDDhhmmss", timestamp())
}

resource "google_cloud_tasks_queue" "task-queue-b" {
  name = "task-queue-b"
  location = "us-east1"

  rate_limits {
    max_concurrent_dispatches = 3
    max_dispatches_per_second = 2
  }

  retry_config {
    max_attempts = 5
    max_retry_duration = "4s"
    max_backoff = "3s"
    min_backoff = "2s"
    max_doublings = 1
  }
}

# Compress source code and make archive file
data "archive_file" "task-queue-source" {
  type = "zip"
  output_path = "/tmp/task-queue-${local.timestamp}.zip"
  source_dir = "../../../../queue/build/src" # index.js is here with handler func
}

# Create bucket that will host the source code
resource "google_storage_bucket" "task-queue-bucket" {
  name = "${var.project}-task-queue"
}

# Add source code zip to bucket
resource "google_storage_bucket_object" "task-queue-zip" {
  # Append file MD5 to force bucket to be recreated
  name = "task-queue-source.zip#${data.archive_file.task-queue-source.output_md5}"
  bucket = google_storage_bucket.task-queue-bucket.name
  source = data.archive_file.task-queue-source.output_path
  depends_on = [data.archive_file.task-queue-source]
}

resource "google_app_engine_flexible_app_version" "task-queue-flexible-v1" {
  project = var.project
  service = "default"
  version_id = "v1"
  runtime = "nodejs14"

  entrypoint {
    shell = "node ./index.js"
  }

  deployment {
    zip {
      source_url = "https://storage.googleapis.com/task-queue/${google_storage_bucket.task-queue-bucket.name}/${google_storage_bucket_object.task-queue-zip.name}"
    }
  }

  liveness_check {
    path = "."
  }

  readiness_check {
    path = "."
  }

  automatic_scaling {
    cool_down_period = "120s"
    cpu_utilization {
      target_utilization = 0.5
    }
  }

  delete_service_on_destroy = true
}

```

I receive the following:

**First warning: I don’t think this is related…**

```auto
2021-10-10T12:37:50.296-0400 [WARN] Provider "provider[\"registry.terraform.io/hashicorp/google\"]" produced an unexpected new value for module.analytics.google_cloudfunctions_function.analytics, but we are tolerating it because it is using the legacy plugin SDK.
    The following problems may be the cause of any confusing errors from downstream operations:
      - .source_archive_object: was cty.StringVal("source.zip#d8d06f1045f9387d72429479c37eb6b3"), but now cty.StringVal("source.zip")
module.analytics.google_cloudfunctions_function.analytics: Modifications complete after 2m16s [id=projects/<proj>/locations/us-east1/functions/analytics]

```

**Main error I can not for the life of me figure out:**

```auto
╷
│ Error: Error waiting to create FlexibleAppVersion: Error waiting for Creating FlexibleAppVersion: Error code 13, message: An internal error occurred.
│
│ with module.task-queue.google_app_engine_flexible_app_version.task-queue-flexible-v1,
│ on ..\..\modules\taskqueue\main.tf line 74, in resource "google_app_engine_flexible_app_version" "task-queue-flexible-v1":
│ 74: resource "google_app_engine_flexible_app_version" "task-queue-flexible-v1" {
│
╵
2021-10-10T12:37:50.302-0400 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"

```

**Versions**

```auto
Terraform v1.0.8
on windows_amd64
+ provider registry.terraform.io/hashicorp/archive v2.2.0
+ provider registry.terraform.io/hashicorp/google v3.88.0

```

**Questions**

1. Am I correct with my chosen resources to run my Task Queue handler function (nodejs express app)? Are there any resources I am missing? Do I need an actual `google_app_engine_application` TFE resource?

2. Any insight into this unhelpful error?

Thanks so much
