providers/aws/aws_instance: fix security group and key name issues in count
This commit is contained in:
parent
e8eae17cc9
commit
9ec1990608
|
@ -202,13 +202,18 @@ func resource_aws_instance_diff(
|
|||
|
||||
ComputedAttrs: []string{
|
||||
"availability_zone",
|
||||
"key_name",
|
||||
"public_dns",
|
||||
"public_ip",
|
||||
"private_dns",
|
||||
"private_ip",
|
||||
"security_groups",
|
||||
"subnet_id",
|
||||
},
|
||||
}
|
||||
|
||||
// TODO(mitchellh): figure out way to diff user_data_hash
|
||||
|
||||
return b.Diff(s, c)
|
||||
}
|
||||
|
||||
|
|
|
@ -120,6 +120,13 @@ func (b *ResourceBuilder) Diff(
|
|||
comp = true
|
||||
break
|
||||
}
|
||||
|
||||
// If the key is prefixed with the computed key, don't
|
||||
// mark it for delete, ever.
|
||||
if strings.HasPrefix(k, ck+".") {
|
||||
comp = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if comp {
|
||||
continue
|
||||
|
|
|
@ -37,6 +37,34 @@ func TestResourceBuilder_attrSetComputed(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestResourceBuilder_attrSetComputedComplex(t *testing.T) {
|
||||
rb := &ResourceBuilder{
|
||||
Attrs: map[string]AttrType{
|
||||
"foo": AttrTypeCreate,
|
||||
},
|
||||
ComputedAttrs: []string{
|
||||
"foo",
|
||||
},
|
||||
}
|
||||
|
||||
state := &terraform.ResourceState{
|
||||
ID: "foo",
|
||||
Attributes: map[string]string{
|
||||
"foo.#": "0",
|
||||
},
|
||||
}
|
||||
|
||||
c := testConfig(t, map[string]interface{}{}, nil)
|
||||
|
||||
diff, err := rb.Diff(state, c)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
if diff != nil {
|
||||
t.Fatalf("diff shold be nil: %s", diff)
|
||||
}
|
||||
}
|
||||
|
||||
func TestResourceBuilder_replaceComputed(t *testing.T) {
|
||||
rb := &ResourceBuilder{
|
||||
Attrs: map[string]AttrType{
|
||||
|
|
Loading…
Reference in New Issue