Improve backward compatibility for now

This commit is contained in:
Colin Hebert 2015-03-07 17:16:59 +11:00
parent 9e233a5cd7
commit 2260045dc8
1 changed files with 6 additions and 2 deletions

View File

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