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 400 Bad Request when creating PostgreSQL flexibleservers/migration using azapi_resource #624

Open
cjdalan opened this issue Sep 24, 2024 · 0 comments

Comments

@cjdalan
Copy link

cjdalan commented Sep 24, 2024

We're using azapi_resource to create a flexibleServers/migration. Using the code snippet below for creating it.

resource "azapi_resource" "migration" {
  type      = "Microsoft.DBforPostgreSQL/flexibleServers/migrations@2023-12-01-preview"
  name      = "migration"
  location  = var.location
  parent_id = var.targetServerResourceId

  body = jsonencode({
    properties = {
      dbsToMigrate                = var.dbNamesToMigrate
      migrationInstanceResourceId = var.migrationRuntimeServerResourceId
      migrationMode               = var.migrationMode
      migrationOption             = var.migrationOption
      overwriteDbsInTarget        = var.overwriteDbsInTarget
      sourceDbServerResourceId    = var.sourceServerResourceId
      sourceType                  = var.sourceType
      sslMode                     = var.sslMode

      secretParameters = {
        sourceServerUsername = var.sourceServerLoginName
        targetServerUsername = var.targetServerLoginName

        adminCredentials = {
          sourceServerPassword = var.sourceServerLoginPassword
          targetServerPassword = var.targetServerLoginPassword
        }
      }
    }
  })
}

Here is the error

Error: Failed to retrieve resource
  with x.x.x.migration,
  on .terraform/modules/x/x/main.tf line 201, in resource "azapi_resource" "migration":
 201: resource "azapi_resource" "migration" {
checking for presence of existing Resource: (ResourceId
"/subscriptions/x/resourceGroups/x/providers/Microsoft.DBforPostgreSQL/flexibleServers/x/migrations/migration"
/ Api Version "2023-12-01-preview"): GET
https://management.azure.com/subscriptions/x/resourceGroups/x/providers/Microsoft.DBforPostgreSQL/flexibleServers/x/migrations/migration
--------------------------------------------------------------------------------
RESPONSE 400: 400 Bad Request
ERROR CODE: InvalidInput
--------------------------------------------------------------------------------
{
  "error": {
    "code": "InvalidInput",
    "message": "Invalid input. Parameter name: 'MigrationResourceId'. Error: Invalid migration resource ID 'subscriptions/x/resourceGroups/x/providers/Microsoft.DBforPostgreSQL/flexibleServers/x/migrations/migration'.\r\nParameter name: MigrationResourceId"
  }
}
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

No branches or pull requests

1 participant