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

New resources: azurerm_iothub_device_update_account azurerm_iothub_device_update_instance #18789

Merged
merged 3 commits into from
Oct 27, 2022

Conversation

myc2h6o
Copy link
Contributor

@myc2h6o myc2h6o commented Oct 17, 2022

Copy link
Member

@stephybun stephybun left a comment

Choose a reason for hiding this comment

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

Thanks for this PR @myc2h6o, there are still some test failures relating to the region though

------- Stdout: -------
=== RUN   TestAccIotHubDeviceUpdateAccount_sku
=== PAUSE TestAccIotHubDeviceUpdateAccount_sku
=== CONT  TestAccIotHubDeviceUpdateAccount_sku
testcase.go:110: Step 1/4 error: Error running apply: exit status 1
Error: creating Account (Subscription: "*******"
Resource Group Name: "acctest-rg-221018105259715989"
Account Name: "acc-dua-eu3sy"): performing AccountsCreate: deviceupdates.DeviceupdatesClient#AccountsCreate: Failure sending request: StatusCode=0 -- Original Error: Code="LocationNotAvailableForResourceType" Message="The provided location 'westeurope' is not available for resource type 'Microsoft.DeviceUpdate/accounts'. List of available regions for the resource type is 'westus2,northeurope,southeastasia,eastus,eastus2,southcentralus,swedencentral,uksouth,westus3'."
with azurerm_iothub_device_update_account.test,
on terraform_plugin_test.tf line 13, in resource "azurerm_iothub_device_update_account" "test":
13: resource "azurerm_iothub_device_update_account" "test" {
creating Account (Subscription: "*******"
Resource Group Name: "acctest-rg-221018105259715989"
Account Name: "acc-dua-eu3sy"): performing AccountsCreate:
deviceupdates.DeviceupdatesClient#AccountsCreate: Failure sending request:
StatusCode=0 -- Original Error: Code="LocationNotAvailableForResourceType"
Message="The provided location 'westeurope' is not available for resource
type 'Microsoft.DeviceUpdate/accounts'. List of available regions for the
resource type is
'westus2,northeurope,southeastasia,eastus,eastus2,southcentralus,swedencentral,uksouth,westus3'."
--- FAIL: TestAccIotHubDeviceUpdateAccount_sku (120.85s)
FAIL

@myc2h6o
Copy link
Contributor Author

myc2h6o commented Oct 19, 2022

Hi @stephybun thanks for reviewing the pr! I've already updated the region here: https://github.com/hashicorp/terraform-provider-azurerm/pull/18789/files#diff-c9a4f5ece9fe921f274cae0220ba39a13027c503c6bd80e3cc9ee926565a5c94, to replace the westeurope with northeurope, however the test seems to be run within westeurope still. Does it require the change to be merged to allow the config to take effect or am I doing something wrong there?

The test runs well with overriden parameter:
image

@myc2h6o
Copy link
Contributor Author

myc2h6o commented Oct 20, 2022

Hi @stephybun I've double checked, looks like the .teamcity location settings only take effect after merged. I've split out the test location change to #18884

@myc2h6o
Copy link
Contributor Author

myc2h6o commented Oct 21, 2022

The separate pr for updating test location is working fine. Here is the updated test result
image

Copy link
Member

@jackofallops jackofallops left a comment

Choose a reason for hiding this comment

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

Thanks @myc2h6o
The update methods I think need revisiting. The removal of the data from the payloads there is an anti-pattern that shouldn't be necessary and we should avoid within the provider. Can you speak with the service team on your side to resolve?

Thanks!

Comment on lines 253 to 255
existing.Properties.HostName = nil
existing.Properties.Locations = nil
existing.SystemData = nil
Copy link
Member

Choose a reason for hiding this comment

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

This shouldn't need to be zeroed, ARM spec says the service is supposed to ignore R/O fields on update payloads? Needing this would indicated a bug?

existing.Tags = &model.Tags
}

existing.SystemData = nil
Copy link
Member

Choose a reason for hiding this comment

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

As above, this shouldn't be necessary.

}

if matched := regexp.MustCompile(`^[A-Za-z0-9]+(-[A-Za-z0-9]+)*$`).Match([]byte(value)); !matched {
errors = append(errors, fmt.Errorf("%q may only contain alphanumeric characters and dashes, and consecutive dashes (-) are not allowed", k))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
errors = append(errors, fmt.Errorf("%q may only contain alphanumeric characters and dashes, and consecutive dashes (-) are not allowed", k))
errors = append(errors, fmt.Errorf("%q must start with an alphanumeric, may only contain alphanumeric characters and dashes, and consecutive dashes (-) are not allowed", k))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Error message updated.

@myc2h6o
Copy link
Contributor Author

myc2h6o commented Oct 25, 2022

Hi @jackofallops thanks for reviewing the pr! I've updated the error message, and removed the unexpected assignment of HostName and Locations in the Update function.
As for SystemData, it is a workaround before the Pandora side fix hashicorp/pandora#1096 is done, similar to signalr_service, I've added comment around the code.

@myc2h6o
Copy link
Contributor Author

myc2h6o commented Oct 25, 2022

Test result after the update
image


* `identity` - (Optional) An `identity` block as defined below.

* `public_network_access` - (Optional) The Public Network Access setting of the IoT Hub Device Update Account. Possible values are `Enabled` and `Disabled`. Defaults to `Enabled`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is a bool?

Suggested change
* `public_network_access` - (Optional) The Public Network Access setting of the IoT Hub Device Update Account. Possible values are `Enabled` and `Disabled`. Defaults to `Enabled`.
* `public_network_access_enabled` - (Optional) The Public Network Access setting of the IoT Hub Device Update Account. Possible values are `Enabled` and `Disabled`. Defaults to `Enabled`.


* `name` - (Required) Specifies the name which should be used for this IoT Hub Device Update Instance. Changing this forces a new resource to be created.

* `iothub_device_update_account_id` - (Required) Specifies the ID of the IoT Hub Device Update Account where the IoT Hub Device Update Instance exists. Changing this forces a new resource to be created.
Copy link
Collaborator

Choose a reason for hiding this comment

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

iothub is in the rsource name so

Suggested change
* `iothub_device_update_account_id` - (Required) Specifies the ID of the IoT Hub Device Update Account where the IoT Hub Device Update Instance exists. Changing this forces a new resource to be created.
* `device_update_account_id` - (Required) Specifies the ID of the IoT Hub Device Update Account where the IoT Hub Device Update Instance exists. Changing this forces a new resource to be created.

@myc2h6o
Copy link
Contributor Author

myc2h6o commented Oct 27, 2022

Hi @katbyte thanks for reviewing the pr! I've renamed iothub_device_update_account_id to device_update_account_id and public_network_access (string) to public_network_access_enabled (bool). Also simplified some test cases. Please take a look.

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

Thanks @myc2h6o - LGTM 🗺️

@katbyte katbyte merged commit 74b3cbd into hashicorp:main Oct 27, 2022
katbyte added a commit that referenced this pull request Oct 27, 2022
@github-actions github-actions bot added this to the v3.29.0 milestone Oct 27, 2022
@github-actions
Copy link

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

@myc2h6o myc2h6o deleted the device_update branch October 28, 2022 13:57
@github-actions
Copy link

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 Nov 28, 2022
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.

4 participants