Skip to content

Commit

Permalink
skip: Merge branch 'update_iam_per_policy' into feature/policy_testin…
Browse files Browse the repository at this point in the history
…g_v2
  • Loading branch information
anna-shcherbak committed Jul 3, 2024
2 parents 13f44d0 + 2cfa9ba commit b90f2ec
Show file tree
Hide file tree
Showing 21 changed files with 141 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ policies:
IAM instance roles are not used for AWS resource access from instances
resource: aws.ec2
filters:
- not:
- type: value
key: State.Name
value: terminated
- type: value
key: IamInstanceProfile
value: absent
15 changes: 7 additions & 8 deletions policies/ecc-aws-222-ec2_instance_managed_by_systems_manager.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ policies:
EC2 instances are not managed by AWS Systems Manager
resource: aws.ec2
filters:
- and:
- type: value
key: State.Name
op: in
value: [running, stopped]
- type: ssm
key: InstanceId
value: empty
- not:
- type: value
key: State.Name
value: terminated
- type: ssm
key: InstanceId
value: empty
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ policies:
Instances managed by Systems Manager do not have association compliance status of COMPLIANT
resource: aws.ec2
filters:
- and:
- type: value
key: State.Name
op: in
value: [running, stopped]
- type: ssm-compliance
compliance_types:
- Association
states:
- NON_COMPLIANT
- not:
- type: value
key: State.Name
value: terminated
- type: ssm-compliance
compliance_types:
- Association
states:
- NON_COMPLIANT
4 changes: 4 additions & 0 deletions policies/ecc-aws-224-ec2_instance_imdsv2_enabled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ policies:
EC2 instances do not use IMDSv2
resource: aws.ec2
filters:
- not:
- type: value
key: State.Name
value: terminated
- type: value
key: MetadataOptions.HttpTokens
value: optional
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ policies:
EC2 instances detailed monitoring disabled
resource: aws.ec2
filters:
- not:
- type: value
key: State.Name
value: terminated
- type: value
key: Monitoring.State
value: disabled
4 changes: 4 additions & 0 deletions policies/ecc-aws-490-ec2_token_hop_limit_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ policies:
EC2 instances token hop limit set correctly
resource: aws.ec2
filters:
- not:
- type: value
key: State.Name
value: terminated
- not:
- type: value
key: MetadataOptions.HttpPutResponseHopLimit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ policies:
EBS volumes attached to an EC2 instance is not marked for deletion upon instance termination
resource: aws.ec2
filters:
- not:
- type: value
key: State.Name
value: terminated
- type: value
key: BlockDeviceMappings[].Ebs.DeleteOnTermination
op: contains
Expand Down
6 changes: 5 additions & 1 deletion policies/ecc-aws-549-ec2_instance_previous_generation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ policies:
EC2 instance is not using last generation classes
resource: ec2
filters:
- not:
- type: value
key: State.Name
value: terminated
- type: value
key: InstanceType
op: regex
value: '(m1|m2|m3|t1|c1|c3|i2|cr1|r3|hs1|g2|a1).[^\s]+'
value: '(m1|m2|m3|m4|t1|c1|c2|c3|i2|cr1|r3|r4|hs1|g2|a1|d2).[^\s]+'
4 changes: 4 additions & 0 deletions policies/ecc-aws-576-ec2_instance_dedicated_tenancy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ policies:
Amazon EC2 instances with dedicated tenancy
resource: aws.ec2
filters:
- not:
- type: value
key: State.Name
value: terminated
- type: value
key: Placement.Tenancy
op: in
Expand Down
22 changes: 11 additions & 11 deletions terraform/ecc-aws-020-instance_without_any_tag/iam/020-policy.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:DescribeInstances",
"ec2:DescribeRegions"
],
"Resource": "*"
}
]
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:DescribeInstances",
"ec2:DescribeTags"
],
"Resource": "*"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"Action": [
"ec2:DescribeInstanceAttribute",
"ec2:DescribeInstances",
"ec2:DescribeTags",
"ec2:DescribeRegions"
"ec2:DescribeTags"
],
"Resource": "*"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"Effect": "Allow",
"Action": [
"ssm:ListResourceComplianceSummaries",
"ec2:DescribeInstances"
"ec2:DescribeInstances",
"ec2:DescribeTags"
],
"Resource": "*"
}
Expand Down
21 changes: 11 additions & 10 deletions terraform/ecc-aws-185-ec2_stopped_instance/iam/185-policy.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:DescribeInstances"
],
"Resource": "*"
}
]
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:DescribeInstances",
"ec2:DescribeTags"
],
"Resource": "*"
}
]
}
21 changes: 11 additions & 10 deletions terraform/ecc-aws-186-ec2_instance_no_public_ip/iam/186-policy.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:DescribeNetworkInterfaces"
],
"Resource": "*"
}
]
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:DescribeInstances",
"ec2:DescribeTags"
],
"Resource": "*"
}
]
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:DescribeInstances"
],
"Resource": "*"
}
]
}
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:DescribeInstances",
"ec2:DescribeTags"
],
"Resource": "*"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
"Effect": "Allow",
"Action": [
"ec2:DescribeInstances",
"ec2:DescribeTags",
"tag:GetResources",
"ssm:DescribeInstanceInformation"
],
"Resource": "*"
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"Effect": "Allow",
"Action": [
"ec2:DescribeInstances",
"ec2:DescribeTags",
"ssm:ListResourceComplianceSummaries"
],
"Resource": "*"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:DescribeInstances"
],
"Resource": "*"
}
]
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:DescribeInstances",
"ec2:DescribeTags"
],
"Resource": "*"
}
]
}
21 changes: 11 additions & 10 deletions terraform/ecc-aws-490-ec2_token_hop_limit_check/iam/490-policy.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:DescribeInstances"
],
"Resource": "*"
}
]
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:DescribeInstances",
"ec2:DescribeTags"
],
"Resource": "*"
}
]
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "ec2:DescribeInstances",
"Resource": "*"
}
]
}
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:DescribeInstances",
"ec2:DescribeTags"
],
"Resource": "*"
}
]
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:DescribeInstances"
],
"Resource": "*"
}
]
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:DescribeInstances",
"ec2:DescribeTags"
],
"Resource": "*"
}
]
}

0 comments on commit b90f2ec

Please sign in to comment.