-
Notifications
You must be signed in to change notification settings - Fork 9.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
Adding private ip address reference to azurerm network interface #6538
Conversation
Felivel
commented
May 8, 2016
- Adding private ip address reference
- Updating the docs.
I am working on creating the test for this PR. |
Hi @Felivel Please let me know when you are happy for this to go on review. We hope to release 0.6.16 tomorrow (Monday) and this would be a nice addition to it :) Paul |
* adding private ip address reference * Updating the docs.
Hello @stack72, Please review my change. I have added an extra attribute called Is there way to access an attribute of an attribute? or are we limited to Thanks. |
I have done testing with a private build and have integrated the changes to my workflows. Everything seems to be working fine. |
if iface.IPConfigurations != nil && len(*iface.IPConfigurations) > 0 { | ||
var privateIPAddress *string | ||
for _, ipConfig := range *iface.IPConfigurations { | ||
privateIPAddress = ipConfig.Properties.PrivateIPAddress |
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.
we are ranging over a collection here and adding each private ip address in an IPConfig to the same string variable
Should the schema have private_ip_address
as a List? Or can we guarantee that only 1 private IP will be in place?
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.
At the moment we can only specify one ip configuration.
Azure/azure-sdk-for-go#259
Maybe we can pick the primary ip configuration once we are able to multiple configurations.
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.
Ok, if there is only 1, then we shouldn't range over right now
We should do something like this:
if iface.IPConfigurations != nil && len(*iface.IPConfigurations) > 0 {
var privateIPAddress *string
if iface.IPConfigurations[0] != nil {
privateIPAddress = iface.IPConfigurations[0].Properties.PrivateIPAddress
}
}
Then leave a note in place referencing that Azure SDK issue where only 1 NIC is allowed - thoughts?
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.
Looks good. I tried doing that but I was getting some errors. I will try it again.
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 hit the same problem as last time.
builtin/providers/azurerm/resource_arm_network_interface_card.go:264:
invalid operation: iface.IPConfigurations[0] (type *[]network.InterfaceIPConfiguration does not support indexing)
Should I assign the pointer value to a variable and try like that?
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.
Hi @Felivel
The issue here is that you cannot index when a pointer is in play. So it has to be dereferrenced like this:
(*iface.IPConfigurations)[0].Properties.PrivateIPAddress
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.
Ok, I will push the change in a moment.
Hi @Felivel I have a few questions inline. Once answered, we should be able to merge this. P. |
@@ -53,6 +53,12 @@ func resourceArmNetworkInterface() *schema.Resource { | |||
Computed: true, | |||
}, | |||
|
|||
"private_ip_address": &schema.Schema{ |
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.
We are only using this part of the schema in the Read func. Is this not allowed to be set specifically? If not, then we can just make it Computed, and remove optional
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.
Done.
Removing optional attribute from private_ip_address, this element is only being used in the read.
Change this to a loop when Azure/azure-sdk-for-go#259 is fixed
Hi @Felivel this looks great :) At the end of a Terraform run, I can now get the following:
|
…hicorp#6538) * Adding private ip address reference * adding private ip address reference * Updating the docs. * Removing optional attrib from private_ip_address Removing optional attribute from private_ip_address, this element is only being used in the read. * Selecting the first element instead of using a loop for now. Change this to a loop when Azure/azure-sdk-for-go#259 is fixed
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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |