Skip to content

Commit

Permalink
[obs] use the region by provider if not specified (#292)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShiChangkuo committed Apr 7, 2020
1 parent 6d6f87a commit 5c3c899
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions huaweicloud/resource_huaweicloud_obs_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ func resourceObsBucket() *schema.Resource {

func resourceObsBucketCreate(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
obsClient, err := config.newObjectStorageClient(GetRegion(d, config))
region := GetRegion(d, config)
obsClient, err := config.newObjectStorageClient(region)
if err != nil {
return fmt.Errorf("Error creating HuaweiCloud OBS client: %s", err)
}
Expand All @@ -266,7 +267,7 @@ func resourceObsBucketCreate(d *schema.ResourceData, meta interface{}) error {
ACL: obs.AclType(acl),
StorageClass: obs.StorageClassType(class),
}
opts.Location = d.Get("region").(string)
opts.Location = region
log.Printf("[DEBUG] OBS bucket create opts: %#v", opts)

_, err = obsClient.CreateBucket(opts)
Expand Down
4 changes: 2 additions & 2 deletions website/docs/r/obs_bucket.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ The following arguments are supported:

* `force_destroy` - (Optional) A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. Default to `false`.

* `region` - (Optional) If specified, the region this bucket should reside in. Otherwise, the region used by the provider.
* `region` - (Optional) Specified the region where this bucket will be created. If not specified, used the region by the provider.

The `logging` object supports the following:

Expand Down Expand Up @@ -256,7 +256,7 @@ The following attributes are exported:

* `id` - The name of the bucket.
* `bucket_domain_name` - The bucket domain name. Will be of format `bucketname.obs.region.myhuaweicloud.com`.
* `region` - The region this bucket resides in.
* `region` - The region where this bucket resides in.

## Import

Expand Down

0 comments on commit 5c3c899

Please sign in to comment.