-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add inline and proxy scanner resources (#434)
***Issue***: https://lacework.atlassian.net/jira/software/projects/ALLY/issues/ALLY-1037 ***Description:*** Added inline scanner and proxy scanner resources. ***Additional Info:*** Releated to go-sdk pull request lacework/go-sdk#1018 Signed-off-by: Salim Afiune Maya <afiune@lacework.net> Co-authored-by: credibleforce <jamiefrasermcmurray@gmail.com>
- Loading branch information
1 parent
2cf4309
commit d7e0074
Showing
19 changed files
with
845 additions
and
14 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
examples/resource_lacework_integration_inline_scanner/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,25 @@ | ||
terraform { | ||
required_providers { | ||
lacework = { | ||
source = "lacework/lacework" | ||
} | ||
} | ||
} | ||
|
||
provider "lacework" { | ||
profile = "snifftest-composite" | ||
} | ||
|
||
resource "lacework_integration_inline_scanner" "example" { | ||
name = var.name | ||
|
||
limit_num_scan = 60 | ||
identifier_tag { | ||
key = "foo" | ||
value = "bar" | ||
} | ||
} | ||
|
||
output "server_token" { | ||
value = lacework_integration_inline_scanner.example.server_token | ||
} |
4 changes: 4 additions & 0 deletions
4
examples/resource_lacework_integration_inline_scanner/variables.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,4 @@ | ||
variable "name" { | ||
type = string | ||
default = "Inline Scanner Container Registry Example" | ||
} |
28 changes: 28 additions & 0 deletions
28
examples/resource_lacework_integration_proxy_scanner/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,28 @@ | ||
terraform { | ||
required_providers { | ||
lacework = { | ||
source = "lacework/lacework" | ||
} | ||
} | ||
} | ||
|
||
provider "lacework" { | ||
profile = "snifftest-composite" | ||
} | ||
|
||
resource "lacework_integration_proxy_scanner" "example" { | ||
name = var.name | ||
|
||
limit_num_imgs = 10 | ||
limit_by_tags = ["dev*", "*test"] | ||
limit_by_repositories = ["repo/my-image", "repo/other-image"] | ||
|
||
limit_by_label { | ||
key = "foo" | ||
value = "bar" | ||
} | ||
} | ||
|
||
output "server_token" { | ||
value = lacework_integration_proxy_scanner.example.server_token | ||
} |
4 changes: 4 additions & 0 deletions
4
examples/resource_lacework_integration_proxy_scanner/variables.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,4 @@ | ||
variable "name" { | ||
type = string | ||
default = "Proxy Scanner Container Registry Example" | ||
} |
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
47 changes: 47 additions & 0 deletions
47
integration/resource_lacework_integration_inline_scanner_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,47 @@ | ||
package integration | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
"time" | ||
|
||
"github.com/gruntwork-io/terratest/modules/terraform" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
// TestIntegrationInlineScannerCreate applies integration terraform: | ||
// => '../examples/resource_lacework_integration_inline_scanner' | ||
// | ||
// It uses the go-sdk to verify the created integration, | ||
// applies an update with new integration name and destroys it | ||
func TestIntegrationInlineScannerCreate(t *testing.T) { | ||
integrationName := fmt.Sprintf("Inline Scanner Container Registry - %s", time.Now()) | ||
|
||
terraformOptions := terraform.WithDefaultRetryableErrors(t, &terraform.Options{ | ||
TerraformDir: "../examples/resource_lacework_integration_inline_scanner", | ||
EnvVars: tokenEnvVar, | ||
Vars: map[string]interface{}{ | ||
"name": integrationName, | ||
}, | ||
}) | ||
defer terraform.Destroy(t, terraformOptions) | ||
|
||
// Create new Inline Scanner Container Registry | ||
create := terraform.InitAndApplyAndIdempotent(t, terraformOptions) | ||
createData := GetContainerRegisteryInlineScanner(create) | ||
assert.Equal(t, integrationName, createData.Data.Name) | ||
assert.Equal(t, []map[string]string{{"foo": "bar"}}, createData.Data.Data.IdentifierTag) | ||
assert.Equal(t, "60", createData.Data.Data.LimitNumScan) | ||
|
||
// Update Inline Scanner Container Registry | ||
terraformOptions.Vars["name"] = "Inline Scanner Container Registry Updated" | ||
|
||
update := terraform.ApplyAndIdempotent(t, terraformOptions) | ||
updateData := GetContainerRegisteryInlineScanner(update) | ||
assert.Equal(t, "Inline Scanner Container Registry Updated", updateData.Data.Name) | ||
assert.Equal(t, []map[string]string{{"foo": "bar"}}, createData.Data.Data.IdentifierTag) | ||
assert.Equal(t, "60", createData.Data.Data.LimitNumScan) | ||
|
||
server_token := terraform.Output(t, terraformOptions, "server_token") | ||
assert.NotEmpty(t, server_token) | ||
} |
53 changes: 53 additions & 0 deletions
53
integration/resource_lacework_integration_proxy_scanner_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,53 @@ | ||
package integration | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
"time" | ||
|
||
"github.com/gruntwork-io/terratest/modules/terraform" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
// TestIntegrationProxyScannerCreate applies integration terraform: | ||
// => '../examples/resource_lacework_integration_inline_scanner' | ||
// | ||
// It uses the go-sdk to verify the created integration, | ||
// applies an update with new integration name and destroys it | ||
func TestIntegrationProxyScannerCreate(t *testing.T) { | ||
integrationName := fmt.Sprintf("Proxy Scanner Container Registry - %s", time.Now()) | ||
|
||
terraformOptions := terraform.WithDefaultRetryableErrors(t, &terraform.Options{ | ||
TerraformDir: "../examples/resource_lacework_integration_proxy_scanner", | ||
EnvVars: tokenEnvVar, | ||
Vars: map[string]interface{}{ | ||
"name": integrationName, | ||
}, | ||
}) | ||
defer terraform.Destroy(t, terraformOptions) | ||
|
||
// Create new Proxy Scanner Container Registry | ||
create := terraform.InitAndApplyAndIdempotent(t, terraformOptions) | ||
createData := GetContainerRegisteryProxyScanner(create) | ||
assert.Equal(t, integrationName, createData.Data.Name) | ||
assert.Equal(t, 10, createData.Data.Data.LimitNumImg) | ||
assert.Equal(t, []map[string]string{{"foo": "bar"}}, createData.Data.Data.LimitByLabel) | ||
assert.Equal(t, []string{"dev*", "*test"}, createData.Data.Data.LimitByTag) | ||
assert.Equal(t, []string{"repo/my-image", "repo/other-image"}, createData.Data.Data.LimitByRep) | ||
|
||
// Update Proxy Scanner Container Registry | ||
terraformOptions.Vars["name"] = "Proxy Scanner Container Registry Updated" | ||
|
||
update := terraform.ApplyAndIdempotent(t, terraformOptions) | ||
updateData := GetContainerRegisteryProxyScanner(update) | ||
assert.Equal(t, "Proxy Scanner Container Registry Updated", updateData.Data.Name) | ||
assert.Equal(t, 10, createData.Data.Data.LimitNumImg) | ||
assert.Equal(t, []map[string]string{{"foo": "bar"}}, createData.Data.Data.LimitByLabel) | ||
assert.Equal(t, []string{"dev*", "*test"}, createData.Data.Data.LimitByTag) | ||
assert.Equal(t, []string{"repo/my-image", "repo/other-image"}, createData.Data.Data.LimitByRep) | ||
assert.NotEmpty(t, createData.Data.ServerToken.ServerToken) | ||
assert.NotEmpty(t, createData.Data.ServerToken.Uri) | ||
|
||
server_token := terraform.Output(t, terraformOptions, "server_token") | ||
assert.NotEmpty(t, server_token) | ||
} |
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.