providers/aws/aws_instance: fix security group and key name issues in count

This commit is contained in:
Mitchell Hashimoto 2014-07-16 15:21:01 -07:00
parent e8eae17cc9
commit 9ec1990608
3 changed files with 40 additions and 0 deletions

View File

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

View File

@ -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

View File

@ -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{