-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enha: added option to create flow log for the VPC
- Loading branch information
1 parent
f26e283
commit b920df8
Showing
4 changed files
with
215 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
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,100 @@ | ||
provider "aws" { | ||
region = "eu-central-1" | ||
default_tags { | ||
tags = { | ||
Environment = "Test" | ||
} | ||
} | ||
} | ||
|
||
run "invalid_name_prefix" { | ||
command = plan | ||
|
||
variables { | ||
flow_log = { | ||
name_prefix = "a" | ||
traffic_type = "ALL" | ||
retention_in_days = 1 | ||
} | ||
} | ||
|
||
expect_failures = [var.flow_log] | ||
} | ||
|
||
run "invalid_traffic_type" { | ||
command = plan | ||
|
||
variables { | ||
flow_log = { | ||
name_prefix = "abc" | ||
traffic_type = "FOO" | ||
retention_in_days = 1 | ||
} | ||
} | ||
|
||
expect_failures = [var.flow_log] | ||
} | ||
|
||
run "invalid_retention_in_days" { | ||
command = plan | ||
|
||
variables { | ||
flow_log = { | ||
name_prefix = "abc" | ||
traffic_type = "ALL" | ||
retention_in_days = 2 | ||
} | ||
} | ||
|
||
expect_failures = [var.flow_log] | ||
} | ||
|
||
run "valid_flow_log" { | ||
command = plan | ||
|
||
variables { | ||
flow_log = { | ||
name_prefix = "abc" | ||
traffic_type = "ALL" | ||
retention_in_days = 1 | ||
} | ||
} | ||
|
||
assert { | ||
condition = length(aws_flow_log.main) == 1 | ||
error_message = "Flow log was not created" | ||
} | ||
|
||
assert { | ||
condition = length(aws_iam_role.main) == 1 | ||
error_message = "IAM role for flow log was not created" | ||
} | ||
|
||
assert { | ||
condition = length(aws_cloudwatch_log_group.main) == 1 | ||
error_message = "CloudWatch log group for flow log was not created" | ||
} | ||
} | ||
|
||
run "no_flow_log" { | ||
command = plan | ||
|
||
variables { | ||
flow_log = null | ||
} | ||
|
||
assert { | ||
condition = length(aws_flow_log.main) == 0 | ||
error_message = "Flow log was created unexpectedly" | ||
} | ||
|
||
assert { | ||
condition = length(aws_iam_role.main) == 0 | ||
error_message = "IAM role for flow log was created unexpectedly" | ||
} | ||
|
||
assert { | ||
condition = length(aws_cloudwatch_log_group.main) == 0 | ||
error_message = "CloudWatch log group for flow log was created unexpectedly" | ||
} | ||
} |
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