-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
These are sample policies for ECS best practices
- Loading branch information
Showing
5 changed files
with
79 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apiVersion: v2 | ||
name: best-practices-ecs-tf-config | ||
description: Best practices ECS terraform config policy set | ||
type: application | ||
version: 0.1.0 | ||
appVersion: 0.1.0 | ||
keywords: | ||
- kubernetes | ||
- nirmata | ||
- kyverno | ||
- policy | ||
maintainers: | ||
- name: Nirmata | ||
url: https://nirmata.com/ |
32 changes: 32 additions & 0 deletions
32
charts/best-practices-ecs-tf-config/pols/check-aws-vpc-network-mode.yaml
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,32 @@ | ||
apiVersion: json.kyverno.io/v1alpha1 | ||
kind: ValidatingPolicy | ||
metadata: | ||
name: check-awsvpc-network-mode | ||
labels: | ||
ecs.aws.network.kyverno.io: awsvpc | ||
annotations: | ||
policies.kyverno.io/title: Check awsvpc network mode | ||
policies.kyverno.io/category: ECS Best Practices | ||
policies.kyverno.io/severity: medium | ||
policies.kyverno.io/description: >- | ||
The awsvpc network mode restricts the flow of traffic between different | ||
tasks or between your tasks and other services that run within your Amazon VPC. | ||
The awsvpc network mode provides task-level network isolation for tasks | ||
that run on Amazon EC2. | ||
spec: | ||
rules: | ||
- name: check-awsvpc-network-mode | ||
match: | ||
all: | ||
- ($analyzer): | ||
resource: | ||
type: terraform-config | ||
- (resource.aws_ecs_task_definition && length(resource.aws_ecs_task_definition) > `0`): true | ||
assert: | ||
all: | ||
- message: ECS services and tasks are required to use awsvpc network mode. | ||
check: | ||
resource: | ||
~.(aws_ecs_task_definition): | ||
~.(@): | ||
network_mode: awsvpc |
29 changes: 29 additions & 0 deletions
29
charts/best-practices-ecs-tf-config/pols/validate-ecs-container-insights-enabled.yaml
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,29 @@ | ||
apiVersion: json.kyverno.io/v1alpha1 | ||
kind: ValidatingPolicy | ||
metadata: | ||
name: validate-ecs-container-insights-enabled | ||
annotations: | ||
policies.kyverno.io/title: Validate ECS container insights are enabled | ||
policies.kyverno.io/category: ECS Best Practices | ||
policies.kyverno.io/severity: medium | ||
policies.kyverno.io/description: >- | ||
This Policy ensures that ECS clusters have container | ||
insights enabled. | ||
spec: | ||
rules: | ||
- name: container-insights | ||
match: | ||
all: | ||
- ($analyzer): | ||
resource: | ||
type: terraform-config | ||
- (resource.aws_ecs_cluster && length(resource.aws_ecs_cluster) > `0`): true | ||
assert: | ||
all: | ||
- message: ECS container insights are not enabled | ||
check: | ||
resource: | ||
~.(aws_ecs_cluster): | ||
~.(@): | ||
(setting[?name == 'containerInsights']): | ||
- value: enabled |
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,4 @@ | ||
{{ range $path, $_ := .Files.Glob "pols/**.yaml" }} | ||
{{ $.Files.Get $path }} | ||
--- | ||
{{ end }} |
Empty file.