-
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.
terraform_plan: Add
references_to
& referenced_by
to direct_refer…
…ences
- Loading branch information
Showing
13 changed files
with
559 additions
and
2 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 |
---|---|---|
|
@@ -131,4 +131,5 @@ dmypy.json | |
.pyre/ | ||
|
||
.DS_Store | ||
.local | ||
.local | ||
.test_tmp |
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
...references/fixtures/at_least_one_aws_s3_bucket_int_config_refers_to_s3_bucket.tirith.json
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 @@ | ||
{ | ||
"meta": { | ||
"required_provider": "stackguardian/terraform_plan", | ||
"version": "v1" | ||
}, | ||
"evaluators": [ | ||
{ | ||
"id": "s3HasLifeCycleIntelligentTiering", | ||
"description": "Make sure IntelligentTieringConfig references to S3 bucket", | ||
"provider_args": { | ||
"operation_type": "direct_references", | ||
"terraform_resource_type": "aws_s3_bucket_intelligent_tiering_configuration" | ||
}, | ||
"condition": { | ||
"type": "Contains", | ||
"value": "aws_s3_bucket", | ||
"error_tolerance": 0 | ||
} | ||
} | ||
], | ||
"eval_expression": "s3HasLifeCycleIntelligentTiering" | ||
} |
23 changes: 23 additions & 0 deletions
23
...providers/terraform_plan/direct_references/fixtures/elb_references_to_secroup.tirith.json
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,23 @@ | ||
{ | ||
"meta": { | ||
"required_provider": "stackguardian/terraform_plan", | ||
"version": "v1" | ||
}, | ||
"evaluators": [ | ||
{ | ||
"id": "elbRefsToSecGroup", | ||
"description": "Make sure ELBs references to security groups", | ||
"provider_args": { | ||
"operation_type": "direct_references", | ||
"terraform_resource_type": "aws_elb", | ||
"references_to": "aws_security_group" | ||
}, | ||
"condition": { | ||
"type": "Equals", | ||
"value": true, | ||
"error_tolerance": 0 | ||
} | ||
} | ||
], | ||
"eval_expression": "elbRefsToSecGroup" | ||
} |
38 changes: 38 additions & 0 deletions
38
tests/providers/terraform_plan/direct_references/fixtures/elb_with_secgroup.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,38 @@ | ||
provider "aws" { | ||
region = "us-west-2" # Change this to your desired AWS region | ||
} | ||
|
||
resource "aws_security_group" "elb_sg" { | ||
name = "elb-sg" | ||
description = "Security Group for ELB" | ||
|
||
ingress { | ||
from_port = 80 | ||
to_port = 80 | ||
protocol = "tcp" | ||
cidr_blocks = ["0.0.0.0/0"] # Allow all incoming HTTP traffic. Modify as needed. | ||
} | ||
|
||
egress { | ||
from_port = 0 | ||
to_port = 0 | ||
protocol = "-1" | ||
cidr_blocks = ["0.0.0.0/0"] # Allow all outgoing traffic. Modify as needed. | ||
} | ||
} | ||
|
||
resource "aws_elb" "example" { | ||
name = "example-elb" | ||
availability_zones = ["us-west-2a", "us-west-2b"] # Change these based on your region and requirements | ||
|
||
listener { | ||
instance_port = 80 | ||
instance_protocol = "http" | ||
lb_port = 80 | ||
lb_protocol = "http" | ||
} | ||
|
||
security_groups = [aws_security_group.elb_sg.id] | ||
|
||
# Optionally add health checks, instances, etc. | ||
} |
54 changes: 54 additions & 0 deletions
54
tests/providers/terraform_plan/direct_references/fixtures/extra_elb_no_secgroup.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,54 @@ | ||
provider "aws" { | ||
region = "us-west-2" # Change this to your desired AWS region | ||
} | ||
|
||
resource "aws_security_group" "elb_sg" { | ||
name = "elb-sg" | ||
description = "Security Group for ELB" | ||
|
||
ingress { | ||
from_port = 80 | ||
to_port = 80 | ||
protocol = "tcp" | ||
cidr_blocks = ["0.0.0.0/0"] # Allow all incoming HTTP traffic. Modify as needed. | ||
} | ||
|
||
egress { | ||
from_port = 0 | ||
to_port = 0 | ||
protocol = "-1" | ||
cidr_blocks = ["0.0.0.0/0"] # Allow all outgoing traffic. Modify as needed. | ||
} | ||
} | ||
|
||
resource "aws_elb" "example" { | ||
name = "example-elb" | ||
availability_zones = ["us-west-2a", "us-west-2b"] # Change these based on your region and requirements | ||
|
||
listener { | ||
instance_port = 80 | ||
instance_protocol = "http" | ||
lb_port = 80 | ||
lb_protocol = "http" | ||
} | ||
|
||
security_groups = [aws_security_group.elb_sg.id] | ||
|
||
# Optionally add health checks, instances, etc. | ||
} | ||
|
||
resource "aws_elb" "something" { | ||
name = "something-elb" | ||
availability_zones = ["us-west-2a", "us-west-2b"] # Change these based on your region and requirements | ||
|
||
listener { | ||
instance_port = 80 | ||
instance_protocol = "http" | ||
lb_port = 80 | ||
lb_protocol = "http" | ||
} | ||
|
||
security_groups = [] | ||
|
||
# Optionally add health checks, instances, etc. | ||
} |
24 changes: 24 additions & 0 deletions
24
.../providers/terraform_plan/direct_references/fixtures/fail_s3_referenced_by_to.tirith.json
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,24 @@ | ||
{ | ||
"meta": { | ||
"required_provider": "stackguardian/terraform_plan", | ||
"version": "v1" | ||
}, | ||
"evaluators": [ | ||
{ | ||
"id": "s3HasLifeCycleIntelligentTiering", | ||
"description": "Make sure all aws_s3_bucket are referenced by aws_s3_bucket_intelligent_tiering_configuration", | ||
"provider_args": { | ||
"operation_type": "direct_references", | ||
"terraform_resource_type": "aws_s3_bucket", | ||
"referenced_by": "aws_s3_bucket_intelligent_tiering_configuration", | ||
"references_to": "aws_s3_bucket" | ||
}, | ||
"condition": { | ||
"type": "Equals", | ||
"value": true, | ||
"error_tolerance": 0 | ||
} | ||
} | ||
], | ||
"eval_expression": "s3HasLifeCycleIntelligentTiering" | ||
} |
25 changes: 25 additions & 0 deletions
25
...rs/terraform_plan/direct_references/fixtures/s3_bucket_not_all_has_intelligent_tiering.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,25 @@ | ||
provider "aws" { | ||
region = "us-west-1" # Adjust the region as needed. | ||
} | ||
|
||
resource "aws_s3_bucket_intelligent_tiering_configuration" "example-entire-bucket" { | ||
bucket = aws_s3_bucket.example.id | ||
name = "EntireBucket" | ||
|
||
tiering { | ||
access_tier = "DEEP_ARCHIVE_ACCESS" | ||
days = 180 | ||
} | ||
tiering { | ||
access_tier = "ARCHIVE_ACCESS" | ||
days = 125 | ||
} | ||
} | ||
|
||
resource "aws_s3_bucket" "example" { | ||
bucket = "example" | ||
} | ||
|
||
resource "aws_s3_bucket" "bb" { | ||
bucket = "bb" | ||
} |
21 changes: 21 additions & 0 deletions
21
...rs/terraform_plan/direct_references/fixtures/s3_bucket_with_intelligent_tiering_config.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,21 @@ | ||
provider "aws" { | ||
region = "us-west-1" # Adjust the region as needed. | ||
} | ||
|
||
resource "aws_s3_bucket_intelligent_tiering_configuration" "example-entire-bucket" { | ||
bucket = aws_s3_bucket.example.id | ||
name = "EntireBucket" | ||
|
||
tiering { | ||
access_tier = "DEEP_ARCHIVE_ACCESS" | ||
days = 180 | ||
} | ||
tiering { | ||
access_tier = "ARCHIVE_ACCESS" | ||
days = 125 | ||
} | ||
} | ||
|
||
resource "aws_s3_bucket" "example" { | ||
bucket = "example" | ||
} |
23 changes: 23 additions & 0 deletions
23
...m_plan/direct_references/fixtures/s3_referenced_by_intelligent_tiering_config.tirith.json
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,23 @@ | ||
{ | ||
"meta": { | ||
"required_provider": "stackguardian/terraform_plan", | ||
"version": "v1" | ||
}, | ||
"evaluators": [ | ||
{ | ||
"id": "s3HasLifeCycleIntelligentTiering", | ||
"description": "Make sure all aws_s3_bucket are referenced by aws_s3_bucket_intelligent_tiering_configuration", | ||
"provider_args": { | ||
"operation_type": "direct_references", | ||
"terraform_resource_type": "aws_s3_bucket", | ||
"referenced_by": "aws_s3_bucket_intelligent_tiering_configuration" | ||
}, | ||
"condition": { | ||
"type": "Equals", | ||
"value": true, | ||
"error_tolerance": 0 | ||
} | ||
} | ||
], | ||
"eval_expression": "s3HasLifeCycleIntelligentTiering" | ||
} |
Oops, something went wrong.