providers/aws: properly create an i nstance after destroy

This commit is contained in:
Mitchell Hashimoto 2014-06-25 18:49:30 -07:00
parent b6a02e473d
commit e8035a5c96
2 changed files with 13 additions and 2 deletions

View File

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

View File

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