-
Notifications
You must be signed in to change notification settings - Fork 41
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
32c96f6
commit d614b3c
Showing
6 changed files
with
142 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module "aws_logs" { | ||
source = "../../" | ||
|
||
s3_bucket_name = var.test_name | ||
guardduty_logs_prefixes = var.guardduty_logs_prefixes | ||
region = var.region | ||
allow_guardduty = true | ||
default_allow = false | ||
|
||
force_destroy = var.force_destroy | ||
} |
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,15 @@ | ||
variable "test_name" { | ||
type = string | ||
} | ||
|
||
variable "region" { | ||
type = string | ||
} | ||
|
||
variable "force_destroy" { | ||
type = bool | ||
} | ||
|
||
variable "guardduty_logs_prefixes" { | ||
type = list(string) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package test | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/gruntwork-io/terratest/modules/aws" | ||
"github.com/gruntwork-io/terratest/modules/random" | ||
"github.com/gruntwork-io/terratest/modules/terraform" | ||
test_structure "github.com/gruntwork-io/terratest/modules/test-structure" | ||
) | ||
|
||
func TestTerraformAwsLogsGuardDuty(t *testing.T) { | ||
t.Parallel() | ||
|
||
tempTestFolder := test_structure.CopyTerraformFolderToTemp(t, "../", "examples/guardduty") | ||
testName := fmt.Sprintf("terratest-aws-logs-%s", strings.ToLower(random.UniqueId())) | ||
awsRegion := "us-west-2" | ||
|
||
terraformOptions := &terraform.Options{ | ||
TerraformDir: tempTestFolder, | ||
Vars: map[string]interface{}{ | ||
"region": awsRegion, | ||
"test_name": testName, | ||
"force_destroy": true, | ||
"guardduty_logs_prefixes": []string{testName}, | ||
}, | ||
EnvVars: map[string]string{ | ||
"AWS_DEFAULT_REGION": awsRegion, | ||
}, | ||
} | ||
|
||
defer terraform.Destroy(t, terraformOptions) | ||
terraform.InitAndApply(t, terraformOptions) | ||
} |
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