forked from KscSDK/terraform-provider-kingsoftcloud
-
Notifications
You must be signed in to change notification settings - Fork 15
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 #229 from fengyikai/feature/iam/trunk
v.17.0 iam integrated
- Loading branch information
Showing
30 changed files
with
2,314 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
This data source provides a list of group resources. | ||
# Example Usage | ||
```hcl | ||
data "ksyun_iam_groups" "groups" { | ||
} | ||
``` | ||
*/ | ||
package ksyun | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" | ||
) | ||
|
||
func dataSourceKsyunIamGroups() *schema.Resource { | ||
return &schema.Resource{ | ||
Read: dataSourceKsyunIamGroupsRead, | ||
|
||
Schema: map[string]*schema.Schema{ | ||
|
||
"output_file": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Description: "File name where to save data source results (after running `terraform plan`).", | ||
}, | ||
"groups": { | ||
Type: schema.TypeList, | ||
Computed: true, | ||
Description: "a list of users.", | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"group_id": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The ID of the IAM GroupId.", | ||
}, | ||
"path": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "IAM Group Path.", | ||
}, | ||
"group_name": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "IAM GroupName.", | ||
}, | ||
"description": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "IAM Group Description.", | ||
}, | ||
"create_date": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "IAN Group CreateDate.", | ||
}, | ||
"krn": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "IAN Group Krn.", | ||
}, | ||
"user_count": { | ||
Type: schema.TypeInt, | ||
Computed: true, | ||
Description: "IAN Group UserCount.", | ||
}, | ||
"policy_count": { | ||
Type: schema.TypeInt, | ||
Computed: true, | ||
Description: "IAN Group PolicyCount.", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
} | ||
func dataSourceKsyunIamGroupsRead(d *schema.ResourceData, meta interface{}) error { | ||
iamGroupService := IamGroupService{meta.(*KsyunClient)} | ||
return iamGroupService.ReadAndSetIamGroups(d, dataSourceKsyunIamGroups()) | ||
} |
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,30 @@ | ||
package ksyun | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource" | ||
) | ||
|
||
func TestAccKsyunIAMGroupsDataSource_basic(t *testing.T) { | ||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { | ||
testAccPreCheck(t) | ||
}, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccDataIAMGroupConfig, | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckIDExists("data.ksyun_iam_groups.groups"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
const testAccDataIAMGroupConfig = ` | ||
data "ksyun_iam_groups" "groups" { | ||
} | ||
` |
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,90 @@ | ||
/* | ||
This data source provides a list of role resources. | ||
# Example Usage | ||
```hcl | ||
data "ksyun_iam_roles" "roles" { | ||
} | ||
``` | ||
*/ | ||
package ksyun | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" | ||
) | ||
|
||
func dataSourceKsyunIamRoles() *schema.Resource { | ||
return &schema.Resource{ | ||
Read: dataSourceKsyunIamRolesRead, | ||
|
||
Schema: map[string]*schema.Schema{ | ||
|
||
"output_file": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Description: "File name where to save data source results (after running `terraform plan`).", | ||
}, | ||
"roles": { | ||
Type: schema.TypeList, | ||
Computed: true, | ||
Description: "a list of users.", | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"role_id": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The ID of the IAM RoleId.", | ||
}, | ||
"role_name": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "IAM RoleName.", | ||
}, | ||
"krn": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "IAM Role Krn.", | ||
}, | ||
"description": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "IAM Role Description.", | ||
}, | ||
"trust_type": { | ||
Type: schema.TypeInt, | ||
Computed: true, | ||
Description: "IAN Role TrustType.", | ||
}, | ||
"trust_accounts": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "IAN Role TrustAccounts.", | ||
}, | ||
"trust_provider": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "IAN Role TrustProvider.", | ||
}, | ||
"service_role_type": { | ||
Type: schema.TypeInt, | ||
Computed: true, | ||
Description: "IAN Role ServiceRoleType.", | ||
}, | ||
"create_date": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "IAN Role CreateDate.", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
} | ||
func dataSourceKsyunIamRolesRead(d *schema.ResourceData, meta interface{}) error { | ||
iamRoleService := IamRoleService{meta.(*KsyunClient)} | ||
return iamRoleService.ReadAndSetIamRoles(d, dataSourceKsyunIamRoles()) | ||
} |
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,30 @@ | ||
package ksyun | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource" | ||
) | ||
|
||
func TestAccKsyunIAMRolesDataSource_basic(t *testing.T) { | ||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { | ||
testAccPreCheck(t) | ||
}, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccDataIAMRoleConfig, | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckIDExists("data.ksyun_iam_roles.roles"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
const testAccDataIAMRoleConfig = ` | ||
data "ksyun_iam_roles" "roles" { | ||
} | ||
` |
Oops, something went wrong.