From 0d557a605f7d04dd79159f364756e4bbc5f8c5d0 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 17 Jun 2014 19:14:44 -0700 Subject: [PATCH] providers/aws: use new diff package --- builtin/providers/aws/diff.go | 33 ++++++++++++++++++++++ builtin/providers/aws/resource_provider.go | 28 +----------------- 2 files changed, 34 insertions(+), 27 deletions(-) create mode 100644 builtin/providers/aws/diff.go diff --git a/builtin/providers/aws/diff.go b/builtin/providers/aws/diff.go new file mode 100644 index 000000000..7cad8592e --- /dev/null +++ b/builtin/providers/aws/diff.go @@ -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", + }, + } +} diff --git a/builtin/providers/aws/resource_provider.go b/builtin/providers/aws/resource_provider.go index 00da3b37f..62459f2fa 100644 --- a/builtin/providers/aws/resource_provider.go +++ b/builtin/providers/aws/resource_provider.go @@ -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 {