-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating rules for redshift to handle lists of parameters
- Loading branch information
Keith Monihen
committed
Apr 20, 2020
1 parent
d348075
commit b255773
Showing
7 changed files
with
119 additions
and
35 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
27 changes: 0 additions & 27 deletions
27
...raform/aws/redshift/redshift_parameter_group/require_ssl/tests/terraform11/require_ssl.tf
This file was deleted.
Oops, something went wrong.
29 changes: 26 additions & 3 deletions
29
...raform/aws/redshift/redshift_parameter_group/require_ssl/tests/terraform12/require_ssl.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 |
---|---|---|
@@ -1,27 +1,50 @@ | ||
# Warn | ||
# Test that require_ssl parameter is present and set to true | ||
# https://www.terraform.io/docs/providers/aws/r/redshift_parameter_group.html | ||
|
||
# WARN require_ssl is not set | ||
resource "aws_redshift_parameter_group" "parameter_and_require_ssl_not_set" { | ||
name = "foobar" | ||
family = "redshift-1.0" | ||
} | ||
|
||
# Warn | ||
# WARN: require_ssl is false | ||
resource "aws_redshift_parameter_group" "require_ssl_set_to_false" { | ||
name = "foobar" | ||
family = "redshift-1.0" | ||
|
||
parameter { | ||
name = "enable_user_activity_logging" | ||
value = "true" | ||
} | ||
|
||
parameter { | ||
name = "require_ssl" | ||
value = "false" | ||
} | ||
|
||
parameter { | ||
name = "query_group" | ||
value = "example" | ||
} | ||
} | ||
|
||
# Pass | ||
# PASS: require_ssl is set to true | ||
resource "aws_redshift_parameter_group" "require_ssl_set_to_true" { | ||
name = "foobar" | ||
family = "redshift-1.0" | ||
|
||
parameter { | ||
name = "enable_user_activity_logging" | ||
value = "true" | ||
} | ||
|
||
parameter { | ||
name = "require_ssl" | ||
value = "true" | ||
} | ||
|
||
parameter { | ||
name = "query_group" | ||
value = "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
22 changes: 22 additions & 0 deletions
22
cli/assets/terraform/aws/redshift/redshift_parameter_group/user_logging/rule.yml
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,22 @@ | ||
--- | ||
version: 1 | ||
description: Terraform rules | ||
type: Terraform | ||
files: | ||
- "*.tf" | ||
- "*.tfvars" | ||
rules: | ||
|
||
- id: REDSHIFT_CLUSTER_PARAMETER_GROUP_USER_ACTIVITY_LOGGING | ||
message: RedshiftCluster Parameter Group should set enable_user_activity_logging to true | ||
resource: aws_redshift_parameter_group | ||
severity: FAILURE | ||
assertions: | ||
- exactly-one: | ||
key: parameter | ||
expressions: | ||
- key: name | ||
op: eq | ||
value: enable_user_activity_logging | ||
- key: value | ||
op: is-true |
55 changes: 55 additions & 0 deletions
55
...form/aws/redshift/redshift_parameter_group/user_logging/tests/terraform12/user_logging.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,55 @@ | ||
# Test that user activity logging is enabled | ||
# https://www.terraform.io/docs/providers/aws/r/redshift_parameter_group.html | ||
|
||
# FAIL: enable_user_activity_logging is not set | ||
resource "aws_redshift_parameter_group" "logging_not_set" { | ||
name = "foobar" | ||
family = "redshift-1.0" | ||
|
||
parameter { | ||
name = "require_ssl" | ||
value = "true" | ||
} | ||
} | ||
|
||
# FAIL: enable_user_activity_logging is false | ||
resource "aws_redshift_parameter_group" "logging_set_to_false" { | ||
name = "foobar" | ||
family = "redshift-1.0" | ||
|
||
parameter { | ||
name = "require_ssl" | ||
value = "false" | ||
} | ||
|
||
parameter { | ||
name = "enable_user_activity_logging" | ||
value = "false" | ||
} | ||
|
||
parameter { | ||
name = "query_group" | ||
value = "example" | ||
} | ||
} | ||
|
||
# PASS: enable_user_activity_logging is set to true | ||
resource "aws_redshift_parameter_group" "logging_set_to_true" { | ||
name = "foobar" | ||
family = "redshift-1.0" | ||
|
||
parameter { | ||
name = "require_ssl" | ||
value = "true" | ||
} | ||
|
||
parameter { | ||
name = "enable_user_activity_logging" | ||
value = "true" | ||
} | ||
|
||
parameter { | ||
name = "query_group" | ||
value = "example" | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
cli/assets/terraform/aws/redshift/redshift_parameter_group/user_logging/tests/test.yml
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,14 @@ | ||
--- | ||
version: 1 | ||
description: Terraform 12 tests | ||
type: Terraform | ||
files: | ||
- "*.tf" | ||
- "*.tfvars" | ||
tests: | ||
- | ||
ruleId: REDSHIFT_CLUSTER_PARAMETER_GROUP_USER_ACTIVITY_LOGGING | ||
warnings: 0 | ||
failures: 2 | ||
tags: | ||
- "terraform12" |