Skip to content

Commit

Permalink
add create cluster grouping feature (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
trend-lucas-wu authored Aug 7, 2024
1 parent bd8e309 commit b6dfd0a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/resources/container_cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ resource "visionone_container_cluster" "example_cluster" {
description = "This is a sample cluster"
resource_id = "arn:aws:eks:xxx:xxx:cluster/xxx"
policy_id = "LogOnlyPolicy-xxx"
group_id = "00000000-0000-0000-0000-000000000000"
runtime_security_enabled = true
vulnerability_scan_enabled = true
namespaces = ["kube-system"]
Expand Down Expand Up @@ -98,6 +99,7 @@ resource "helm_release" "trendmicro" {

### Required

- `group_id` (String) The ID of the group associated with the cluster. To get the group ID, go to Container Security > Container Inventory on the Trend Vision One console.
- `name` (String) The name of the cluster.

### Optional
Expand Down
1 change: 1 addition & 0 deletions examples/resources/visionone_container_cluster/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ resource "visionone_container_cluster" "example_cluster" {
description = "This is a sample cluster"
resource_id = "arn:aws:eks:xxx:xxx:cluster/xxx"
policy_id = "LogOnlyPolicy-xxx"
group_id = "00000000-0000-0000-0000-000000000000"
runtime_security_enabled = true
vulnerability_scan_enabled = true
namespaces = ["kube-system"]
Expand Down
10 changes: 9 additions & 1 deletion internal/trendmicro/container_security/resources/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ func (r *clusterResource) Schema(_ context.Context, _ resource.SchemaRequest, re
MarkdownDescription: "Last time of the cluster was evaluated against the policy rules.",
Computed: true,
},
"group_id": schema.StringAttribute{
MarkdownDescription: "The ID of the group associated with the cluster. To get the group ID, go to Container Security > Container Inventory on the Trend Vision One console.",
Required: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
},
"namespaces": schema.SetAttribute{
ElementType: types.StringType,
MarkdownDescription: "The namespaces of kubernetes you want to exclude from scanning. \nAccepted values: `calico-system`, `istio-system`, `kube-system`, `openshift*` Default value: `kube-system`",
Expand Down Expand Up @@ -214,7 +221,8 @@ func (r *clusterResource) Create(ctx context.Context, req resource.CreateRequest
tflog.Debug(ctx, fmt.Sprintf("Create new Cluster plan: %+v", plan))

data := dto.CreateClusterRequest{
Name: plan.Name.ValueString(),
Name: plan.Name.ValueString(),
GroupId: plan.GroupId.ValueString(),
}
if !plan.Description.IsNull() {
data.Description = plan.Description.ValueString()
Expand Down
1 change: 1 addition & 0 deletions pkg/dto/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ type CreateClusterRequest struct {
Description string `json:"description"`
PolicyId string `json:"policyId"`
ResourceId string `json:"resourceId"`
GroupId string `json:"groupId"`
}

type CreateRulesetRequest struct {
Expand Down
2 changes: 2 additions & 0 deletions pkg/dto/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package dto

import (
"errors"

"github.com/hashicorp/terraform-plugin-framework/types"
)

Expand All @@ -25,6 +26,7 @@ type ClusterResourceModel struct {
CreatedDateTime types.String `tfsdk:"created_date_time"`
UpdatedDateTime types.String `tfsdk:"updated_date_time"`
LastEvaluatedDateTime types.String `tfsdk:"last_evaluated_date_time"`
GroupId types.String `tfsdk:"group_id"`
Namespaces types.Set `tfsdk:"namespaces"`
RuntimeSecurityEnabled types.Bool `tfsdk:"runtime_security_enabled"`
VulnerabilityScanEnabled types.Bool `tfsdk:"vulnerability_scan_enabled"`
Expand Down

0 comments on commit b6dfd0a

Please sign in to comment.