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

azurerm_data_factory_linked_service_data_lake_storage_gen2 - Supports managed identity auth through use_managed_identity #8938

Merged
merged 3 commits into from
Nov 2, 2020

Conversation

dnlbunting
Copy link
Contributor

Closes #6501

Adds a use_managed_identity flag to azurerm_data_factory_linked_service_data_lake_storage_gen2.

If both use_managed_identity=true and service_principal_key or service_principal_id are specified raises an error.

First contribution so feel free to add feedback

…ate using managed identity

Error if neither MI nor SPN are specified

Remove auth ocnflict
Copy link
Member

@mbfrahry mbfrahry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @dnlbunting, thanks for opening this PR! Things look nearly there but some of the validation you wrote can be better surfaced at the plan level so we error before Terraform even applies. I've detailed some of what you need below and feel free to reach out if you have any questions around it.

ValidateFunc: validation.IsUUID,
},

"service_principal_key": {
Type: schema.TypeString,
Required: true,
Optional: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a nifty schema valdiation check we can add. It's called RequiredWith and it takes an array of strings and makes sure that if one of those attributes is specified, than all of the attributes in that array must also be specified. It'll error if any aren't which should remove the logic you wrote out down below!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll also probably want do add ConflictsWith: []string{"use_managed_identity"} to all of these attributes

@@ -58,21 +58,27 @@ func resourceArmDataFactoryLinkedServiceDataLakeStorageGen2() *schema.Resource {
ValidateFunc: validation.IsURLWithHTTPS,
},

"use_managed_identity": {
Type: schema.TypeBool,
Optional: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll want to add ConflictsWith here too to make sure we don't specify it with the other service principal attributes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And to round it all out we should throw in AtLeastOneOf with all of these attributes to make sure at least one of them gets specified when creating this resource.

Copy link
Member

@mbfrahry mbfrahry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, would it make sense to just infer that we should use managed identity if we don't specify the service principal? Or is it better for the user to purposefully specify that they want managed identity?

@dnlbunting
Copy link
Contributor Author

@mbfrahry Thanks for the pointers on the schema validation, I'll make those changes. IMO making the managed identity opt-in rather the the default was clearer, since the managed identity has to be explicitly enabled in the parent ADF resource too.

@ghost ghost removed the waiting-response label Oct 29, 2020
@mbfrahry
Copy link
Member

That works for me! I'll look forward to the schema validation changes

Copy link
Member

@mbfrahry mbfrahry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@mbfrahry mbfrahry added this to the v2.35.0 milestone Nov 2, 2020
@mbfrahry mbfrahry changed the title Allow azurerm_data_factory_linked_service_data_lake_storage_gen2 to auth with managed identity azurerm_data_factory_linked_service_data_lake_storage_gen2 - Supports managed identity auth through use_managed_identity Nov 2, 2020
@mbfrahry
Copy link
Member

mbfrahry commented Nov 2, 2020

Thanks for this @dnlbunting. It should make it into the next release!

@mbfrahry mbfrahry merged commit 986955e into hashicorp:master Nov 2, 2020
mbfrahry added a commit that referenced this pull request Nov 2, 2020
@dnlbunting dnlbunting deleted the adlsgen2-managed-identity branch November 3, 2020 11:39
@ghost
Copy link

ghost commented Nov 5, 2020

This has been released in version 2.35.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 2.35.0"
}
# ... other configuration ...

@ghost
Copy link

ghost commented Dec 3, 2020

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 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Dec 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for adding Managed Identity to Linked Services to ADLS Gen 2 for Azure Data Factory.
3 participants