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_databricks_access_connector - add support for UserManaged identity. #21069

Closed
wants to merge 16 commits into from

Conversation

WodansSon
Copy link
Collaborator

@WodansSon WodansSon commented Mar 22, 2023

  • Upgrade the azurerm_databricks_access_connector API version from 2022-04-01-preview to 2022-10-01-preview which exposes UserManaged identities.

@WodansSon WodansSon changed the title azurerm_databricks_access_connector - add support for user_managed_identity field azurerm_databricks_access_connector - add support for UserManaged in type for identity code block Mar 22, 2023
@WodansSon WodansSon changed the title azurerm_databricks_access_connector - add support for UserManaged in type for identity code block azurerm_databricks_access_connector - add support for UserManaged in type field in the identity code block Mar 22, 2023
@WodansSon WodansSon changed the title azurerm_databricks_access_connector - add support for UserManaged in type field in the identity code block azurerm_databricks_access_connector - add support for UserManaged in the type field of the identity code block Mar 22, 2023
@github-actions github-actions bot added size/L and removed size/XL labels Mar 23, 2023
@WodansSon WodansSon changed the title azurerm_databricks_access_connector - add support for UserManaged in the type field of the identity code block azurerm_databricks_access_connector - add support for UserManaged and SystemManaged, UserManaged in identity code block. Mar 23, 2023
@github-actions github-actions bot added size/XL and removed size/L labels Mar 24, 2023
@WodansSon WodansSon changed the title azurerm_databricks_access_connector - add support for UserManaged and SystemManaged, UserManaged in identity code block. azurerm_databricks_access_connector - add support for UserManaged identity. Mar 24, 2023
@WodansSon WodansSon added this to the v3.50.0 milestone Mar 24, 2023
@WodansSon WodansSon marked this pull request as ready for review March 24, 2023 08:51
@WodansSon
Copy link
Collaborator Author

image

@WodansSon
Copy link
Collaborator Author

image

Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

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

hey @WodansSon

Thanks for this PR.

Taking a look through here whilst this is mostly looking good, we'll want to add a new type to the commonschema (and identity) packages here - we're intentionally no longer defining identity blocks within the Provider to ensure behavioural consistency across the provider. As such would you mind moving this logic there, introducing:

  1. The SystemOrUserAssignedIdentity schema method in commonschema.
  2. A typed model for SystemOrUserAssignedIdentity, as per the other types of Managed Identities in the identity package.
  3. An Expand and Flatten function for SystemOrUserAssignedIdentity so that we can ensure these are handled consistently.

Since it's taken a lot of coordination to make the identity types consistent, we're being particularly cautious with these - as such we'll need these types to exist within the commonschema and identity types to move forward here, but once those are present we can switch over to using those and this should otherwise be good to go :)

Thanks!

}
}

func (r AccessConnectorResource) Update() sdk.ResourceFunc {
return sdk.ResourceFunc{
Timeout: 5 * time.Minute,
Copy link
Contributor

Choose a reason for hiding this comment

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

if we're rate limited we'll hit this, we should make this 30m

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

@@ -66,97 +107,125 @@ func (r AccessConnectorResource) IDValidationFunc() pluginsdk.SchemaValidateFunc

func (r AccessConnectorResource) Create() sdk.ResourceFunc {
return sdk.ResourceFunc{
Timeout: 5 * time.Minute,
Copy link
Contributor

Choose a reason for hiding this comment

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

if we're rate limited we'll hit this, we should make this 30m

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

// UserAssigned Identity is supported for an Access Connector
// resource, not both together.') and only allows for a single 'identity_ids'
// to be passed...
"identity": {
Copy link
Contributor

Choose a reason for hiding this comment

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

rather than doing this, let's introduce a new commonschema type to support this, commonschema.SystemAssignedOrUserAssignedIdentity - identity is intentionally standardised across the provider now

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have opened PR #164 to address this comment...

Comment on lines +138 to +140
if identityValue.Type == identity.TypeUserAssigned && len(identityValue.IdentityIds) == 0 {
return fmt.Errorf("`identity_ids` must be specified when `type` is set to %q", string(identity.TypeUserAssigned))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

if we add an Expand and Flatten function to the identity package, then this logic can be made contained within the identity package, which'll ensure we keep this consistent - can we update this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have opened PR #164 to address this comment...

Comment on lines +94 to 115
func TestAccDatabricksAccessConnector_identityMissingIdentityIDsError(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_databricks_access_connector", "test")
r := DatabricksAccessConnectorResource{}
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.identityUserAssignedMissingIdentityIDs(data),
Check: acceptance.ComposeTestCheckFunc(),
ExpectError: regexp.MustCompile(`must be specified when`),
},
})
}

func TestAccDatabricksAccessConnector_identityUserAssignedTooManyError(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_databricks_access_connector", "test")
r := DatabricksAccessConnectorResource{}
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.identityUserAssignedTooManyError(data),
Check: acceptance.ComposeTestCheckFunc(),
ExpectError: regexp.MustCompile(`Too many list items`),
},
})
Copy link
Contributor

Choose a reason for hiding this comment

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

fwiw this logic should be handled by the identity package, so we should be able to remove these?


## Attributes Reference

The following attributes are exported:
The following Attributes are exported in addition to the Arguments listed above:
Copy link
Contributor

Choose a reason for hiding this comment

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

(minor) looks like we use this phrasing in other resources, we should probably make this consistent:

Suggested change
The following Attributes are exported in addition to the Arguments listed above:
In addition to the Arguments listed above - the following Attributes are exported:

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

@tombuildsstuff tombuildsstuff self-assigned this Mar 29, 2023
@tombuildsstuff
Copy link
Contributor

hey @WodansSon

Thanks for pushing those changes.

Apologies for the late notice here, but I've just spotted that this is a duplicate of #21059 and as such I hope you don't mind but I'm going to close this in favour of #21059.

I've confirmed that whilst the Swagger defines SystemAssigned,UserAssigned as a value - that it neither supports this (or SystemAssigned, UserAssigned) as a value - as such I've sent this PR to correct the Swagger to account for this, since this use-case applies to several other APIs, which'll allow us to represent this correctly in the SDK too.

Whilst the Swagger does allow for MaxItems to be defined for the userAssignedIdentityIds field, unfortunately since the Swagger's don't generally define this value to allow for service expansion, whilst we can add a MaxItems: 1 to the identity_ids value here, we've intentionally avoided doing so at this time.

As such I hope you don't mind but since #21059 was opened before this I'm going to close this PR in favour of #21059, but once that's merged we should be good to go here 👍

Thanks!

@github-actions
Copy link

This functionality has been released in v3.50.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

github-actions bot commented May 1, 2023

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, 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 May 1, 2023
@WodansSon WodansSon deleted the e_databricks_user_assigned_identity branch October 26, 2023 04:28
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.

2 participants