Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new: add policy ecc-aws-872-autoscaling_launch_template_hop_limit #115

Open
wants to merge 1 commit into
base: testing_policies
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions iam/All-permissions_2.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
"kafka:ListClustersV2",
"cloudformation:ListStacks",
"iam:ListVirtualMFADevices",
"cloudwatch:DescribeAlarmsForMetric"
"cloudwatch:DescribeAlarmsForMetric",
"ec2:DescribeLaunchTemplates",
"ec2:DescribeLaunchTemplateVersions"
],
"Resource": "*"
}
]
}
}
18 changes: 18 additions & 0 deletions policies/ecc-aws-872-autoscaling_launch_template_hop_limit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright (c) 2024 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-872-autoscaling_launch_template_hop_limit
comment: '010024032000'
description: |
Auto Scaling launch template hop limit is greater than 1
resource: aws.launch-template-version
filters:
- type: value
key: LaunchTemplateData.MetadataOptions.HttpPutResponseHopLimit
op: gt
value: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
resource "aws_launch_template" "this" {
name_prefix = "872_launch_template_green"
image_id = data.aws_ami.this.id
instance_type = "t2.micro"
metadata_options {
http_endpoint = "enabled"
http_tokens = "required"
http_put_response_hop_limit = "1"
}
}

data "aws_ami" "this" {
most_recent = true
owners = ["amazon"]

filter {
name = "name"
values = ["amzn2-ami-hvm*"]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5"
}
}
}

provider "aws" {
profile = var.profile
region = var.default-region
default_tags {
tags = {
CustodianRule = "ecc-aws-872-autoscaling_launch_template_hop_limit"
ComplianceStatus = "Green"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
profile = "c7n"
default-region = "us-east-1"
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"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:DescribeLaunchTemplates",
"ec2:DescribeLaunchTemplateVersions"
],
"Resource": "*"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
resource "aws_launch_template" "this" {
name_prefix = "872_launch_template_red"
image_id = data.aws_ami.this.id
instance_type = "t2.micro"
metadata_options {
http_endpoint = "enabled"
http_tokens = "required"
http_put_response_hop_limit = "5"
}
}

data "aws_ami" "this" {
most_recent = true
owners = ["amazon"]

filter {
name = "name"
values = ["amzn2-ami-hvm*"]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5"
}
}
}

provider "aws" {
profile = var.profile
region = var.default-region
default_tags {
tags = {
CustodianRule = "ecc-aws-872-autoscaling_launch_template_hop_limit"
ComplianceStatus = "Red"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
profile = "c7n"
default-region = "us-east-1"
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"
}