Skip to content

Commit

Permalink
Fix issue #1830
Browse files Browse the repository at this point in the history
  • Loading branch information
VaishnaviGopal authored and hkantare committed Aug 26, 2020
1 parent 4949d90 commit f1a36bb
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
38 changes: 31 additions & 7 deletions ibm/resource_ibm_is_instance.go
Expand Up @@ -207,6 +207,8 @@ func resourceIBMISInstance() *schema.Resource {
},
isInstanceNicPrimaryIpv4Address: {
Type: schema.TypeString,
ForceNew: true,
Optional: true,
Computed: true,
},
isInstanceNicSecurityGroups: {
Expand Down Expand Up @@ -241,6 +243,8 @@ func resourceIBMISInstance() *schema.Resource {
},
isInstanceNicPrimaryIpv4Address: {
Type: schema.TypeString,
ForceNew: true,
Optional: true,
Computed: true,
},
isInstanceNicSecurityGroups: {
Expand Down Expand Up @@ -487,6 +491,11 @@ func classicInstanceCreate(d *schema.ResourceData, meta interface{}, profile, na
if ok {
primnicobj.Name = &namestr
}
ipv4, _ := primnic[isInstanceNicPrimaryIpv4Address]
ipv4str := ipv4.(string)
if ipv4str != "" {
primnicobj.PrimaryIpv4Address = &ipv4str
}
secgrpintf, ok := primnic[isInstanceNicSecurityGroups]
if ok {
secgrpSet := secgrpintf.(*schema.Set)
Expand Down Expand Up @@ -521,6 +530,11 @@ func classicInstanceCreate(d *schema.ResourceData, meta interface{}, profile, na
if ok && namestr != "" {
nwInterface.Name = &namestr
}
ipv4, _ := nic[isInstanceNicPrimaryIpv4Address]
ipv4str := ipv4.(string)
if ipv4str != "" {
nwInterface.PrimaryIpv4Address = &ipv4str
}
secgrpintf, ok := nic[isInstanceNicSecurityGroups]
if ok {
secgrpSet := secgrpintf.(*schema.Set)
Expand Down Expand Up @@ -623,13 +637,13 @@ func instanceCreate(d *schema.ResourceData, meta interface{}, profile, name, vpc
if ok {
volTemplate.Name = &namestr
}
// enc, ok := bootvol[isInstanceBootEncryption]
// encstr := enc.(string)
// if ok && encstr != "" {
// volTemplate.EncryptionKey = &vpcv1.EncryptionKeyIdentity{
// Crn: &encstr,
// }
// }
enc, ok := bootvol[isInstanceBootEncryption]
encstr := enc.(string)
if ok && encstr != "" {
volTemplate.EncryptionKey = &vpcv1.EncryptionKeyIdentity{
CRN: &encstr,
}
}
volcap := 100
volcapint64 := int64(volcap)
volprof := "general-purpose"
Expand Down Expand Up @@ -657,6 +671,11 @@ func instanceCreate(d *schema.ResourceData, meta interface{}, profile, name, vpc
if namestr != "" {
primnicobj.Name = &namestr
}
ipv4, _ := primnic[isInstanceNicPrimaryIpv4Address]
ipv4str := ipv4.(string)
if ipv4str != "" {
primnicobj.PrimaryIpv4Address = &ipv4str
}
secgrpintf, ok := primnic[isInstanceNicSecurityGroups]
if ok {
secgrpSet := secgrpintf.(*schema.Set)
Expand Down Expand Up @@ -690,6 +709,11 @@ func instanceCreate(d *schema.ResourceData, meta interface{}, profile, name, vpc
if ok && namestr != "" {
nwInterface.Name = &namestr
}
ipv4, _ := nic[isInstanceNicPrimaryIpv4Address]
ipv4str := ipv4.(string)
if ipv4str != "" {
nwInterface.PrimaryIpv4Address = &ipv4str
}
secgrpintf, ok := nic[isInstanceNicSecurityGroups]
if ok {
secgrpSet := secgrpintf.(*schema.Set)
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/is_instance.html.markdown
Expand Up @@ -164,11 +164,13 @@ The following arguments are supported:
Nested `primary_network_interface` block have the following structure:
* `name` - (Optional, string) The name of the network interface.
* `port_speed` - (Deprecated, int) Speed of the network interface.
* `primary_ipv4_address` - (Optional, Forces new resource, string) The IPV4 address of the interface
* `subnet` - (Required, string) ID of the subnet.
* `security_groups` - (Optional, list) Comma separated IDs of security groups.
* `network_interfaces` - (Optional, Forces new resource, list) A nested block describing the additional network interface of this instance.
Nested `network_interfaces` block have the following structure:
* `name` - (Optional, string) The name of the network interface.
* `primary_ipv4_address` - (Optional, Forces new resource, string) The IPV4 address of the interface
* `subnet` - (Required, string) ID of the subnet.
* `security_groups` - (Optional, list) Comma separated IDs of security groups.

Expand Down

0 comments on commit f1a36bb

Please sign in to comment.