Skip to content

Commit

Permalink
Merge pull request #229 from fengyikai/feature/iam/trunk
Browse files Browse the repository at this point in the history
v.17.0 iam integrated
  • Loading branch information
notone0010 authored Oct 8, 2024
2 parents a8ede80 + 01f9de5 commit b850c13
Show file tree
Hide file tree
Showing 30 changed files with 2,314 additions and 0 deletions.
35 changes: 35 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## 1.17.0(Oct 08, 2024)

FEATURES:

- - **New Resource:** `ksyun_iam_user` IAM用户管理
- - **New Resource:** `ksyun_iam_role` IAM角色管理
- - **New Resource:** `ksyun_iam_group` IAM用户组管理
- - **New Resource:** `ksyun_iam_policy` IAM策略管理
- - **New Data Source:** `ksyun_iam_users` IAM用户列表
- - **New Data Source:** `ksyun_iam_roles` IAM角色列表
- - **New Data Source:** `ksyun_iam_groups` IAM角色列表

## 1.16.3 (Aug 22, 2024)

BUGFIX:
Expand Down Expand Up @@ -776,3 +788,26 @@ DATA SOURCES:

* redis read
* redis security group read

### IAM

DATA SOURCES:

* iam users read
* iam roles read
* iam groups read

RESOURCES:

* iam user create
* iam user read
* iam user delete
* iam role create
* iam role read
* iam role delete
* iam group create
* iam group read
* iam group delete
* iam policy create
* iam policy read
* iam policy delete
85 changes: 85 additions & 0 deletions ksyun/data_source_ksyun_iam_groups.go
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())
}
30 changes: 30 additions & 0 deletions ksyun/data_source_ksyun_iam_groups_test.go
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" {
}
`
90 changes: 90 additions & 0 deletions ksyun/data_source_ksyun_iam_roles.go
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())
}
30 changes: 30 additions & 0 deletions ksyun/data_source_ksyun_iam_roles_test.go
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" {
}
`
Loading

0 comments on commit b850c13

Please sign in to comment.