Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Remove RGv1 logic. Add KUBERNETES to ResourceGroups #1666

Merged
merged 17 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 9 additions & 40 deletions api/_examples/resource-groups/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@ func main() {
for _, account := range res.Data {
var resourceGuid string
resourceType := account.Type

if account.Props != nil {
resourceGuid = account.ResourceGuid
} else {
resourceGuid = account.ResourceGroupGuid
}
resourceGuid = account.ResourceGroupGuid

support := "Unsupported"
switch resourceType {
Expand All @@ -42,13 +37,15 @@ func main() {
support = "Supported"
case api.GcpResourceGroup.String():
support = "Supported"
case api.LwAccountResourceGroup.String():
support = "Supported"
case api.MachineResourceGroup.String():
support = "Supported"
case api.OciResourceGroup.String():
support = "Supported"
case api.KubernetesResourceGroup.String():
support = "Supported"
}

// Output: RESOURCE_GUID:RESOURCE_TYPE:[Supported|Unsupported]
// Output: RESOURCE_GROUP_GUID:RESOURCE_TYPE:[Supported|Unsupported]
fmt.Printf("%s:%s:%s\n", resourceGuid, resourceType, support)
}

Expand All @@ -74,7 +71,7 @@ func main() {
},
}

myResourceGroupWithQuery := api.NewResourceGroupWithQuery(
myResourceGroupWithQuery := api.NewResourceGroup(
"resource-group-with-query-from-golang",
api.AwsResourceGroup,
"Resource groups in `us` regions",
Expand All @@ -91,9 +88,9 @@ func main() {
fmt.Printf("Succesfully created resource group \n %+v\n", rgV2Resp)

println("Updating v2 resource group name")
rgV2Resp.Data.NameV2 = "resource-group-with-query-from-golang-updated"
rgV2Resp.Data.Name = "resource-group-with-query-from-golang-updated"

updatedResponse, err := lacework.V2.ResourceGroups.UpdateAws(&rgV2Resp.Data)
updatedResponse, err := lacework.V2.ResourceGroups.Update(&rgV2Resp.Data)

if err != nil {
log.Fatal(err)
Expand All @@ -106,32 +103,4 @@ func main() {
log.Fatal(err)
}
println("Successfully deleted resource group")

props := api.LwAccountResourceGroupProps{
Description: "All Lacework accounts",
LwAccounts: []string{"tech-ally"},
}

myResourceGroup := api.NewResourceGroup(
"resource-group-from-golang",
api.LwAccountResourceGroup,
props,
)

// LW_ACCOUNT resource groups are only allowed at Organization level,
// copy the client to make it an org client
orgLwClient, err := api.CopyClient(lacework,
api.WithOrgAccess(),
)
if err != nil {
log.Fatal(err)
}

response, err := orgLwClient.V2.ResourceGroups.Create(myResourceGroup)
if err != nil {
log.Fatal(err)
}

// Output: Resource Group created: RESOURCE_GUID
fmt.Printf("Resource Group created: %s", response.Data.ResourceGuid)
}
49 changes: 49 additions & 0 deletions api/_templates/resource_groups/kubernetes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"filters": {
"filter1": {
"field": "AWS Account",
"operation": "EQUALS",
"values": [
"123456789012"
]
},
"filter2": {
"field": "AWS Region",
"operation": "EQUALS",
"values": [
"us-west-2"
]
},
"filter3": {
"field": "Cluster Name",
"operation": "EQUALS",
"values": [
"*"
]
},
"filter4": {
"field": "Namespace",
"operation": "EQUALS",
"values": [
"prod"
]
}
},
"expression": {
"operator": "OR",
"children": [
{
"filterName": "filter1"
},
{
"filterName": "filter2"
},
{
"filterName": "filter3"
},
{
"filterName": "filter4"
}
]
}
}
2 changes: 0 additions & 2 deletions api/feature_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"fmt"
)

const ApiV2CliFeatureFlag = "PUBLIC.rgv2.cli"

type FeatureFlagsService struct {
client *Client
}
Expand Down
Loading
Loading