diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8582722..c8d53dc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: terraform_wrapper: false - uses: actions/setup-python@v3 with: - python-version: "3.10" + python-version: "3.11" - name: Install Custodian run: | pip install c7n_left diff --git a/policies/cost.yaml b/policies/cost.yaml new file mode 100644 index 0000000..06424d9 --- /dev/null +++ b/policies/cost.yaml @@ -0,0 +1,19 @@ +policies: + - name: check-ebs-volume-type + description: "use gp3 volumes for better cost and performance over gp2" + resource: terraform.aws_instance + metadata: + severity: low + categories: [cost] + filters: + - or: + - type: value + key: root_block_device.volume_type + value: gp2 + - type: value + key: ebs_block_device.volume_type + value: gp2 +# - type: list-item +# key: ebs_block_device +# attrs: +# - volume_type: gp2 diff --git a/root-module/ec2.tf b/root-module/ec2.tf new file mode 100644 index 0000000..f0f952e --- /dev/null +++ b/root-module/ec2.tf @@ -0,0 +1,32 @@ +data "aws_ami" "ubuntu" { + most_recent = true + + filter { + name = "name" + values = ["ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*"] + } + + filter { + name = "virtualization-type" + values = ["hvm"] + } + + owners = ["099720109477"] # Canonical +} + +resource "aws_instance" "web" { + ami = data.aws_ami.ubuntu.id + instance_type = "m6g.large" + + ebs_block_device { + device_name = "/dev/sdf" + volume_type = "gp2" + volume_size = "30" + } + + tags = { + Name = "HelloWorld" + Env = "Dev" + } + +}