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

Getting 404 with using azapi_update for Virtual Endpoints on Postgres Flexible Servers #620

Open
will-iam-gm opened this issue Sep 18, 2024 · 2 comments

Comments

@will-iam-gm
Copy link

will-iam-gm commented Sep 18, 2024

Hello yesterday we experienced several of our workflows failing on running azapi_update_resource

We are using this resource to create a virtual endpoint for Postgres Flexible Servers, we started using this several months back since at the time Azurerm did not support virtual endpoints.

resource "azapi_update_resource" "virtual_endpoint" {
  for_each  = local.secondary_deployment ? local.postgres_flexible_servers : {}
  type      = "Microsoft.DBforPostgreSQL/flexibleServers/virtualendpoints@2023-06-01-preview"
  name      = module.postgres_flexible_server_virtual_endpoint_tagging[each.key].postgres_flexible_server_virtual_endpoint_id
  parent_id = module.postgres_flexible_server[each.key].azurerm_postgresql_flexible_server_id
  body = jsonencode({
    properties = {
      endpointType = "ReadWrite"
      members = [
        module.postgres_flexible_server_replica[each.key].azurerm_postgresql_flexible_server.name
      ]
    }
  })
}

Here is the error

╷
│ Error: checking for presence of existing Resource: (ResourceId "/subscriptions/3f7d848d-ffd6-4908-9dc7-0cd745e5e282/resourceGroups/a232328-t01-musea2-rg-willb/providers/Microsoft.DBforPostgreSQL/flexibleServers/a232328-t01-musea2-psql-willb/virtualendpoints/a232328-t01-psql-willb" / Api Version "2023-06-01-preview"): GET https://management.azure.com/subscriptions/3f7d848d-ffd6-4908-9dc7-0cd745e5e282/resourceGroups/a232328-t01-musea2-rg-willb/providers/Microsoft.DBforPostgreSQL/flexibleServers/a232328-t01-musea2-psql-willb/virtualendpoints/a232328-t01-psql-willb
│ --------------------------------------------------------------------------------
│ RESPONSE 404: 404 Not Found
│ ERROR CODE: ResourceNotFound
│ --------------------------------------------------------------------------------
│ {
│   "error": {
│     "code": "ResourceNotFound",
│     "message": "The specified resource 'https://orcasbreadth.eastus2.control.database.windows.net:8343/modules/ArmPostgreSQL/subscriptions/3f7d848d-ffd6-4908-9dc7-0cd745e5e282/resourceGroups/a232328-t01-musea2-rg-willb/providers/Microsoft.DBforPostgreSQL/flexibleServers/a232328-t01-musea2-psql-willb/virtualendpoints/a232328-t01-psql-willb?api-version=2023-06-01-preview' was not found."
│   }
│ }
│ --------------------------------------------------------------------------------
│ 
│ 
│   with azapi_update_resource.virtual_endpoint["willb"],
│   on postgres.tf line 108, in resource "azapi_update_resource" "virtual_endpoint":
│  108: resource "azapi_update_resource" "virtual_endpoint" {
│ 
╵

Debug turned on

2024-09-18T13:41:14.871Z [DEBUG] provider.terraform-provider-azapi_v1.12.1: Sep 18 13:41:14.871535 Request: ==> OUTGOING REQUEST (Try=1)
2024-09-18T13:41:16.9156183Z    GET https://management.azure.com/subscriptions/3f7d848d-ffd6-4908-9dc7-0cd745e5e282/resourceGroups/a232328-t01-musea2-rg-willb/providers/Microsoft.DBforPostgreSQL/flexibleServers/a232328-t01-musea2-psql-willb/virtualendpoints/a232328-t01-psql-willb?api-version=2023-06-01-preview
2024-09-18T13:41:16.9157902Z    Accept: application/json
2024-09-18T13:41:16.9158336Z    Authorization: REDACTED
2024-09-18T13:41:16.9159529Z    User-Agent: HashiCorp Terraform/1.6.6 (+https://www.terraform.io) Terraform Plugin SDK/2.8.0 terraform-provider-azapi/vv1.12.1 pid-222c6c49-1b0a-5959-a213-6608f9eb8820
2024-09-18T13:41:16.9160802Z    X-Ms-Correlation-Request-Id: 020b1db2-520a-101c-99c8-19373e1e30df
2024-09-18T13:41:16.9161673Z    Request contained no body: timestamp=2024-09-18T13:41:14.871Z
2024-09-18T13:41:16.9163203Z 2024-09-18T13:41:15.118Z [DEBUG] provider.terraform-provider-azapi_v1.12.1: Sep 18 13:41:15.117947 Response: ==> REQUEST/RESPONSE (Try=1/246.361782ms, OpTime=246.383293ms) -- RESPONSE RECEIVED
2024-09-18T13:41:16.9165781Z    GET https://management.azure.com/subscriptions/3f7d848d-ffd6-4908-9dc7-0cd745e5e282/resourceGroups/a232328-t01-musea2-rg-willb/providers/Microsoft.DBforPostgreSQL/flexibleServers/a232328-t01-musea2-psql-willb/virtualendpoints/a232328-t01-psql-willb?api-version=2023-06-01-preview
2024-09-18T13:41:16.9167496Z    Accept: application/json
2024-09-18T13:41:16.9167956Z    Authorization: REDACTED
2024-09-18T13:41:16.9169124Z    User-Agent: HashiCorp Terraform/1.6.6 (+https://www.terraform.io) Terraform Plugin SDK/2.8.0 terraform-provider-azapi/vv1.12.1 pid-222c6c49-1b0a-5959-a213-6608f9eb8820
2024-09-18T13:41:16.9170392Z    X-Ms-Correlation-Request-Id: 020b1db2-520a-101c-99c8-19373e1e30df
2024-09-18T13:41:16.9171204Z    --------------------------------------------------------------------------------
2024-09-18T13:41:16.9171810Z    RESPONSE Status: 404 Not Found
2024-09-18T13:41:16.9172379Z    Cache-Control: no-cache
2024-09-18T13:41:16.9172822Z    Content-Length: 421
2024-09-18T13:41:16.9173314Z    Content-Type: application/json; charset=utf-8
2024-09-18T13:41:16.9173837Z    Date: Wed, 18 Sep 2024 13:41:14 GMT
2024-09-18T13:41:16.9174304Z    Expires: -1
2024-09-18T13:41:16.9174692Z    Pragma: no-cache
2024-09-18T13:41:16.9175256Z    Strict-Transport-Security: max-age=31536000; includeSubDomains
2024-09-18T13:41:16.9175870Z    X-Cache: REDACTED
2024-09-18T13:41:16.9176303Z    X-Content-Type-Options: nosniff
2024-09-18T13:41:16.9176964Z    X-Ms-Correlation-Request-Id: 020b1db2-520a-101c-99c8-19373e1e30df
2024-09-18T13:41:16.9177765Z    X-Ms-Ratelimit-Remaining-Subscription-Global-Reads: REDACTED
2024-09-18T13:41:16.9178508Z    X-Ms-Ratelimit-Remaining-Subscription-Reads: 498
2024-09-18T13:41:16.9179182Z    X-Ms-Request-Id: fea291b0-be57-4d12-b615-87f561e9d062
2024-09-18T13:41:16.9180028Z    X-Ms-Routing-Request-Id: EASTUS:20240918T134115Z:7850f93e-74a8-459e-b8fb-2d2ec929aeeb
2024-09-18T13:41:16.9180755Z    X-Msedge-Ref: REDACTED
2024-09-18T13:41:16.9181327Z    --------------------------------------------------------------------------------
2024-09-18T13:41:16.9184192Z {"error":{"code":"ResourceNotFound","message":"The specified resource 'https://orcasbreadth.eastus2.control.database.windows.net:8343/modules/ArmPostgreSQL/subscriptions/3f7d848d-ffd6-4908-9dc7-0cd745e5e282/resourceGroups/a232328-t01-musea2-rg-willb/providers/Microsoft.DBforPostgreSQL/flexibleServers/a232328-t01-musea2-psql-willb/virtualendpoints/a232328-t01-psql-willb?api-version=2023-06-01-preview' was not found."}}

We are using Terraform 1.6.6 and AzAPI provider 1.12.1

Also we are using Api Version "2023-06-01-preview", I tried swapping this for Api Version "2023-12-01-preview" and no difference.

Reference : https://learn.microsoft.com/en-us/azure/templates/microsoft.dbforpostgresql/flexibleservers/virtualendpoints?pivots=deployment-language-terraform

@ms-henglu
Copy link
Member

Hi @will-iam-gm ,

Thank you for taking time to report this issue.

The azapi_update_resource is used to update an existing resource, from the logs, it seems the target resource doesn't exist.

@will-iam-gm
Copy link
Author

will-iam-gm commented Sep 19, 2024

@ms-henglu that is interesting so your saying we have been using this resource incorrectly? We definitely been using this to add virtualendpoints to Postgres Flexible servers for several months..

I think we assumed the resource getting updated was the Postgres server itself, which does exist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants