@@ -31,11 +31,12 @@ func resourceBlockStorageVolumeV1() *schema.Resource {
3131
3232 Schema : map [string ]* schema.Schema {
3333 "region" : & schema.Schema {
34- Type : schema .TypeString ,
35- Required : true ,
36- ForceNew : true ,
37- DefaultFunc : schema . EnvDefaultFunc ( "OS_REGION_NAME" , "" ) ,
34+ Type : schema .TypeString ,
35+ Optional : true ,
36+ Computed : true ,
37+ ForceNew : true ,
3838 },
39+
3940 "size" : & schema.Schema {
4041 Type : schema .TypeInt ,
4142 Required : true ,
@@ -111,7 +112,7 @@ func resourceBlockStorageVolumeV1() *schema.Resource {
111112
112113func resourceBlockStorageVolumeV1Create (d * schema.ResourceData , meta interface {}) error {
113114 config := meta .(* Config )
114- blockStorageClient , err := config .blockStorageV1Client (GetRegion (d ))
115+ blockStorageClient , err := config .blockStorageV1Client (GetRegion (d , config ))
115116 if err != nil {
116117 return fmt .Errorf ("Error creating OpenStack block storage client: %s" , err )
117118 }
@@ -165,7 +166,7 @@ func resourceBlockStorageVolumeV1Create(d *schema.ResourceData, meta interface{}
165166func resourceBlockStorageVolumeV1Read (d * schema.ResourceData , meta interface {}) error {
166167 config := meta .(* Config )
167168
168- blockStorageClient , err := config .blockStorageV1Client (GetRegion (d ))
169+ blockStorageClient , err := config .blockStorageV1Client (GetRegion (d , config ))
169170 if err != nil {
170171 return fmt .Errorf ("Error creating OpenStack block storage client: %s" , err )
171172 }
@@ -185,7 +186,7 @@ func resourceBlockStorageVolumeV1Read(d *schema.ResourceData, meta interface{})
185186 d .Set ("source_vol_id" , v .SourceVolID )
186187 d .Set ("volume_type" , v .VolumeType )
187188 d .Set ("metadata" , v .Metadata )
188- d .Set ("region" , GetRegion (d ))
189+ d .Set ("region" , GetRegion (d , config ))
189190
190191 attachments := make ([]map [string ]interface {}, len (v .Attachments ))
191192 for i , attachment := range v .Attachments {
@@ -202,7 +203,7 @@ func resourceBlockStorageVolumeV1Read(d *schema.ResourceData, meta interface{})
202203
203204func resourceBlockStorageVolumeV1Update (d * schema.ResourceData , meta interface {}) error {
204205 config := meta .(* Config )
205- blockStorageClient , err := config .blockStorageV1Client (GetRegion (d ))
206+ blockStorageClient , err := config .blockStorageV1Client (GetRegion (d , config ))
206207 if err != nil {
207208 return fmt .Errorf ("Error creating OpenStack block storage client: %s" , err )
208209 }
@@ -226,7 +227,7 @@ func resourceBlockStorageVolumeV1Update(d *schema.ResourceData, meta interface{}
226227
227228func resourceBlockStorageVolumeV1Delete (d * schema.ResourceData , meta interface {}) error {
228229 config := meta .(* Config )
229- blockStorageClient , err := config .blockStorageV1Client (GetRegion (d ))
230+ blockStorageClient , err := config .blockStorageV1Client (GetRegion (d , config ))
230231 if err != nil {
231232 return fmt .Errorf ("Error creating OpenStack block storage client: %s" , err )
232233 }
@@ -239,7 +240,7 @@ func resourceBlockStorageVolumeV1Delete(d *schema.ResourceData, meta interface{}
239240 // make sure this volume is detached from all instances before deleting
240241 if len (v .Attachments ) > 0 {
241242 log .Printf ("[DEBUG] detaching volumes" )
242- if computeClient , err := config .computeV2Client (GetRegion (d )); err != nil {
243+ if computeClient , err := config .computeV2Client (GetRegion (d , config )); err != nil {
243244 return err
244245 } else {
245246 for _ , volumeAttachment := range v .Attachments {
0 commit comments