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

IoT Hub add endpoints and routes #1693

Merged
merged 10 commits into from
Aug 21, 2018
Merged

IoT Hub add endpoints and routes #1693

merged 10 commits into from
Aug 21, 2018

Conversation

andrey-moor
Copy link
Contributor

Adds endpoint and route blocks to allow configuring routes as part of the IoT Hub resource.

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 @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!

"condition": {
Type: schema.TypeString,
Optional: true,
Default: "true",
Copy link
Contributor

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?

Copy link
Contributor Author

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)
Copy link
Contributor

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)
}

Copy link
Contributor Author

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.

condition := route["condition"].(string)

endpointNamesRaw := route["endpoint_names"].([]interface{})
endpointsNames := make([]string, 0, len(endpointNamesRaw))
Copy link
Contributor

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


if input != nil && input.Endpoints != nil {

for _, container := range *input.Endpoints.StorageContainers {
Copy link
Contributor

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?

results = append(results, output)
}

for _, queue := range *input.Endpoints.ServiceBusQueues {
Copy link
Contributor

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?

results = append(results, output)
}

for _, topic := range *input.Endpoints.ServiceBusTopics {
Copy link
Contributor

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?

results = append(results, output)
}

for _, eventHub := range *input.Endpoints.EventHubs {
Copy link
Contributor

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?

@@ -100,9 +115,28 @@ resource "azurerm_iothub" "test" {
capacity = "1"
}

endpoint {
Copy link
Contributor

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?

Copy link
Contributor Author

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

@andrey-moor
Copy link
Contributor Author

andrey-moor commented Aug 1, 2018

@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)

@tombuildsstuff
Copy link
Contributor

@andrey-moor you should be able to do that via:

TF_ACC=1 go test ./azurerm -v -timeout 120m -run="TestAcc" -count=1

where TestAcc is the prefix of the tests to be run

I'll kick these off in our CI system in the mean time :)

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.

a couple of changes needed but this otherwise LGTM 👍


if input != nil && input.Endpoints != nil {

storageContainers := *input.Endpoints.StorageContainers
Copy link
Contributor

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
}

}

sbTopics := *input.Endpoints.ServiceBusTopics
if sbTopics != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

(as above)

}

eventHubs := *input.Endpoints.EventHubs
if eventHubs != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

(as above)

}

sbQueues := *input.Endpoints.ServiceBusQueues
if sbQueues != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

(as above)

},
Required: true,
},
"is_enabled": {
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point 👍

@metacpp metacpp requested a review from WodansSon August 3, 2018 00:03
@tombuildsstuff tombuildsstuff removed the request for review from WodansSon August 3, 2018 07:22
@tombuildsstuff tombuildsstuff added this to the 1.13.0 milestone Aug 3, 2018
@andrey-moor
Copy link
Contributor Author

@tombuildsstuff is there anything else we can do here?

@tombuildsstuff
Copy link
Contributor

tombuildsstuff commented Aug 15, 2018

@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 :)

@tombuildsstuff tombuildsstuff modified the milestones: 1.13.0, 1.14.0 Aug 15, 2018
@tombuildsstuff
Copy link
Contributor

Tests pass:

screenshot 2018-08-21 at 14 38 59

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 @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!

@tombuildsstuff tombuildsstuff merged commit 2db1532 into hashicorp:master Aug 21, 2018
tombuildsstuff added a commit that referenced this pull request Aug 21, 2018
torresdal added a commit to torresdal/terraform-provider-azurerm that referenced this pull request Aug 23, 2018
* 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
  ...
@tombuildsstuff
Copy link
Contributor

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!

@ghost
Copy link

ghost commented Mar 6, 2019

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 and limited conversation to collaborators Mar 6, 2019
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.

3 participants