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(GROW-2949): Provide organization_id for project level agentless integration #1648

Merged
merged 3 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
13 changes: 13 additions & 0 deletions lwgenerate/gcp/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ type GenerateGcpTfConfigurationArgs struct {

Projects []string

// GCP organization id for agentless integration. Agentless integration requires an organization id
// even for project level integration
AgentlessOrganizationId string

// Default GCP Provider labels
ProviderDefaultLabels map[string]interface{}

Expand Down Expand Up @@ -231,6 +235,13 @@ func WithUsePubSubAudit(usePubSub bool) GcpTerraformModifier {
}
}

// WithAgentlessOrganizationId Set the agentless organization id for GCP provider
func WithAgentlessOrganizationId(organizationId string) GcpTerraformModifier {
return func(c *GenerateGcpTfConfigurationArgs) {
c.AgentlessOrganizationId = organizationId
}
}

// WithGcpServiceAccountCredentials Set the path for the GCP Service Account to be utilized by the GCP provider
func WithGcpServiceAccountCredentials(path string) GcpTerraformModifier {
return func(c *GenerateGcpTfConfigurationArgs) {
Expand Down Expand Up @@ -632,6 +643,8 @@ func createAgentless(args *GenerateGcpTfConfigurationArgs) ([]*hclwrite.Block, e
if args.OrganizationIntegration {
attributes["integration_type"] = "ORGANIZATION"
attributes["organization_id"] = args.GcpOrganizationId
ipcrm marked this conversation as resolved.
Show resolved Hide resolved
} else if len(args.AgentlessOrganizationId) > 0 {
attributes["organization_id"] = args.AgentlessOrganizationId
}
}
if i > 0 {
Expand Down
12 changes: 8 additions & 4 deletions lwgenerate/gcp/gcp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,7 @@ func TestGenerateGcpTfConfigurationArgs_Generate_Agentless(t *testing.T) {
"TestGenerationProjectLevelAgentless",
gcp.NewTerraform(true, false, false, false,
gcp.WithProjectId(projectName),
gcp.WithAgentlessOrganizationId("123456789"),
gcp.WithRegions([]string{"us-east1"}),
),
fmt.Sprintf("%s\n%s", RequiredProviders, moduleImportProjectLevelAgentless),
Expand All @@ -729,6 +730,7 @@ func TestGenerateGcpTfConfigurationArgs_Generate_Agentless(t *testing.T) {
gcp.NewTerraform(true, false, false, false,
gcp.WithProjectId(projectName),
gcp.WithRegions([]string{"us-east1"}),
gcp.WithAgentlessOrganizationId("123456789"),
gcp.WithProjectFilterList([]string{"p1", "p2"}),
),
fmt.Sprintf("%s\n%s", RequiredProviders, moduleImportProjectLevelAgentlessWithProjectFilterList),
Expand Down Expand Up @@ -1181,10 +1183,11 @@ var moduleImportProjectLevelAgentless = `provider "google" {
}

module "lacework_gcp_agentless_scanning_global" {
source = "lacework/agentless-scanning/gcp"
version = "~> 2.0"
global = true
regional = true
source = "lacework/agentless-scanning/gcp"
version = "~> 2.0"
global = true
organization_id = "123456789"
regional = true

providers = {
google = google.us-east1
Expand All @@ -1202,6 +1205,7 @@ module "lacework_gcp_agentless_scanning_global" {
source = "lacework/agentless-scanning/gcp"
version = "~> 2.0"
global = true
organization_id = "123456789"
project_filter_list = ["p1", "p2"]
regional = true

Expand Down
Loading