-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #119 from volcengine/feat/cfs
Feat/cfs
- Loading branch information
Showing
34 changed files
with
2,652 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
resource "volcengine_cloudfs_access" "foo1" { | ||
fs_name = "tftest2" | ||
|
||
subnet_id = "subnet-13fca1crr5d6o3n6nu46cyb5m" | ||
security_group_id = "sg-rrv1klfg5s00v0x578mx14m" | ||
vpc_route_enabled = false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
resource "volcengine_cloudfs_file_system" "foo" { | ||
fs_name = "tffile" | ||
zone_id = "cn-beijing-b" | ||
cache_plan = "T2" | ||
mode = "HDFS_MODE" | ||
read_only = true | ||
|
||
subnet_id = "subnet-13fca1crr5d6o3n6nu46cyb5m" | ||
security_group_id = "sg-rrv1klfg5s00v0x578mx14m" | ||
cache_capacity_tib = 10 | ||
vpc_route_enabled = true | ||
|
||
tos_bucket = "tfacc" | ||
tos_prefix = "pre/" | ||
} | ||
|
||
|
||
resource "volcengine_cloudfs_file_system" "foo1" { | ||
fs_name = "tffileu" | ||
zone_id = "cn-beijing-b" | ||
cache_plan = "T2" | ||
mode = "ACC_MODE" | ||
read_only = true | ||
|
||
subnet_id = "subnet-13fca1crr5d6o3n6nu46cyb5m" | ||
security_group_id = "sg-rrv1klfg5s00v0x578mx14m" | ||
cache_capacity_tib = 15 | ||
vpc_route_enabled = false | ||
|
||
tos_bucket = "tfacc" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
resource "volcengine_cloudfs_namespace" "foo" { | ||
fs_name = "tf-test-fs" | ||
tos_bucket = "tf-test" | ||
read_only = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
data "volcengine_cloudfs_accesses" "default" { | ||
fs_name = "tftest2" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
data "volcengine_cloudfs_file_systems" "default" { | ||
fs_name = "tftest2" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
data "volcengine_cloudfs_namespaces" "default" { | ||
fs_name = "tf-test-fs" | ||
ns_id = "1801439850948****" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
data "volcengine_cloudfs_ns_quotas" "default" { | ||
fs_names = ["tffile", "tftest2"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
data "volcengine_cloudfs_quotas" "default" { | ||
} |
98 changes: 98 additions & 0 deletions
98
volcengine/cloudfs/cloudfs_access/data_source_volcengine_cloudfs_accesses.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package cloudfs_access | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" | ||
ve "github.com/volcengine/terraform-provider-volcengine/common" | ||
) | ||
|
||
func DataSourceVolcengineCloudfsAccesses() *schema.Resource { | ||
return &schema.Resource{ | ||
Read: dataSourceVolcengineCloudfsAccessesRead, | ||
Schema: map[string]*schema.Schema{ | ||
"fs_name": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: "The name of file system.", | ||
}, | ||
"output_file": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Description: "File name where to save data source results.", | ||
}, | ||
"total_count": { | ||
Type: schema.TypeInt, | ||
Computed: true, | ||
Description: "The total count of query.", | ||
}, | ||
"accesses": { | ||
Description: "The collection of query.", | ||
Type: schema.TypeList, | ||
Computed: true, | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"fs_name": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The name of cloud fs.", | ||
}, | ||
"access_id": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The id of access.", | ||
}, | ||
"access_account_id": { | ||
Type: schema.TypeInt, | ||
Computed: true, | ||
Description: "The account id of access.", | ||
}, | ||
"access_service_name": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The service name of access.", | ||
}, | ||
"vpc_id": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The id of vpc.", | ||
}, | ||
"subnet_id": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The id of subnet.", | ||
}, | ||
"security_group_id": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The id of security group.", | ||
}, | ||
"is_default": { | ||
Type: schema.TypeBool, | ||
Computed: true, | ||
Description: "Whether is default access.", | ||
}, | ||
"created_time": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The creation time.", | ||
}, | ||
"status": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The status of access.", | ||
}, | ||
"vpc_route_enabled": { | ||
Type: schema.TypeBool, | ||
Computed: true, | ||
Description: "Whether to enable all vpc route.", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func dataSourceVolcengineCloudfsAccessesRead(d *schema.ResourceData, meta interface{}) error { | ||
service := NewService(meta.(*ve.SdkClient)) | ||
return ve.DefaultDispatcher().Data(service, d, DataSourceVolcengineCloudfsAccesses()) | ||
} |
157 changes: 157 additions & 0 deletions
157
volcengine/cloudfs/cloudfs_access/resource_volcengine_cloudfs_access.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
package cloudfs_access | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
"time" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" | ||
ve "github.com/volcengine/terraform-provider-volcengine/common" | ||
) | ||
|
||
/* | ||
Import | ||
CloudFs Access can be imported using the FsName:AccessId, e.g. | ||
``` | ||
$ terraform import volcengine_cloudfs_file_system.default tfname:access-**rdgmedx3fow | ||
``` | ||
*/ | ||
|
||
func ResourceVolcengineCloudfsAccess() *schema.Resource { | ||
resource := &schema.Resource{ | ||
Create: resourceVolcengineCloudfsAccessCreate, | ||
Read: resourceVolcengineCloudfsAccessRead, | ||
Update: resourceVolcengineCloudfsAccessUpdate, | ||
Delete: resourceVolcengineCloudfsAccessDelete, | ||
Importer: &schema.ResourceImporter{ | ||
State: func(data *schema.ResourceData, i interface{}) ([]*schema.ResourceData, error) { | ||
items := strings.Split(data.Id(), ":") | ||
if len(items) != 2 { | ||
return []*schema.ResourceData{data}, fmt.Errorf("import id must split with ':'") | ||
} | ||
if err := data.Set("fs_name", items[0]); err != nil { | ||
return []*schema.ResourceData{data}, err | ||
} | ||
if err := data.Set("access_id", items[1]); err != nil { | ||
return []*schema.ResourceData{data}, err | ||
} | ||
return []*schema.ResourceData{data}, nil | ||
}, | ||
}, | ||
Timeouts: &schema.ResourceTimeout{ | ||
Create: schema.DefaultTimeout(30 * time.Minute), | ||
Update: schema.DefaultTimeout(30 * time.Minute), | ||
Delete: schema.DefaultTimeout(30 * time.Minute), | ||
}, | ||
Schema: map[string]*schema.Schema{ | ||
"fs_name": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
ForceNew: true, | ||
Description: "The name of file system.", | ||
}, | ||
"access_account_id": { | ||
Type: schema.TypeInt, | ||
Optional: true, | ||
Computed: true, | ||
ForceNew: true, | ||
Description: "The account id of access.", | ||
}, | ||
"access_iam_role": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
ForceNew: true, | ||
Description: "The iam role of access. If the VPC of another account is attached, " + | ||
"the other account needs to create a role with CFSCacheAccess permission, " + | ||
"and enter the role name as a parameter.", | ||
}, | ||
"subnet_id": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
ForceNew: true, | ||
Description: "The id of subnet.", | ||
}, | ||
"security_group_id": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
ForceNew: true, | ||
Description: "The id of security group.", | ||
}, | ||
"vpc_route_enabled": { | ||
Type: schema.TypeBool, | ||
Optional: true, | ||
Description: "Whether enable all vpc route.", | ||
}, | ||
|
||
"status": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "Status of access.", | ||
}, | ||
"created_time": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The creation time.", | ||
}, | ||
"is_default": { | ||
Type: schema.TypeBool, | ||
Computed: true, | ||
Description: "Whether is default access.", | ||
}, | ||
"access_service_name": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The service name of access.", | ||
}, | ||
"vpc_id": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The id of vpc.", | ||
}, | ||
"access_id": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The id of access.", | ||
}, | ||
}, | ||
} | ||
return resource | ||
} | ||
|
||
func resourceVolcengineCloudfsAccessCreate(d *schema.ResourceData, meta interface{}) (err error) { | ||
service := NewService(meta.(*ve.SdkClient)) | ||
err = ve.DefaultDispatcher().Create(service, d, ResourceVolcengineCloudfsAccess()) | ||
if err != nil { | ||
return fmt.Errorf("error on creating access %q, %s", d.Id(), err) | ||
} | ||
return resourceVolcengineCloudfsAccessRead(d, meta) | ||
} | ||
|
||
func resourceVolcengineCloudfsAccessRead(d *schema.ResourceData, meta interface{}) (err error) { | ||
service := NewService(meta.(*ve.SdkClient)) | ||
err = ve.DefaultDispatcher().Read(service, d, ResourceVolcengineCloudfsAccess()) | ||
if err != nil { | ||
return fmt.Errorf("error on reading access %q, %s", d.Id(), err) | ||
} | ||
return err | ||
} | ||
|
||
func resourceVolcengineCloudfsAccessUpdate(d *schema.ResourceData, meta interface{}) (err error) { | ||
service := NewService(meta.(*ve.SdkClient)) | ||
err = ve.DefaultDispatcher().Update(service, d, ResourceVolcengineCloudfsAccess()) | ||
if err != nil { | ||
return fmt.Errorf("error on updating access %q, %s", d.Id(), err) | ||
} | ||
return resourceVolcengineCloudfsAccessRead(d, meta) | ||
} | ||
|
||
func resourceVolcengineCloudfsAccessDelete(d *schema.ResourceData, meta interface{}) (err error) { | ||
service := NewService(meta.(*ve.SdkClient)) | ||
err = ve.DefaultDispatcher().Delete(service, d, ResourceVolcengineCloudfsAccess()) | ||
if err != nil { | ||
return fmt.Errorf("error on deleting access %q, %s", d.Id(), err) | ||
} | ||
return err | ||
} |
Oops, something went wrong.