-
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 #160 from volcengine/feat/vke
Feat/vke
- Loading branch information
Showing
58 changed files
with
3,770 additions
and
10 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
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,2 @@ | ||
data "volcengine_iam_saml_providers" "foo"{ | ||
} |
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 @@ | ||
data "volcengine_organization_accounts" "foo" { | ||
search = "210061****" | ||
# org_unit_id = "730662904425309****" | ||
# verification_id = "730671013833631****" | ||
} |
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_organization_service_control_policies" "foo" { | ||
policy_type = "Custom" | ||
query = "test" | ||
} |
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_organization_units" "foo"{ | ||
} |
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_organizations" "foo" { | ||
|
||
} |
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,6 @@ | ||
resource "volcengine_iam_saml_provider" "foo" { | ||
encoded_saml_metadata_document = "your document" | ||
saml_provider_name = "terraform" | ||
sso_type = 2 | ||
status = 1 | ||
} |
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 @@ | ||
resource "volcengine_organization" "foo" { | ||
|
||
} |
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,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" | ||
} | ||
} |
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,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
17
example/organizationServiceControlPolicyAttachment/main.tf
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,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" | ||
} |
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 @@ | ||
resource "volcengine_organization_service_control_policy_enabler" "foo" { | ||
|
||
} |
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,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" | ||
} |
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
79 changes: 79 additions & 0 deletions
79
volcengine/iam/iam_saml_provider/data_source_volcengine_iam_saml_providers.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,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()) | ||
} |
121 changes: 121 additions & 0 deletions
121
volcengine/iam/iam_saml_provider/resource_volcengine_iam_saml_provider.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,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 | ||
} |
Oops, something went wrong.