Skip to content
This repository was archived by the owner on Mar 1, 2023. It is now read-only.

Commit f2fba93

Browse files
committed
add storage s3 bucket resource
1 parent 288e792 commit f2fba93

24 files changed

+528
-175
lines changed

docs/data-sources/gcore_storage_s3.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ provider gcore {
1919
permanent_api_token="123$321" // https://support.gcorelabs.com/hc/en-us/articles/360018625617-API-tokens
2020
ignore_creds_auth_error=true // if you want to manage storage resource only and provide permanent_api_token without user_name & password
2121
gcore_platform = "https://api.gcdn.co"
22-
gcore_storage_api = "https://storage.gcorelabs.com/api"
22+
gcore_storage_api = "https://api.gcorelabs.com/storage"
2323
}
2424
2525
data "gcore_storage_s3" "example_s3" {
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "gcore_storage_s3_bucket Data Source - terraform-provider-gcorelabs"
4+
subcategory: ""
5+
description: |-
6+
Represent storage s3 bucket resource.
7+
---
8+
9+
# gcore_storage_s3_bucket (Data Source)
10+
11+
Represent storage s3 bucket resource.
12+
13+
## Example Usage
14+
15+
```terraform
16+
provider gcore {
17+
user_name = "test"
18+
password = "test"
19+
permanent_api_token = "123$321" // https://support.gcorelabs.com/hc/en-us/articles/360018625617-API-tokens
20+
ignore_creds_auth_error = true
21+
// if you want to manage storage resource only and provide permanent_api_token without user_name & password
22+
gcore_platform = "https://api.gcdn.co"
23+
gcore_storage_api = "https://api.gcorelabs.com/storage"
24+
}
25+
26+
data "gcore_storage_s3_bucket" "example_s3_bucket" {
27+
storage_id = 1
28+
name = "example1bucket2name"
29+
}
30+
```
31+
32+
<!-- schema generated by tfplugindocs -->
33+
## Schema
34+
35+
### Required
36+
37+
- **name** (String) A name of storage bucket resource.
38+
- **storage_id** (Number) An id of existing storage resource.
39+
40+
### Optional
41+
42+
- **id** (String) The ID of this resource.
43+
44+

docs/resources/gcore_storage_s3.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ provider gcore {
1919
permanent_api_token="123$321" // https://support.gcorelabs.com/hc/en-us/articles/360018625617-API-tokens
2020
ignore_creds_auth_error=true // if you want to manage storage resource only and provide permanent_api_token without user_name & password
2121
gcore_platform = "https://api.gcdn.co"
22-
gcore_storage_api = "https://storage.gcorelabs.com/api"
22+
gcore_storage_api = "https://api.gcorelabs.com/storage"
2323
}
2424
2525
resource "gcore_storage_s3" "example_s3" {
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "gcore_storage_s3_bucket Resource - terraform-provider-gcorelabs"
4+
subcategory: ""
5+
description: |-
6+
Represent s3 storage bucket resource. https://storage.gcorelabs.com/storage/list
7+
---
8+
9+
# gcore_storage_s3_bucket (Resource)
10+
11+
Represent s3 storage bucket resource. https://storage.gcorelabs.com/storage/list
12+
13+
## Example Usage
14+
15+
```terraform
16+
provider gcore {
17+
user_name = "test"
18+
password = "test"
19+
permanent_api_token="123$321" // https://support.gcorelabs.com/hc/en-us/articles/360018625617-API-tokens
20+
ignore_creds_auth_error=true // if you want to manage storage resource only and provide permanent_api_token without user_name & password
21+
gcore_platform = "https://api.gcdn.co"
22+
gcore_storage_api = "https://api.gcorelabs.com/storage"
23+
}
24+
25+
resource "gcore_storage_s3_bucket" "example_s3_bucket" {
26+
name = "example1bucket2name"
27+
storage_id = 1
28+
}
29+
```
30+
31+
<!-- schema generated by tfplugindocs -->
32+
## Schema
33+
34+
### Required
35+
36+
- **name** (String) A name of new storage bucket resource.
37+
- **storage_id** (Number) An id of existing storage resource.
38+
39+
### Optional
40+
41+
- **id** (String) The ID of this resource.
42+
43+

examples/data-sources/gcore_storage_s3/data-source.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ provider gcore {
44
permanent_api_token="123$321" // https://support.gcorelabs.com/hc/en-us/articles/360018625617-API-tokens
55
ignore_creds_auth_error=true // if you want to manage storage resource only and provide permanent_api_token without user_name & password
66
gcore_platform = "https://api.gcdn.co"
7-
gcore_storage_api = "https://storage.gcorelabs.com/api"
7+
gcore_storage_api = "https://api.gcorelabs.com/storage"
88
}
99

1010
data "gcore_storage_s3" "example_s3" {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
provider gcore {
2+
user_name = "test"
3+
password = "test"
4+
permanent_api_token = "123$321" // https://support.gcorelabs.com/hc/en-us/articles/360018625617-API-tokens
5+
ignore_creds_auth_error = true
6+
// if you want to manage storage resource only and provide permanent_api_token without user_name & password
7+
gcore_platform = "https://api.gcdn.co"
8+
gcore_storage_api = "https://api.gcorelabs.com/storage"
9+
}
10+
11+
data "gcore_storage_s3_bucket" "example_s3_bucket" {
12+
storage_id = 1
13+
name = "example1bucket2name"
14+
}

examples/resources/gcore_storage_s3/resource.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ provider gcore {
44
permanent_api_token="123$321" // https://support.gcorelabs.com/hc/en-us/articles/360018625617-API-tokens
55
ignore_creds_auth_error=true // if you want to manage storage resource only and provide permanent_api_token without user_name & password
66
gcore_platform = "https://api.gcdn.co"
7-
gcore_storage_api = "https://storage.gcorelabs.com/api"
7+
gcore_storage_api = "https://api.gcorelabs.com/storage"
88
}
99

1010
resource "gcore_storage_s3" "example_s3" {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
provider gcore {
2+
user_name = "test"
3+
password = "test"
4+
permanent_api_token="123$321" // https://support.gcorelabs.com/hc/en-us/articles/360018625617-API-tokens
5+
ignore_creds_auth_error=true // if you want to manage storage resource only and provide permanent_api_token without user_name & password
6+
gcore_platform = "https://api.gcdn.co"
7+
gcore_storage_api = "https://api.gcorelabs.com/storage"
8+
}
9+
10+
resource "gcore_storage_s3_bucket" "example_s3_bucket" {
11+
name = "example1bucket2name"
12+
storage_id = 1
13+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package gcore
2+
3+
import (
4+
"regexp"
5+
6+
"github.com/hashicorp/go-cty/cty"
7+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
8+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
9+
)
10+
11+
func dataSourceStorageS3Bucket() *schema.Resource {
12+
return &schema.Resource{
13+
Schema: map[string]*schema.Schema{
14+
StorageS3BucketSchemaStorageID: {
15+
Type: schema.TypeInt,
16+
Required: true,
17+
Description: "An id of existing storage resource.",
18+
},
19+
StorageS3BucketSchemaName: {
20+
Type: schema.TypeString,
21+
Required: true,
22+
ValidateDiagFunc: func(i interface{}, path cty.Path) diag.Diagnostics {
23+
storageName := i.(string)
24+
if !regexp.MustCompile(`^[\w\-]+$`).MatchString(storageName) ||
25+
len(storageName) > 63 ||
26+
len(storageName) < 3 {
27+
return diag.Errorf("bucket name can't be empty and can have only letters & numbers. it also should be less than 63 symbols")
28+
}
29+
return nil
30+
},
31+
Description: "A name of storage bucket resource.",
32+
},
33+
},
34+
ReadContext: resourceStorageS3BucketRead,
35+
Description: "Represent storage s3 bucket resource.",
36+
}
37+
}

gcore/data_source_gcore_storage_s3_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"testing"
1010
"time"
1111

12-
"github.com/G-Core/gcorelabs-storage-sdk-go/swagger/client/storage"
12+
"github.com/G-Core/gcore-storage-sdk-go/swagger/client/storage"
1313
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
1414
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
1515
)

0 commit comments

Comments
 (0)