-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,12 @@ func resourceArmNetworkInterface() *schema.Resource { | |
Computed: true, | ||
}, | ||
|
||
"private_ip_address": &schema.Schema{ | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Computed: true, | ||
}, | ||
|
||
"virtual_machine_id": &schema.Schema{ | ||
Type: schema.TypeString, | ||
Optional: true, | ||
|
@@ -241,7 +247,7 @@ func resourceArmNetworkInterfaceRead(d *schema.ResourceData, meta interface{}) e | |
return nil | ||
} | ||
if err != nil { | ||
return fmt.Errorf("Error making Read request on Azure Netowkr Interface %s: %s", name, err) | ||
return fmt.Errorf("Error making Read request on Azure Network Interface %s: %s", name, err) | ||
} | ||
|
||
iface := *resp.Properties | ||
|
@@ -252,6 +258,17 @@ func resourceArmNetworkInterfaceRead(d *schema.ResourceData, meta interface{}) e | |
} | ||
} | ||
|
||
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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At the moment we can only specify one ip configuration. 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 commentThe 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:
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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. I hit the same problem as last time.
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 commentThe 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:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I will push the change in a moment. |
||
} | ||
|
||
if *privateIPAddress != "" { | ||
d.Set("private_ip_address", *privateIPAddress) | ||
} | ||
} | ||
|
||
if iface.VirtualMachine != nil { | ||
if *iface.VirtualMachine.ID != "" { | ||
d.Set("virtual_machine_id", *iface.VirtualMachine.ID) | ||
|
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.