diff --git a/builtin/providers/cloudstack/resource_cloudstack_template.go b/builtin/providers/cloudstack/resource_cloudstack_template.go index 2d5c42497..12de2152a 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_template.go +++ b/builtin/providers/cloudstack/resource_cloudstack_template.go @@ -130,17 +130,6 @@ func resourceCloudStackTemplateCreate(d *schema.ResourceData, meta interface{}) return e.Error() } - // If there is a project supplied, we retrieve and set the project id - if project, ok := d.GetOk("project"); ok { - // Retrieve the project UUID - projectid, e := retrieveUUID(cs, "project", project.(string)) - if e != nil { - return e.Error() - } - // Set the default project ID - p.SetProjectid(projectid) - } - // Retrieve the zone UUID zoneid, e := retrieveUUID(cs, "zone", d.Get("zone").(string)) if e != nil { @@ -178,6 +167,17 @@ func resourceCloudStackTemplateCreate(d *schema.ResourceData, meta interface{}) p.SetPasswordenabled(v.(bool)) } + // If there is a project supplied, we retrieve and set the project id + if project, ok := d.GetOk("project"); ok { + // Retrieve the project UUID + projectid, e := retrieveUUID(cs, "project", project.(string)) + if e != nil { + return e.Error() + } + // Set the default project ID + p.SetProjectid(projectid) + } + // Create the new template r, err := cs.Template.RegisterTemplate(p) if err != nil {