-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
New Resource: azurerm_sql_active_directory_administrator
#765
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey @simongh
Thanks for this PR - apologies for the delay in reviewing this!
I've taken a look through and left some comments inline, but this is off to a good start. If we can fix up the issues raised in the comments and some documentation - this otherwise looks good to kick off the tests. Regarding documentation, this consists of a link in the sidebar and a documentation page similar to this one.
Thanks!
"tenant_id": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add some validation for this to ensure it's a valid UUID? we can use:
ValidateFunc: validateUUID,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added suggested validator. This value can be updated.
|
||
"object_id": { | ||
Type: schema.TypeString, | ||
Required: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add some validation for this to ensure it's a valid UUID? we can use:
ValidateFunc: validateUUID,
also, can this value be updated? if not, this would be better as ForceNew: true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added validator. This value can be updated
|
||
"resource_group_name": resourceGroupNameSchema(), | ||
|
||
"login": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would this be better as username? also, can this value be updated? if not, this would be better as ForceNew: true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
login matches up with the Azure API. They don't tend to use username very much, as this could also be a group name.
I'm not precious about it either way though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 that's fair - let's leave this as-is
resp, error := client.Get(ctx, resGroup, serverName, administratorName) | ||
if error != nil { | ||
return error | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor can we change error
-> err
to match the convention here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated to match conventions
uuid "github.com/satori/go.uuid" | ||
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" | ||
//"github.com/hashicorp/terraform/helper/validation" | ||
//"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/response" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor can we remove these unused imports?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
Create: resourceArmSqlAdministratorCreateUpdate, | ||
Read: resourceArmSqlAdministratorRead, | ||
Update: resourceArmSqlAdministratorCreateUpdate, | ||
Delete: resourceArmSqlAdministratorDelete, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we update the function name + these prefixes to resourceArmSqlActiveDirectoryAdministrator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renamed as requested
|
||
serverName := d.Get("server_name").(string) | ||
resGroup := d.Get("resource_group_name").(string) | ||
administratorName := "activeDirectory" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note when #825 is resolved we shouldn't need this field
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
presuming I don't need to do anything here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed - we'll take care of those changes once it's merged in (it's more a future TODO for us 😄)
login = "sqladmin" | ||
tenant_id = "${data.azurerm_client_config.current.tenant_id}" | ||
object_id = "${data.azurerm_client_config.current.client_id}" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor could we make the spacing consistent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
resource_group_name = "${azurerm_resource_group.test.name}" | ||
login = "sqladmin2" | ||
tenant_id = "${data.azurerm_client_config.current.tenant_id}" | ||
object_id = "${data.azurerm_client_config.current.client_id}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor could we fix the spacing here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Delete: resourceArmSqlAdministratorDelete, | ||
Importer: &schema.ResourceImporter{ | ||
State: schema.ImportStatePassthrough, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
given we've supported import - can we add an import test for this resource? here's an example of how we do that https://github.com/terraform-providers/terraform-provider-azurerm/blob/master/azurerm/import_arm_mysql_server_test.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I've implemented this. i'm getting a "filename too long" error, which makes it tricky to test this is working at all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no worries, I can kick off the tests and take a look. Out of interest (I'm assuming you're running on Windows) - do you have the unlimited filename length Windows feature enabled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hadn't & I have now, but it seems VS Code still complains.
I do this normally at work, but just checking here before I do it. If I rebase my branch with these changes onto master, it's not going to mess the pull request up is it? |
@simongh nope, it should be fine :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey @simongh
Thanks for pushing those changes - I've taken a look through and this mostly LGTM. I've picked out a few minor issues which I'll push a commit to fix so that we can get this merged (I hope you don't mind) and then kick off the tests - but otherwise we should be good to merge this :)
Thanks!
ResourceName: resourceName, | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor we can actually remove this, since it's empty
|
||
## Import | ||
|
||
A SQL Active Directory Administratir can be imported using the `resource id`, e.g. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor Administratir
-> Administrator
|
||
* `server_name` - (Required) The name of the SQL Server on which to set the administrator | ||
|
||
* `resource_group_name` - (Required) The name of the resource group for the SQL server. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we append Changing this forces a new resource to be created.
to this?
|
||
The following arguments are supported: | ||
|
||
* `server_name` - (Required) The name of the SQL Server on which to set the administrator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we append Changing this forces a new resource to be created.
to this?
Add a Active Directory administrator to a SQL server | ||
--- | ||
|
||
# azurerm\_sql\_active\_directory\_administrator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor we don't need the backslashes here
azurerm_sql_active_directory_administrator
Tests pass:
|
That's all good. Happy to have contributed. |
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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks! |
I've added the ability to set the AD administrator on SQL servers.
This is my first attempt at using GO and writing anything for Terraform, so I've probably made egregious mistakes.
It appeared to work when I tried it out on my Azure.