-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
IoT Hub add endpoints and routes #1693
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 @andrey-moor
Thanks for this PR :)
I've taken a look through and left some comments in-line but this is otherwise off to a good start - if we can fix up the comments then we should be able to run the tests and get this merged :)
Thanks!
azurerm/resource_arm_iothub.go
Outdated
"condition": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Default: "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.
is there a reason why this is a String rather than a Bool?
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 is intentional - there a special query syntax to filter events before routing them (
https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-query-language#device-to-cloud-message-routes-query-expression). But I think it makes sense to add a comment to avoid confusion in the future.
@@ -142,13 +243,26 @@ func resourceArmIotHubCreateAndUpdate(d *schema.ResourceData, meta interface{}) | |||
skuInfo := expandIoTHubSku(d) | |||
tags := d.Get("tags").(map[string]interface{}) | |||
|
|||
endpoints, err := expandIoTHubEndpoints(d, subscriptionID) |
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 raise this error? e.g.
if err != nil {
return fmt.Errorf("Error expanding `endpoints`: %+v", err)
}
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.
Yeah, good point - I've added error message.
azurerm/resource_arm_iothub.go
Outdated
condition := route["condition"].(string) | ||
|
||
endpointNamesRaw := route["endpoint_names"].([]interface{}) | ||
endpointsNames := make([]string, 0, len(endpointNamesRaw)) |
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 ditch the last argument here (len(endpointNamesRaw)
) - this'll cause a series of blank items to be appended to the end of the array
azurerm/resource_arm_iothub.go
Outdated
|
||
if input != nil && input.Endpoints != nil { | ||
|
||
for _, container := range *input.Endpoints.StorageContainers { |
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 nil-check around this to ensure input.Endpoints.StorageContainers
isn't nil?
azurerm/resource_arm_iothub.go
Outdated
results = append(results, output) | ||
} | ||
|
||
for _, queue := range *input.Endpoints.ServiceBusQueues { |
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 nil-check around this to ensure input.Endpoints.ServiceBusQueues
isn't nil?
azurerm/resource_arm_iothub.go
Outdated
results = append(results, output) | ||
} | ||
|
||
for _, topic := range *input.Endpoints.ServiceBusTopics { |
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 nil-check around this to ensure input.Endpoints.ServiceBusTopics
isn't nil?
azurerm/resource_arm_iothub.go
Outdated
results = append(results, output) | ||
} | ||
|
||
for _, eventHub := range *input.Endpoints.EventHubs { |
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 nil-check around this to ensure input.Endpoints.EventHubs
isn't nil?
azurerm/resource_arm_iothub_test.go
Outdated
@@ -100,9 +115,28 @@ resource "azurerm_iothub" "test" { | |||
capacity = "1" | |||
} | |||
|
|||
endpoint { |
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 split this out into it's own test?
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.
Agree - that will make it cleaner
@tombuildsstuff thanks for the comments. Is there a clean way to execute acceptance tests against specific resource type? (wasn't able to figure it out by a quick look) |
@andrey-moor you should be able to do that via:
where I'll kick these off in our CI system in the mean time :) |
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.
a couple of changes needed but this otherwise LGTM 👍
azurerm/resource_arm_iothub.go
Outdated
|
||
if input != nil && input.Endpoints != nil { | ||
|
||
storageContainers := *input.Endpoints.StorageContainers |
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.
there's actually a crash here if .StorageContainers is nil (since the *
is dereferencing the pointer) - we can instead make this:
if container := input.Endpoints.StorageContainers; container != nil {
# .. use *container as needed
}
azurerm/resource_arm_iothub.go
Outdated
} | ||
|
||
sbTopics := *input.Endpoints.ServiceBusTopics | ||
if sbTopics != nil { |
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.
(as above)
azurerm/resource_arm_iothub.go
Outdated
} | ||
|
||
eventHubs := *input.Endpoints.EventHubs | ||
if eventHubs != nil { |
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.
(as above)
azurerm/resource_arm_iothub.go
Outdated
} | ||
|
||
sbQueues := *input.Endpoints.ServiceBusQueues | ||
if sbQueues != nil { |
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.
(as above)
azurerm/resource_arm_iothub.go
Outdated
}, | ||
Required: true, | ||
}, | ||
"is_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'd suggest this could better match other resources in Terraform by being enabled
rather than is_enabled
- but this isn't a blocker; what do you think?
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.
Good point 👍
@tombuildsstuff is there anything else we can do here? |
@andrey-moor hey sorry for the delayed re-review here - I've pushed one commit to fix a minor documentation issue but this now LGTM - we're prepping for the release of v1.13.0 but we'll kickoff the tests for this once that's out :) |
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 @andrey-moor
Thanks for pushing those changes - I've taken a look through and this now LGTM - thanks for this / sorry for the delay getting this re-reviewed 👍
Thanks!
* master: (95 commits) Some more AzureStack changes for route table resource and datasource (hashicorp#1807) backport AzureStack route resource PR comments (hashicorp#1810) Updating to include hashicorp#1799 Bug Fix of azurerm_virtual_machine.storage_os_disk.image_uri (hashicorp#1799) Updating to include hashicorp#1693 IoT Hub add endpoints and routes (hashicorp#1693) Updating to include hashicorp#1789 Added support for EventHub compatible EndPoints and Paths (hashicorp#1789) Updating to include hashicorp#1798 Remove client side validation for azure network plugin (hashicorp#1798) backport azure stack route_table PR review comments (hashicorp#1790) Update CHAGELOG.md to include hashicorp#1795 Fix: Corrected regexp for eventhub name reset verb fix some pointer dereferences Fix indentation on application_gateway.html.markdown (hashicorp#1780) folded subscription and [az]schema packages into azure consolidate CaseDifference Supression functions Cleanup after v1.13.0 release v1.13.0 ...
hey @andrey-moor Just to let you know that this has been released in v1.14.0 of the AzureRM Provider which is now available: https://github.com/terraform-providers/terraform-provider-azurerm/blob/v1.14.0/CHANGELOG.md Thanks! |
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! |
Adds
endpoint
androute
blocks to allow configuring routes as part of the IoT Hub resource.