providers/aws: use new diff package

This commit is contained in:
Mitchell Hashimoto 2014-06-17 19:14:44 -07:00
parent 847cd7ac51
commit 0d557a605f
2 changed files with 34 additions and 27 deletions

View File

@ -0,0 +1,33 @@
package aws
import (
"github.com/hashicorp/terraform/diff"
)
var diffBuilder *diff.LazyResourceMap
func init() {
diffBuilder = &diff.LazyResourceMap{
Resources: map[string]diff.ResourceBuilderFactory{
"aws_instance": diffBuilder_aws_instance,
},
}
}
func diffBuilder_aws_instance() *diff.ResourceBuilder {
return &diff.ResourceBuilder{
CreateComputedAttrs: []string{
"public_dns",
"public_ip",
"private_dns",
"private_ip",
},
RequiresNewAttrs: []string{
"ami",
"availability_zone",
"instance_type",
"region",
},
}
}

View File

@ -23,33 +23,7 @@ func (p *ResourceProvider) Configure(*terraform.ResourceConfig) error {
func (p *ResourceProvider) Diff(
s *terraform.ResourceState,
c *terraform.ResourceConfig) (*terraform.ResourceDiff, error) {
diffMap.CreateAttrs([]string{
"ami",
"availability_zone",
"instance_type",
"region",
})
diffMap.CreateComputedAttrs([]string{
"id",
"public_dns",
"public_ip",
"private_dns",
"private_ip",
})
return &terraform.ResourceDiff{
Attributes: map[string]*terraform.ResourceAttrDiff{
"id": &terraform.ResourceAttrDiff{
Old: "",
NewComputed: true,
RequiresNew: true,
},
"created": &terraform.ResourceAttrDiff{
Old: "false",
New: "true",
},
},
}, nil
return nil, nil
}
func (p *ResourceProvider) Resources() []terraform.ResourceType {