Skip to content

Commit

Permalink
Merge pull request #160 from volcengine/feat/vke
Browse files Browse the repository at this point in the history
Feat/vke
  • Loading branch information
zpp12354321 authored Feb 27, 2024
2 parents 2742e9c + e67e1cb commit cbd3ce6
Show file tree
Hide file tree
Showing 58 changed files with 3,770 additions and 10 deletions.
2 changes: 2 additions & 0 deletions common/common_volcengine_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/volcengine/volcengine-go-sdk/service/autoscaling"
"github.com/volcengine/volcengine-go-sdk/service/clb"
"github.com/volcengine/volcengine-go-sdk/service/ecs"
"github.com/volcengine/volcengine-go-sdk/service/iam"
"github.com/volcengine/volcengine-go-sdk/service/natgateway"
"github.com/volcengine/volcengine-go-sdk/service/rdsmysql"
"github.com/volcengine/volcengine-go-sdk/service/rdsmysqlv2"
Expand All @@ -23,6 +24,7 @@ type SdkClient struct {
AutoScalingClient *autoscaling.AUTOSCALING
RdsClient *rdsmysql.RDSMYSQL
RdsClientV2 *rdsmysqlv2.RDSMYSQLV2
IamClient *iam.IAM
UniversalClient *Universal
BypassSvcClient *BypassSvc
}
2 changes: 2 additions & 0 deletions common/common_volcengine_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/volcengine/volcengine-go-sdk/service/autoscaling"
"github.com/volcengine/volcengine-go-sdk/service/clb"
"github.com/volcengine/volcengine-go-sdk/service/ecs"
"github.com/volcengine/volcengine-go-sdk/service/iam"
"github.com/volcengine/volcengine-go-sdk/service/natgateway"
"github.com/volcengine/volcengine-go-sdk/service/rdsmysql"
"github.com/volcengine/volcengine-go-sdk/service/rdsmysqlv2"
Expand Down Expand Up @@ -75,6 +76,7 @@ func (c *Config) Client() (*SdkClient, error) {
client.AutoScalingClient = autoscaling.New(sess)
client.RdsClient = rdsmysql.New(sess)
client.RdsClientV2 = rdsmysqlv2.New(sess)
client.IamClient = iam.New(sess)
client.UniversalClient = NewUniversalClient(sess, c.CustomerEndpoints)
client.BypassSvcClient = NewBypassClient(sess)

Expand Down
2 changes: 1 addition & 1 deletion common/common_volcengine_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package common

const (
TerraformProviderName = "terraform-provider-volcengine"
TerraformProviderVersion = "0.0.139"
TerraformProviderVersion = "0.0.140"
)
1 change: 1 addition & 0 deletions docgen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ var resourceKeys = map[string]string{
"cloud_monitor": "CLOUD_MONITOR",
"rds_mssql": "RDS_MSSQL",
"rds_postgresql": "RDS_POSTGRESQL",
"organization": "ORGANIZATION",
}

type Products struct {
Expand Down
2 changes: 2 additions & 0 deletions example/dataIamSamlProviders/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
data "volcengine_iam_saml_providers" "foo"{
}
5 changes: 5 additions & 0 deletions example/dataOrganizationAccounts/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
data "volcengine_organization_accounts" "foo" {
search = "210061****"
# org_unit_id = "730662904425309****"
# verification_id = "730671013833631****"
}
4 changes: 4 additions & 0 deletions example/dataOrganizationServiceControlPolicies/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
data "volcengine_organization_service_control_policies" "foo" {
policy_type = "Custom"
query = "test"
}
2 changes: 2 additions & 0 deletions example/dataOrganizationUnits/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
data "volcengine_organization_units" "foo"{
}
3 changes: 3 additions & 0 deletions example/dataOrganizations/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "volcengine_organizations" "foo" {

}
6 changes: 6 additions & 0 deletions example/iamSamlProvider/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resource "volcengine_iam_saml_provider" "foo" {
encoded_saml_metadata_document = "your document"
saml_provider_name = "terraform"
sso_type = 2
status = 1
}
3 changes: 3 additions & 0 deletions example/organization/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resource "volcengine_organization" "foo" {

}
17 changes: 17 additions & 0 deletions example/organizationAccount/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
resource "volcengine_organization_unit" "foo" {
name = "acc-test-org-unit"
parent_id = "730671013833632****"
description = "acc-test"
}

resource "volcengine_organization_account" "foo" {
account_name = "acc-test-account"
show_name = "acc-test-account"
description = "acc-test"
org_unit_id = volcengine_organization_unit.foo.id

tags {
key = "k1"
value = "v1"
}
}
10 changes: 10 additions & 0 deletions example/organizationServiceControlPolicy/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
resource "volcengine_organization_service_control_policy" "foo" {
policy_name = "tfpolicy11"
description = "tftest1"
statement = "{\"Statement\":[{\"Effect\":\"Deny\",\"Action\":[\"ecs:RunInstances\"],\"Resource\":[\"*\"]}]}"
}

resource "volcengine_organization_service_control_policy" "foo2" {
policy_name = "tfpolicy21"
statement = "{\"Statement\":[{\"Effect\":\"Deny\",\"Action\":[\"ecs:DeleteInstance\"],\"Resource\":[\"*\"]}]}"
}
17 changes: 17 additions & 0 deletions example/organizationServiceControlPolicyAttachment/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
resource "volcengine_organization_service_control_policy" "foo" {
policy_name = "tfpolicy11"
description = "tftest1"
statement = "{\"Statement\":[{\"Effect\":\"Deny\",\"Action\":[\"ecs:RunInstances\"],\"Resource\":[\"*\"]}]}"
}

resource "volcengine_organization_service_control_policy_attachment" "foo" {
policy_id = volcengine_organization_service_control_policy.foo.id
target_id = "21*********94"
target_type = "Account"
}

resource "volcengine_organization_service_control_policy_attachment" "foo1" {
policy_id = volcengine_organization_service_control_policy.foo.id
target_id = "73*********9"
target_type = "OU"
}
3 changes: 3 additions & 0 deletions example/organizationServiceControlPolicyEnabler/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resource "volcengine_organization_service_control_policy_enabler" "foo" {

}
13 changes: 13 additions & 0 deletions example/organizationUnit/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
resource "volcengine_organization" "foo" {

}

data "volcengine_organization_units" "foo" {
depends_on = [volcengine_organization.foo]
}

resource "volcengine_organization_unit" "foo" {
name = "tf-test-unit"
parent_id = [for unit in data.volcengine_organization_units.foo.units : unit.id if unit.parent_id == "0"][0]
description = "tf-test"
}
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require (
github.com/hashicorp/terraform-plugin-sdk v1.7.0
github.com/mitchellh/copystructure v1.0.0
github.com/stretchr/testify v1.7.0
github.com/volcengine/volc-sdk-golang v1.0.23
github.com/volcengine/volcengine-go-sdk v1.0.75
golang.org/x/sync v0.0.0-20190423024810-112230192c58
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package iam_saml_provider

import (
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
ve "github.com/volcengine/terraform-provider-volcengine/common"
)

func DataSourceVolcengineIamSamlProviders() *schema.Resource {
return &schema.Resource{
Read: dataSourceVolcengineIamSamlProvidersRead,
Schema: map[string]*schema.Schema{
"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.",
},
"providers": {
Description: "The collection of query.",
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"saml_provider_name": {
Type: schema.TypeString,
Computed: true,
Description: "The name of the SAML provider.",
},
"encoded_saml_metadata_document": {
Type: schema.TypeString,
Computed: true,
Description: "Metadata document, encoded in Base64.",
},
"description": {
Type: schema.TypeString,
Computed: true,
Description: "The description of the SAML provider.",
},
"sso_type": {
Type: schema.TypeInt,
Computed: true,
Description: "SSO types, 1. Role-based SSO, 2. User-based SSO.",
},
"status": {
Type: schema.TypeInt,
Computed: true,
Description: "User SSO status, 1. Enabled, 2. Disable other console login methods after enabling, " +
"3. Disabled, is a required field when creating user SSO.",
},
"trn": {
Type: schema.TypeString,
Computed: true,
Description: "The format for the resource name of an identity provider is trn:iam::${accountID}:saml-provider/{$SAMLProviderName}.",
},
"create_date": {
Type: schema.TypeString,
Computed: true,
Description: "Identity provider creation time, such as 20150123T123318Z.",
},
"update_date": {
Type: schema.TypeString,
Computed: true,
Description: "Identity provider update time, such as: 20150123T123318Z.",
},
},
},
},
},
}
}

func dataSourceVolcengineIamSamlProvidersRead(d *schema.ResourceData, meta interface{}) error {
service := NewIamSamlProviderService(meta.(*ve.SdkClient))
return service.Dispatcher.Data(service, d, DataSourceVolcengineIamSamlProviders())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
package iam_saml_provider

import (
"fmt"
"strings"
"time"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
ve "github.com/volcengine/terraform-provider-volcengine/common"
)

/*
Import
IamSamlProvider can be imported using the id, e.g.
```
$ terraform import volcengine_iam_saml_provider.default SAMLProviderName
```
*/

func ResourceVolcengineIamSamlProvider() *schema.Resource {
resource := &schema.Resource{
Create: resourceVolcengineIamSamlProviderCreate,
Read: resourceVolcengineIamSamlProviderRead,
Update: resourceVolcengineIamSamlProviderUpdate,
Delete: resourceVolcengineIamSamlProviderDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
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{
"saml_provider_name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: "The name of the SAML provider.",
},
"encoded_saml_metadata_document": {
Type: schema.TypeString,
Required: true,
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
return strings.Replace(old, "\n", "", -1) == strings.Replace(new, "\n", "", -1)
},
Description: "Metadata document, encoded in Base64.",
},
"description": {
Type: schema.TypeString,
Optional: true,
Description: "The description of the SAML provider.",
},
"sso_type": {
Type: schema.TypeInt,
Required: true,
Description: "SSO types, 1. Role-based SSO, 2. User-based SSO.",
},
"status": {
Type: schema.TypeInt,
Optional: true,
Description: "User SSO status, 1. Enabled, 2. Disable other console login methods after enabling, " +
"3. Disabled, is a required field when creating user SSO.",
},
"trn": {
Type: schema.TypeString,
Computed: true,
Description: "The format for the resource name of an identity provider is trn:iam::${accountID}:saml-provider/{$SAMLProviderName}.",
},
"create_date": {
Type: schema.TypeString,
Computed: true,
Description: "Identity provider creation time, such as 20150123T123318Z.",
},
"update_date": {
Type: schema.TypeString,
Computed: true,
Description: "Identity provider update time, such as: 20150123T123318Z.",
},
},
}
return resource
}

func resourceVolcengineIamSamlProviderCreate(d *schema.ResourceData, meta interface{}) (err error) {
service := NewIamSamlProviderService(meta.(*ve.SdkClient))
err = service.Dispatcher.Create(service, d, ResourceVolcengineIamSamlProvider())
if err != nil {
return fmt.Errorf("error on creating iam_saml_provider %q, %s", d.Id(), err)
}
return resourceVolcengineIamSamlProviderRead(d, meta)
}

func resourceVolcengineIamSamlProviderRead(d *schema.ResourceData, meta interface{}) (err error) {
service := NewIamSamlProviderService(meta.(*ve.SdkClient))
err = service.Dispatcher.Read(service, d, ResourceVolcengineIamSamlProvider())
if err != nil {
return fmt.Errorf("error on reading iam_saml_provider %q, %s", d.Id(), err)
}
return err
}

func resourceVolcengineIamSamlProviderUpdate(d *schema.ResourceData, meta interface{}) (err error) {
service := NewIamSamlProviderService(meta.(*ve.SdkClient))
err = service.Dispatcher.Update(service, d, ResourceVolcengineIamSamlProvider())
if err != nil {
return fmt.Errorf("error on updating iam_saml_provider %q, %s", d.Id(), err)
}
return resourceVolcengineIamSamlProviderRead(d, meta)
}

func resourceVolcengineIamSamlProviderDelete(d *schema.ResourceData, meta interface{}) (err error) {
service := NewIamSamlProviderService(meta.(*ve.SdkClient))
err = service.Dispatcher.Delete(service, d, ResourceVolcengineIamSamlProvider())
if err != nil {
return fmt.Errorf("error on deleting iam_saml_provider %q, %s", d.Id(), err)
}
return err
}
Loading

0 comments on commit cbd3ce6

Please sign in to comment.