Improve backward compatibility for now
This commit is contained in:
parent
9e233a5cd7
commit
2260045dc8
|
@ -459,7 +459,6 @@ func resourceAwsInstanceRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
// we use IDs if we're in a VPC. However, if we previously had an
|
// we use IDs if we're in a VPC. However, if we previously had an
|
||||||
// all-name list of security groups, we use names. Or, if we had any
|
// all-name list of security groups, we use names. Or, if we had any
|
||||||
// IDs, we use IDs.
|
// IDs, we use IDs.
|
||||||
// TODO: check the VPC ID instead?
|
|
||||||
useID := instance.SubnetId != ""
|
useID := instance.SubnetId != ""
|
||||||
// Deprecated: vpc security groups should be defined in vpc_security_group_ids
|
// Deprecated: vpc security groups should be defined in vpc_security_group_ids
|
||||||
if v := d.Get("security_groups"); v != nil {
|
if v := d.Get("security_groups"); v != nil {
|
||||||
|
@ -481,7 +480,12 @@ func resourceAwsInstanceRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
for i, sg := range instance.SecurityGroups {
|
for i, sg := range instance.SecurityGroups {
|
||||||
sgs[i] = sg.Id
|
sgs[i] = sg.Id
|
||||||
}
|
}
|
||||||
d.Set("vpc_security_group_ids", sgs)
|
// Keep some backward compatibility. The user is warned on creation.
|
||||||
|
if d.Get("security_groups") != nil {
|
||||||
|
d.Set("security_groups", sgs)
|
||||||
|
} else {
|
||||||
|
d.Set("vpc_security_group_ids", sgs)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
for i, sg := range instance.SecurityGroups {
|
for i, sg := range instance.SecurityGroups {
|
||||||
sgs[i] = sg.Name
|
sgs[i] = sg.Name
|
||||||
|
|
Loading…
Reference in New Issue