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

Create Azure SQL Server and Azure AD administrators in same request #13677

Closed
timwebster9 opened this issue Oct 10, 2021 · 4 comments · Fixed by #13753
Closed

Create Azure SQL Server and Azure AD administrators in same request #13677

timwebster9 opened this issue Oct 10, 2021 · 4 comments · Fixed by #13753
Labels
Milestone

Comments

@timwebster9
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

This is kind of halfway between a bug and a feature request, so apologies if it's not the correct issue type.

It appears that when creating a SQL Server and Azure AD administrator, they are provisioned using separate requests using the REST API (see gist here) However it is possible to create them both in a single request using the properties.administrators field: https://docs.microsoft.com/en-us/rest/api/sql/2021-02-01-preview/servers/create-or-update

The reason this would be useful is for users of Azure Policy. For example, we would like all instances of SQL server to be provisioned with an Azure AD administrator, or the provisioning request should be rejected. Because this is done in separate requests, we cannot enforce this and have to allow the provisioning of the server without the Azure AD admin. At best we have to use an audit policy and then chase teams to add an Azure AD admin after the fact.

Policy is critically important in enterprise environments, and it makes things difficult in these environments if Terraform and Policy don't play together well.

There is already another resource for adding an Azure AD admin separately, and that could be kept: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/sql_active_directory_administrator

New or Affected Resource(s)

  • azurerm_mssql_server

Potential Terraform Configuration

The configuration could remain unchanged:

resource "azurerm_mssql_server" "example" {
  name                         = "mssqlserver"
  resource_group_name          = azurerm_resource_group.example.name
  location                     = azurerm_resource_group.example.location
  version                      = "12.0"
  administrator_login          = "missadministrator"
  administrator_login_password = "thisIsKat11"
  minimum_tls_version          = "1.2"

  azuread_administrator {
    login_username = "AzureAD Admin"
    object_id      = "00000000-0000-0000-0000-000000000000"
  }

}
@aristosvo
Copy link
Collaborator

aristosvo commented Oct 11, 2021

#13622 is merged, I'll give it a try!

@aristosvo
Copy link
Collaborator

@timwebster9 It is working for creation of new servers (PR follows soon), but updates cannot be done following the same mechanism, still possibly breaking your policy at the moment.

I'm figuring out if it is possible to work around that issue as well, as it might happen that you want to change admins.

@github-actions
Copy link

This functionality has been released in v2.82.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
3 participants