File tree Expand file tree Collapse file tree 11 files changed +329
-3
lines changed Expand file tree Collapse file tree 11 files changed +329
-3
lines changed Original file line number Diff line number Diff line change
1
+ version : 1
2
+ update_configs :
3
+ # Keep go modules up to date, batching pull requests weekly
4
+ - package_manager : " go:modules"
5
+ directory : " /"
6
+ update_schedule : " weekly"
7
+ # Apply default reviewer @trussworks/waddlers group to PRs
8
+ default_reviewers :
9
+ - " trussworks/waddlers"
10
+ # Apply dependencies label to PRs
11
+ default_labels :
12
+ - " dependencies"
Original file line number Diff line number Diff line change
1
+ .terraform
2
+ terraform.tfstate
3
+ terraform.tfstate.backup
4
+ terraform.tfstate. * .backup
Original file line number Diff line number Diff line change
1
+ linters :
2
+ enable :
3
+ - gosec
4
+ - golint
5
+ - gofmt
6
+ - goimports
Original file line number Diff line number Diff line change 1
1
repos :
2
2
- repo : git://github.com/pre-commit/pre-commit-hooks
3
- rev : v2.2.3
3
+ rev : v2.4.0
4
4
hooks :
5
5
- id : check-json
6
6
- id : check-merge-conflict
@@ -12,12 +12,19 @@ repos:
12
12
- id : trailing-whitespace
13
13
14
14
- repo : git://github.com/igorshubovych/markdownlint-cli
15
- rev : v0.17 .0
15
+ rev : v0.19 .0
16
16
hooks :
17
17
- id : markdownlint
18
18
19
19
- repo : git://github.com/antonbabenko/pre-commit-terraform
20
20
rev : v1.19.0
21
21
hooks :
22
22
- id : terraform_docs
23
- - id : terraform_fmt
23
+ - id : terraform_fmt
24
+
25
+ - repo : git://github.com/golangci/golangci-lint
26
+ rev : v1.21.0
27
+ hooks :
28
+ - id : golangci-lint
29
+ entry : golangci-lint run --verbose
30
+ verbose : true
Original file line number Diff line number Diff line change
1
+ .PHONY : ensure_pre_commit
2
+ ensure_pre_commit : .git/hooks/pre-commit # # Ensure pre-commit is installed
3
+ .git/hooks/pre-commit : /usr/local/bin/pre-commit
4
+ pre-commit install
5
+ pre-commit install-hooks
6
+
7
+ .PHONY : pre_commit_tests
8
+ pre_commit_tests : ensure_pre_commit # # Run pre-commit tests
9
+ pre-commit run --all-files
10
+
11
+ .PHONY : test
12
+ test : pre_commit_tests
13
+ go test -v -timeout 90m ./test/...
14
+
15
+ .PHONY : clean
16
+ clean :
17
+ rm -f .* .stamp
Original file line number Diff line number Diff line change @@ -13,6 +13,12 @@ The following AWS Config Rules are supported:
13
13
* rds-storage-encrypted: Checks whether storage encryption is enabled for your RDS DB instances.
14
14
* s3-bucket-public-write-prohibited: Checks that your S3 buckets do not allow public write access.
15
15
16
+ ## Terraform Versions
17
+
18
+ Terraform 0.12. Pin module version to ~ > 2.x Submit pull-requests to master branch.
19
+
20
+ Terraform 0.11. Pin module version to ~ > 1.5.1. Submit pull-requests to terraform011 branch.
21
+
16
22
## Usage
17
23
18
24
``` hcl
@@ -49,3 +55,27 @@ module "aws_config" {
49
55
| password\_ reuse\_ prevention | Number of passwords before allowing reuse. | string | ` "24" ` | no |
50
56
51
57
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
58
+
59
+ ## Developer Setup
60
+
61
+ Install dependencies (macOS)
62
+
63
+ ``` shell
64
+ brew install pre-commit go terraform terraform-docs
65
+ ```
66
+
67
+ ### Testing
68
+
69
+ [ Terratest] ( https://github.com/gruntwork-io/terratest ) is being used for
70
+ automated testing with this module. Tests in the ` test ` folder can be run
71
+ locally by running the following command:
72
+
73
+ ``` text
74
+ make test
75
+ ```
76
+
77
+ Or with aws-vault:
78
+
79
+ ``` text
80
+ AWS_VAULT_KEYCHAIN_NAME=<NAME> aws-vault exec <PROFILE> -- make test
81
+ ```
Original file line number Diff line number Diff line change
1
+ #
2
+ # AWS Config Logs Bucket
3
+ #
4
+
5
+ module "config_logs" {
6
+ source = " trussworks/logs/aws"
7
+ version = " ~> 3"
8
+
9
+ s3_bucket_name = " ${ var . config_logs_bucket } "
10
+ region = " ${ var . region } "
11
+ allow_config = " true"
12
+ config_logs_prefix = " config"
13
+ }
14
+
15
+ module "config" {
16
+ source = " ../../"
17
+
18
+ config_logs_bucket = " ${ module . config_logs . aws_logs_bucket } "
19
+ config_logs_prefix = " config"
20
+ }
Original file line number Diff line number Diff line change
1
+ variable "config_logs_bucket" {
2
+ type = " string"
3
+ }
4
+
5
+ variable "region" {
6
+ type = " string"
7
+ }
Original file line number Diff line number Diff line change
1
+ module github.com/trussworks/terraform-aws-config
2
+
3
+ go 1.13
4
+
5
+ require github.com/gruntwork-io/terratest v0.22.2
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change
1
+ package test
2
+
3
+ import (
4
+ "fmt"
5
+ "strings"
6
+ "testing"
7
+
8
+ "github.com/gruntwork-io/terratest/modules/aws"
9
+ "github.com/gruntwork-io/terratest/modules/random"
10
+ "github.com/gruntwork-io/terratest/modules/terraform"
11
+ )
12
+
13
+ func TestTerraformAwsConfig (t * testing.T ) {
14
+ t .Parallel ()
15
+
16
+ expectedConfigLogsBucket := fmt .Sprintf ("terratest-aws-config-%s" , strings .ToLower (random .UniqueId ()))
17
+ awsRegion := aws .GetRandomStableRegion (t , nil , nil )
18
+
19
+ terraformOptions := & terraform.Options {
20
+ TerraformDir : "../examples/simple/" ,
21
+ Vars : map [string ]interface {}{
22
+ "region" : awsRegion ,
23
+ "config_logs_bucket" : expectedConfigLogsBucket ,
24
+ },
25
+ EnvVars : map [string ]string {
26
+ "AWS_DEFAULT_REGION" : awsRegion ,
27
+ },
28
+ }
29
+
30
+ defer terraform .Destroy (t , terraformOptions )
31
+ terraform .InitAndApply (t , terraformOptions )
32
+
33
+ // Empty config_logs_bucket before terraform destroy
34
+ aws .EmptyS3Bucket (t , awsRegion , expectedConfigLogsBucket )
35
+ }
You can’t perform that action at this time.
0 commit comments