-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from trussworks/mk-012-tests
Terratest Plumbing
- Loading branch information
Showing
11 changed files
with
329 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
version: 1 | ||
update_configs: | ||
# Keep go modules up to date, batching pull requests weekly | ||
- package_manager: "go:modules" | ||
directory: "/" | ||
update_schedule: "weekly" | ||
# Apply default reviewer @trussworks/waddlers group to PRs | ||
default_reviewers: | ||
- "trussworks/waddlers" | ||
# Apply dependencies label to PRs | ||
default_labels: | ||
- "dependencies" |
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 @@ | ||
.terraform | ||
terraform.tfstate | ||
terraform.tfstate.backup | ||
terraform.tfstate.*.backup |
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,6 @@ | ||
linters: | ||
enable: | ||
- gosec | ||
- golint | ||
- gofmt | ||
- goimports |
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,17 @@ | ||
.PHONY: ensure_pre_commit | ||
ensure_pre_commit: .git/hooks/pre-commit ## Ensure pre-commit is installed | ||
.git/hooks/pre-commit: /usr/local/bin/pre-commit | ||
pre-commit install | ||
pre-commit install-hooks | ||
|
||
.PHONY: pre_commit_tests | ||
pre_commit_tests: ensure_pre_commit ## Run pre-commit tests | ||
pre-commit run --all-files | ||
|
||
.PHONY: test | ||
test: pre_commit_tests | ||
go test -v -timeout 90m ./test/... | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -f .*.stamp |
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,20 @@ | ||
# | ||
# AWS Config Logs Bucket | ||
# | ||
|
||
module "config_logs" { | ||
source = "trussworks/logs/aws" | ||
version = "~> 3" | ||
|
||
s3_bucket_name = "${var.config_logs_bucket}" | ||
region = "${var.region}" | ||
allow_config = "true" | ||
config_logs_prefix = "config" | ||
} | ||
|
||
module "config" { | ||
source = "../../" | ||
|
||
config_logs_bucket = "${module.config_logs.aws_logs_bucket}" | ||
config_logs_prefix = "config" | ||
} |
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,7 @@ | ||
variable "config_logs_bucket" { | ||
type = "string" | ||
} | ||
|
||
variable "region" { | ||
type = "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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module github.com/trussworks/terraform-aws-config | ||
|
||
go 1.13 | ||
|
||
require github.com/gruntwork-io/terratest v0.22.2 |
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,35 @@ | ||
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" | ||
) | ||
|
||
func TestTerraformAwsConfig(t *testing.T) { | ||
t.Parallel() | ||
|
||
expectedConfigLogsBucket := fmt.Sprintf("terratest-aws-config-%s", strings.ToLower(random.UniqueId())) | ||
awsRegion := aws.GetRandomStableRegion(t, nil, nil) | ||
|
||
terraformOptions := &terraform.Options{ | ||
TerraformDir: "../examples/simple/", | ||
Vars: map[string]interface{}{ | ||
"region": awsRegion, | ||
"config_logs_bucket": expectedConfigLogsBucket, | ||
}, | ||
EnvVars: map[string]string{ | ||
"AWS_DEFAULT_REGION": awsRegion, | ||
}, | ||
} | ||
|
||
defer terraform.Destroy(t, terraformOptions) | ||
terraform.InitAndApply(t, terraformOptions) | ||
|
||
// Empty config_logs_bucket before terraform destroy | ||
aws.EmptyS3Bucket(t, awsRegion, expectedConfigLogsBucket) | ||
} |