diff --git a/docs/data-sources/enterprise_project.md b/docs/data-sources/enterprise_project.md index 0f34dd9f9e..7163a36dae 100644 --- a/docs/data-sources/enterprise_project.md +++ b/docs/data-sources/enterprise_project.md @@ -25,7 +25,7 @@ EVS | huaweicloud_evs_volume | CCE | huaweicloud_cce_cluster | huaweicloud_cce_node
huaweicloud_cce_node_pool
huaweicloud_cce_addon RDS | huaweicloud_rds_instance
huaweicloud_rds_read_replica_instance | OBS | huaweicloud_obs_bucket | huaweicloud_obs_bucket_object
huaweicloud_obs_bucket_policy -SFS | huaweicloud_sfs_file_system | huaweicloud_sfs_access_rule +SFS | huaweicloud_sfs_file_system
huaweicloud_sfs_turbo | huaweicloud_sfs_access_rule KMS | huaweicloud_kms_key | DCS | huaweicloud_dcs_instance | NAT | huaweicloud_nat_gateway | huaweicloud_nat_snat_rule
huaweicloud_nat_dnat_rule diff --git a/docs/resources/sfs_turbo.md b/docs/resources/sfs_turbo.md index d76e315260..64cca3c2b4 100644 --- a/docs/resources/sfs_turbo.md +++ b/docs/resources/sfs_turbo.md @@ -57,6 +57,9 @@ The following arguments are supported: * `crypt_key_id` - (Optional, String, ForceNew) Specifies the ID of a KMS key to encrypt the file system. Changing this will create a new resource. +* `enterprise_project_id` - (Optional, String, ForceNew) The enterprise project id of the file system. + Changing this will create a new resource. + -> **NOTE:** SFS Turbo will create two private IP addresses and one virtual IP address under the subnet you specified. To ensure normal use, SFS Turbo will enable the inbound rules for ports *111*, *445*, *2049*, *2051*, *2052*, diff --git a/huaweicloud/resource_huaweicloud_sfs_turbo.go b/huaweicloud/resource_huaweicloud_sfs_turbo.go index c710983f97..28eded8789 100644 --- a/huaweicloud/resource_huaweicloud_sfs_turbo.go +++ b/huaweicloud/resource_huaweicloud_sfs_turbo.go @@ -89,7 +89,12 @@ func ResourceSFSTurbo() *schema.Resource { Computed: true, ForceNew: true, }, - + "enterprise_project_id": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Computed: true, + }, "status": { Type: schema.TypeString, Computed: true, @@ -118,14 +123,15 @@ func resourceSFSTurboCreate(d *schema.ResourceData, meta interface{}) error { } createOpts := shares.CreateOpts{ - Name: d.Get("name").(string), - Size: d.Get("size").(int), - ShareProto: d.Get("share_proto").(string), - ShareType: d.Get("share_type").(string), - VpcID: d.Get("vpc_id").(string), - SubnetID: d.Get("subnet_id").(string), - SecurityGroupID: d.Get("security_group_id").(string), - AvailabilityZone: d.Get("availability_zone").(string), + Name: d.Get("name").(string), + Size: d.Get("size").(int), + ShareProto: d.Get("share_proto").(string), + ShareType: d.Get("share_type").(string), + VpcID: d.Get("vpc_id").(string), + SubnetID: d.Get("subnet_id").(string), + SecurityGroupID: d.Get("security_group_id").(string), + AvailabilityZone: d.Get("availability_zone").(string), + EnterpriseProjectId: GetEnterpriseProjectID(d, config), } metaOpts := shares.Metadata{} @@ -184,6 +190,7 @@ func resourceSFSTurboRead(d *schema.ResourceData, meta interface{}) error { d.Set("available_capacity", n.AvailCapacity) d.Set("export_location", n.ExportLocation) d.Set("crypt_key_id", n.CryptKeyID) + d.Set("enterprise_project_id", n.EnterpriseProjectId) // n.Size is a string of float64, should convert it to int if fsize, err := strconv.ParseFloat(n.Size, 64); err == nil { diff --git a/huaweicloud/resource_huaweicloud_sfs_turbo_test.go b/huaweicloud/resource_huaweicloud_sfs_turbo_test.go index 6ee155aabf..e7d3a082b4 100644 --- a/huaweicloud/resource_huaweicloud_sfs_turbo_test.go +++ b/huaweicloud/resource_huaweicloud_sfs_turbo_test.go @@ -78,6 +78,29 @@ func TestAccSFSTurbo_crypt(t *testing.T) { }) } +func TestAccSFSTurbo_withEpsId(t *testing.T) { + randSuffix := acctest.RandString(5) + turboName := fmt.Sprintf("sfs-turbo-acc-%s", randSuffix) + resourceName := "huaweicloud_sfs_turbo.sfs-turbo1" + var turbo shares.Turbo + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheckEpsID(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckSFSTurboDestroy, + Steps: []resource.TestStep{ + { + Config: testAccSFSTurbo_withEpsId(randSuffix), + Check: resource.ComposeTestCheckFunc( + testAccCheckSFSTurboExists(resourceName, &turbo), + resource.TestCheckResourceAttr(resourceName, "name", turboName), + resource.TestCheckResourceAttr(resourceName, "enterprise_project_id", HW_ENTERPRISE_PROJECT_ID_TEST), + ), + }, + }, + }) +} + func testAccCheckSFSTurboDestroy(s *terraform.State) error { config := testAccProvider.Meta().(*Config) sfsClient, err := config.SfsV1Client(HW_REGION_NAME) @@ -207,3 +230,21 @@ resource "huaweicloud_sfs_turbo" "sfs-turbo1" { } `, testAccNetworkPreConditions(suffix), suffix, suffix) } + +func testAccSFSTurbo_withEpsId(suffix string) string { + return fmt.Sprintf(` +%s +data "huaweicloud_availability_zones" "myaz" {} + +resource "huaweicloud_sfs_turbo" "sfs-turbo1" { + name = "sfs-turbo-acc-%s" + size = 500 + share_proto = "NFS" + vpc_id = huaweicloud_vpc_v1.test.id + subnet_id = huaweicloud_vpc_subnet_v1.test.id + security_group_id = huaweicloud_networking_secgroup_v2.secgroup.id + availability_zone = data.huaweicloud_availability_zones.myaz.names[0] + enterprise_project_id = "%s" +} +`, testAccNetworkPreConditions(suffix), suffix, HW_ENTERPRISE_PROJECT_ID_TEST) +}