-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
51cf3dc
commit 0172a3d
Showing
9 changed files
with
396 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
192 changes: 192 additions & 0 deletions
192
tencentcloud/services/tke/resource_tc_kubernetes_cluster_audit.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
tencentcloud/services/tke/resource_tc_kubernetes_cluster_audit.md
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,32 @@ | ||
Provides a resource to create a kubernetes cluster audit | ||
|
||
Example Usage | ||
|
||
Automatic creation of log sets and topics | ||
|
||
```hcl | ||
resource "tencentcloud_kubernetes_cluster_audit" "example" { | ||
cluster_id = "cls-fdy7hm1q" | ||
delete_logset_and_topic = true | ||
} | ||
``` | ||
|
||
Manually fill in log sets and topics | ||
|
||
```hcl | ||
resource "tencentcloud_kubernetes_cluster_audit" "example" { | ||
cluster_id = "cls-fdy7hm1q" | ||
logset_id = "30d32c56-e650-4175-9c70-5280cddee48c" | ||
topic_id = "cfc056ca-517f-46fd-be68-9c5cad518b2f" | ||
topic_region = "ap-guangzhou" | ||
delete_logset_and_topic = false | ||
} | ||
``` | ||
|
||
Import | ||
|
||
kubernetes cluster audit can be imported using the id, e.g. | ||
|
||
``` | ||
terraform import tencentcloud_kubernetes_cluster_audit.example cls-fdy7hm1q | ||
``` |
39 changes: 39 additions & 0 deletions
39
tencentcloud/services/tke/resource_tc_kubernetes_cluster_audit_extension.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,39 @@ | ||
package tke | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"log" | ||
|
||
tkev20180525 "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525" | ||
tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common" | ||
) | ||
|
||
func resourceTencentCloudKubernetesClusterAuditReadPreHandleResponse0(ctx context.Context, resp *tkev20180525.DescribeLogSwitchesResponseParams) error { | ||
logId := tccommon.GetLogId(ctx) | ||
d := tccommon.ResourceDataFromContext(ctx) | ||
if d == nil { | ||
return fmt.Errorf("resource data can not be nil") | ||
} | ||
|
||
if resp.SwitchSet == nil { | ||
d.SetId("") | ||
log.Printf("[WARN]%s resource `kubernetes_cluster_audit` [%s] not found, please check if it has been deleted.\n", logId, d.Id()) | ||
return nil | ||
} | ||
|
||
auditInfo := resp.SwitchSet[0].Audit | ||
if auditInfo.LogsetId != nil { | ||
_ = d.Set("logset_id", auditInfo.LogsetId) | ||
} | ||
|
||
if auditInfo.TopicId != nil { | ||
_ = d.Set("topic_id", auditInfo.TopicId) | ||
} | ||
|
||
if auditInfo.TopicRegion != nil { | ||
_ = d.Set("topic_region", auditInfo.TopicRegion) | ||
} | ||
|
||
return nil | ||
} |
41 changes: 41 additions & 0 deletions
41
tencentcloud/services/tke/resource_tc_kubernetes_cluster_audit_test.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,41 @@ | ||
package tke_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
|
||
tcacctest "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/acctest" | ||
) | ||
|
||
func TestAccTencentCloudKubernetesClusterAuditResource_basic(t *testing.T) { | ||
t.Parallel() | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { | ||
tcacctest.AccPreCheck(t) | ||
}, | ||
Providers: tcacctest.AccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccKubernetesClusterAudit, | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet("tencentcloud_kubernetes_cluster_audit.example", "id"), | ||
resource.TestCheckResourceAttrSet("tencentcloud_kubernetes_cluster_audit.example", "cluster_id"), | ||
resource.TestCheckResourceAttrSet("tencentcloud_kubernetes_cluster_audit.example", "delete_logset_and_topic"), | ||
), | ||
}, | ||
{ | ||
ResourceName: "tencentcloud_kubernetes_cluster_audit.example", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
const testAccKubernetesClusterAudit = ` | ||
resource "tencentcloud_kubernetes_cluster_audit" "example" { | ||
cluster_id = "cls-fdy7hm1q" | ||
delete_logset_and_topic = true | ||
} | ||
` |
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
Oops, something went wrong.