diff --git a/builtin/providers/aws/resources.go b/builtin/providers/aws/resources.go index 3a5d383b0..86e0f5625 100644 --- a/builtin/providers/aws/resources.go +++ b/builtin/providers/aws/resources.go @@ -34,9 +34,15 @@ func resource_aws_instance_create( p := meta.(*ResourceProvider) ec2conn := p.ec2conn + // Merge the diff into the state so that we have all the attributes + // properly. Note that this merged state will contain some computed + // properties so it won't actually be our result (which we build from + // scratch later). + ms := s.MergeDiff(d) + runOpts := &ec2.RunInstances{ - ImageId: d.Attributes["ami"].New, - InstanceType: d.Attributes["instance_type"].New, + ImageId: ms.Attributes["ami"], + InstanceType: ms.Attributes["instance_type"], } log.Printf("[DEBUG] Run configuration: %#v", runOpts) diff --git a/terraform/terraform.go b/terraform/terraform.go index 8d26bd9ea..c3b159dec 100644 --- a/terraform/terraform.go +++ b/terraform/terraform.go @@ -170,6 +170,11 @@ func (t *Terraform) applyWalkFn( return nil, err } + // Make sure the result is instantiated + if rs == nil { + rs = new(ResourceState) + } + // Force the resource state type to be our type rs.Type = r.State.Type