-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new: added policy ecc-aws-548-ebs_volumes_are_of_type_gp3_instead_of_gp2
- Loading branch information
Vladyslav Yevsiukov
authored and
Vladyslav Yevsiukov
committed
Aug 9, 2023
1 parent
05cdc84
commit b876852
Showing
13 changed files
with
193 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
policies/ecc-aws-548-ebs_volumes_are_of_type_gp3_instead_of_gp2.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,16 @@ | ||
# Copyright (c) 2023 EPAM Systems, Inc. | ||
# | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
|
||
policies: | ||
- name: ecc-aws-548-ebs_volumes_are_of_type_gp3_instead_of_gp2 | ||
resource: aws.ebs | ||
description: | | ||
EBS volumes are type of gp2 insted of gp3 | ||
filters: | ||
- type: value | ||
key: VolumeType | ||
value: gp2 |
8 changes: 8 additions & 0 deletions
8
terraform/ecc-aws-548-ebs_volumes_are_of_type_gp3_instead_of_gp2/green/ebs.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,8 @@ | ||
resource "aws_ebs_volume" "this" { | ||
availability_zone = data.aws_availability_zones.this.names[0] | ||
size = 8 | ||
} | ||
|
||
data "aws_availability_zones" "this" { | ||
state = "available" | ||
} |
20 changes: 20 additions & 0 deletions
20
terraform/ecc-aws-548-ebs_volumes_are_of_type_gp3_instead_of_gp2/green/provider.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,20 @@ | ||
terraform { | ||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = "~> 4" | ||
} | ||
} | ||
} | ||
|
||
provider "aws" { | ||
profile = var.profile | ||
region = var.default-region | ||
|
||
default_tags { | ||
tags = { | ||
CustodianRule = "ecc-aws-548-ebs_volumes_are_of_type_gp3_instead_of_gp2" | ||
ComplianceStatus = "Green" | ||
} | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
terraform/ecc-aws-548-ebs_volumes_are_of_type_gp3_instead_of_gp2/green/terraform.tfvars
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,2 @@ | ||
profile = "c7n" | ||
default-region = "us-east-1" |
9 changes: 9 additions & 0 deletions
9
terraform/ecc-aws-548-ebs_volumes_are_of_type_gp3_instead_of_gp2/green/variables.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,9 @@ | ||
variable "default-region" { | ||
type = string | ||
description = "Default region for resources will be created" | ||
} | ||
|
||
variable "profile" { | ||
type = string | ||
description = "Profile name configured before running apply" | ||
} |
12 changes: 12 additions & 0 deletions
12
terraform/ecc-aws-548-ebs_volumes_are_of_type_gp3_instead_of_gp2/iam/548-policy.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,12 @@ | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Effect": "Allow", | ||
"Action": [ | ||
"ec2:DescribeVolumes" | ||
], | ||
"Resource": "*" | ||
} | ||
] | ||
} |
9 changes: 9 additions & 0 deletions
9
terraform/ecc-aws-548-ebs_volumes_are_of_type_gp3_instead_of_gp2/red/ebs.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,9 @@ | ||
resource "aws_ebs_volume" "this" { | ||
availability_zone = data.aws_availability_zones.this.names[0] | ||
size = 8 | ||
type = "gp3" | ||
} | ||
|
||
data "aws_availability_zones" "this" { | ||
state = "available" | ||
} |
20 changes: 20 additions & 0 deletions
20
terraform/ecc-aws-548-ebs_volumes_are_of_type_gp3_instead_of_gp2/red/provider.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,20 @@ | ||
terraform { | ||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = "~> 4" | ||
} | ||
} | ||
} | ||
|
||
provider "aws" { | ||
profile = var.profile | ||
region = var.default-region | ||
|
||
default_tags { | ||
tags = { | ||
CustodianRule = "ecc-aws-548-ebs_volumes_are_of_type_gp3_instead_of_gp2" | ||
ComplianceStatus = "Red" | ||
} | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
terraform/ecc-aws-548-ebs_volumes_are_of_type_gp3_instead_of_gp2/red/terraform.tfvars
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,2 @@ | ||
profile = "c7n" | ||
default-region = "us-east-1" |
9 changes: 9 additions & 0 deletions
9
terraform/ecc-aws-548-ebs_volumes_are_of_type_gp3_instead_of_gp2/red/variables.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,9 @@ | ||
variable "default-region" { | ||
type = string | ||
description = "Default region for resources will be created" | ||
} | ||
|
||
variable "profile" { | ||
type = string | ||
description = "Profile name configured before running apply" | ||
} |
40 changes: 40 additions & 0 deletions
40
...s-548-ebs_volumes_are_of_type_gp3_instead_of_gp2/placebo-green/ec2.DescribeVolumes_1.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,40 @@ | ||
{ | ||
"status_code": 200, | ||
"data": { | ||
"Volumes": [ | ||
{ | ||
"Attachments": [], | ||
"AvailabilityZone": "us-east-1a", | ||
"CreateTime": { | ||
"__class__": "datetime", | ||
"year": 2023, | ||
"month": 8, | ||
"day": 7, | ||
"hour": 10, | ||
"minute": 21, | ||
"second": 26, | ||
"microsecond": 451000 | ||
}, | ||
"Encrypted": false, | ||
"Size": 8, | ||
"SnapshotId": "", | ||
"State": "available", | ||
"VolumeId": "vol-0fb6c7480bfce553c", | ||
"Iops": 100, | ||
"Tags": [ | ||
{ | ||
"Key": "CustodianRule", | ||
"Value": "ecc-aws-548-ebs_volumes_are_of_type_gp3_instead_of_gp2" | ||
}, | ||
{ | ||
"Key": "ComplianceStatus", | ||
"Value": "Green" | ||
} | ||
], | ||
"VolumeType": "gp3", | ||
"MultiAttachEnabled": false | ||
} | ||
], | ||
"ResponseMetadata": {} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...aws-548-ebs_volumes_are_of_type_gp3_instead_of_gp2/placebo-red/ec2.DescribeVolumes_1.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,41 @@ | ||
{ | ||
"status_code": 200, | ||
"data": { | ||
"Volumes": [ | ||
{ | ||
"Attachments": [], | ||
"AvailabilityZone": "us-east-1a", | ||
"CreateTime": { | ||
"__class__": "datetime", | ||
"year": 2023, | ||
"month": 8, | ||
"day": 7, | ||
"hour": 10, | ||
"minute": 20, | ||
"second": 53, | ||
"microsecond": 24000 | ||
}, | ||
"Encrypted": false, | ||
"Size": 8, | ||
"SnapshotId": "", | ||
"State": "available", | ||
"VolumeId": "vol-02e08791159817fa1", | ||
"Iops": 3000, | ||
"Tags": [ | ||
{ | ||
"Key": "CustodianRule", | ||
"Value": "ecc-aws-548-ebs_volumes_are_of_type_gp3_instead_of_gp2" | ||
}, | ||
{ | ||
"Key": "ComplianceStatus", | ||
"Value": "Red" | ||
} | ||
], | ||
"VolumeType": "gp2", | ||
"MultiAttachEnabled": false, | ||
"Throughput": 125 | ||
} | ||
], | ||
"ResponseMetadata": {} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
tests/ecc-aws-548-ebs_volumes_are_of_type_gp3_instead_of_gp2/red_policy_test.py
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 @@ | ||
class PolicyTest(object): | ||
|
||
def test_resources(self, base_test, resources): | ||
base_test.assertEqual(len(resources), 1) | ||
base_test.assertEqual(resources[0]['VolumeType'], "gp2") |