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

azure.sql: can't create MSSQLServerDNSAlias #27

Closed
ytsarev opened this issue Jul 12, 2022 · 10 comments · Fixed by #445
Closed

azure.sql: can't create MSSQLServerDNSAlias #27

ytsarev opened this issue Jul 12, 2022 · 10 comments · Fixed by #445
Assignees
Labels
bug Something isn't working is:triaged

Comments

@ytsarev
Copy link
Collaborator

ytsarev commented Jul 12, 2022

What happened?

MSSQLServerDNSAlias / https://registry.terraform.io/providers/hashicorp/azurerm/3.8.0/docs/resources/mssql_server_dns_alias is going through a standard v1beta1 stabilization process in the context of https://github.com/upbound/official-providers/issues/234

The e2e test of the example fails on the creation attempt:

  At Provider:
  Conditions:
    Last Transition Time:  2022-07-12T13:30:58Z
    Message:               observe failed: cannot run refresh: refresh failed: sql.ServerDNSAliasesClient#Get: Failure responding to request: StatusCode=404 -- Original Error: autorest/azure: Service returned an error. Status=404 Code="ResourceNotFound" Message="The requested resource of type 'Microsoft.Sql/servers/dnsAliases' with name 'example-dns-alias' was not found.": sql.ServerDNSAliasesClient#Get: Failure responding to request: StatusCode=404 -- Original Error: autorest/azure: Service returned an error. Status=404 Code="ResourceNotFound" Message="The requested resource of type 'Microsoft.Sql/servers/dnsAliases' with name 'example-dns-alias' was not found.": File name: main.tf.json
    Reason:                ReconcileError
    Status:                False
    Type:                  Synced

In the meantime the associated terraform example works

provider "azurerm" {
  features {}
}

resource "azurerm_mssql_server_dns_alias" "example" {
  name            = "example-dns-alias"
  mssql_server_id = "/subscriptions/038f2b7c-3265-43b8-8624-c9ad5da610a8/resourceGroups/example-sql-rg/providers/Microsoft.Sql/servers/example-upbound"
}
azurerm_mssql_server_dns_alias.example: Creating...
azurerm_mssql_server_dns_alias.example: Creation complete after 2s [id=/subscriptions/038f2b7c-3265-43b8-8624-c9ad5da610a8/resourceGroups/example-sql-rg/providers/Microsoft.Sql/servers/example-upbound/dnsAliases/example-dns-alias]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

In addition to that, when terraform creates the alias, it is getting picked up/imported by the provider as well

It might be related to dns_record attribute which is not exposed via API but dynamically constructed by the provider

Below is the tfstate after successful creation with terraform cli

      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "dns_record": "example-dns-alias.database.windows.net",
            "id": "/subscriptions/038f2b7c-3265-43b8-8624-c9ad5da610a8/resourceGroups/example-sql-rg/providers/Microsoft.Sql/servers/example-upbound/dnsAliases/example-dns-alias",
            "mssql_server_id": "/subscriptions/038f2b7c-3265-43b8-8624-c9ad5da610a8/resourceGroups/example-sql-rg/providers/Microsoft.Sql/servers/example-upbound",
            "name": "example-dns-alias",
            "timeouts": null
          },

How can we reproduce it?

What environment did it happen in?

@ytsarev ytsarev added the bug Something isn't working label Jul 12, 2022
@turkenh turkenh self-assigned this Sep 26, 2022
@turkenh
Copy link
Contributor

turkenh commented Oct 3, 2022

I could reproduce and have investigated this issue which turned out to be a bug on native terraform provider.

Filed the following: hashicorp/terraform-provider-azurerm#18614

@turkenh
Copy link
Contributor

turkenh commented Oct 4, 2022

I opened a PR there and got merged very quickly.

Now we need a new version there and consume it here.

@jeanduplessis
Copy link
Collaborator

@turkenh I assume we are totally dependent on them doing a new release to continue to make progress on this issue?

@turkenh
Copy link
Contributor

turkenh commented Oct 4, 2022

@turkenh I assume we are totally dependent on them doing a new release to continue to make progress on this issue?

Correct.
There could be other alternatives like a custom build or a short term fork if we needed a very quick fix in general (e.g. a customer issue) but for this ticket I don't think we have such an urgency ATM.

@jeanduplessis
Copy link
Collaborator

@turkenh I see they released a new version of terraform-provider-azurerm yesterday: https://github.com/hashicorp/terraform-provider-azurerm/releases/tag/v3.26.0

I'm not seeing your bug fix in the release notes, but wondering if you could confirm if it made it into the release.

@turkenh
Copy link
Contributor

turkenh commented Oct 7, 2022

I'm not seeing your bug fix in the release notes, but wondering if you could confirm if it made it into the release.

Yes, I can confirm.
I can see my commit when I do a comparison with previous release: hashicorp/terraform-provider-azurerm@v3.25.0...v3.26.0

@turkenh
Copy link
Contributor

turkenh commented Oct 7, 2022

I will wait for bumping provider-azure version until repo re-structuring finalizes.

@jeanduplessis
Copy link
Collaborator

We will only bump the terraform provider after today's OP release.

@turkenh
Copy link
Contributor

turkenh commented Oct 24, 2022

This issue is blocked by #60

@turkenf
Copy link
Collaborator

turkenf commented May 3, 2023

I have successfully tested the MSSQLServerDNSAlias resource locally and I opened a PR that removes manual-intervention: #445

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working is:triaged
Projects
None yet
4 participants