Skip to content

Commit 338f42f

Browse files
Feat terrascan compliance (#146)
1 parent 188aa83 commit 338f42f

File tree

18 files changed

+40
-11
lines changed

18 files changed

+40
-11
lines changed

.github/workflows/ci-pull-request.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ jobs:
7272
run: |
7373
pip install pre-commit
7474
go install github.com/hashicorp/terraform-config-inspect@latest
75+
make deps
7576
7677
- name: Execute generate-terraform-providers for organizational
7778
if: ${{ matrix.directory != '.' }}
@@ -128,9 +129,7 @@ jobs:
128129
- name: Install pre-commit dependencies
129130
run: |
130131
pip install pre-commit
131-
go install github.com/terraform-docs/terraform-docs@v0.16.0
132-
go install github.com/hashicorp/terraform-config-inspect@latest
133-
curl -L "$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E "https://.+?_linux_amd64.zip")" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/
132+
make deps
134133
- name: Clean pre-commit cache
135134
run: pre-commit clean
136135
- name: Execute pre-commit max_version

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ repos:
7070
# https://github.com/antonbabenko/pre-commit-terraform#terraform_validate
7171
- id: terraform_validate
7272
exclude: (test)|(examples-internal)\/.*$
73+
- id: terrascan
74+
exclude: (test)
75+
args:
76+
- '--args=--skip-rules AC_AWS_0369'
7377
- repo: https://github.com/pre-commit/pre-commit-hooks
7478
rev: v4.1.0
7579
hooks:

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ deps:
55
unzip tflint.zip && \
66
rm tflint.zip && \
77
mv tflint "`go env GOPATH`/bin"
8+
curl -L https://github.com/tenable/terrascan/releases/download/v1.9.0/terrascan_1.9.0_Linux_x86_64.tar.gz -o terrascan.tar.gz && \
9+
tar -xf terrascan.tar.gz terrascan && \
10+
rm terrascan.tar.gz && \
11+
install terrascan "`go env GOPATH`/bin" && \
12+
rm terrascan
813

914
clean:
1015
find -name ".terraform" -type d | xargs rm -rf

modules/infrastructure/cloudtrail/s3.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
resource "aws_s3_bucket" "cloudtrail" {
2+
# AC_AWS_0214
3+
# Why: S3 bucket versioning is disabled
4+
#ts:skip=AC_AWS_0214 S3 is for testing purpose by the customer. In production S3 it's pretended to be provided by the customer with the logging related decisions taken by them as it has costs.
5+
# AC_AWS_0497
6+
# Why: S3 access logging is disabled
7+
#ts:skip=AC_AWS_0497 S3 is for testing purpose by the customer. In production S3 it's pretended to be provided by the customer with the logging related decisions taken by them as it has costs.
28
bucket = "${var.name}-${data.aws_caller_identity.me.account_id}"
39
force_destroy = true
410
tags = var.tags
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
resource "aws_sns_topic" "cloudtrail" {
2+
# AC_AWS_0502
3+
# Why: Encrypt SNS with KMS
4+
#ts:skip=AC_AWS_0502 Don't encrypt as far as SNS can be provided by customer
25
name = var.name
36
tags = var.tags
47
}

modules/infrastructure/cloudtrail_s3-sns-sqs/main.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ locals {
1313

1414

1515
resource "aws_sns_topic" "s3_sns" {
16-
name = local.s3_sns_name
17-
16+
# AC_AWS_0502
17+
# Why: Encrypt SNS with KMS
18+
#ts:skip=AC_AWS_0502 Don't encrypt as far as SNS can be provided by customer
19+
name = local.s3_sns_name
1820
policy = <<POLICY
1921
{
2022
"Version":"2012-10-17",

modules/infrastructure/ecs-vpc/vpc.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ data "aws_availability_zones" "zones" {
33

44
# https://registry.terraform.io/modules/terraform-aws-modules/vpc/aws/latest
55
module "vpc" {
6+
# AC_AWS_0369
7+
#ts:skip=AC_AWS_0369 Cannot be ignored on external module
68
source = "terraform-aws-modules/vpc/aws"
79
version = ">=3.14.0"
810

modules/infrastructure/permissions/iam-user/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ resource "aws_iam_user" "this" {
55
}
66

77
resource "aws_iam_access_key" "this" {
8+
# AC_AWS_0133
9+
#ts:skip=AC_AWS_0133 Doesn't apply
810
user = aws_iam_user.this.name
911
lifecycle {
1012
create_before_destroy = true

modules/infrastructure/sqs-sns-subscription/main.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
resource "aws_sqs_queue" "this" {
2+
# AC_AWS_0366
3+
# Why: Ensure that your Amazon Simple Queue Service (SQS) queues are protecting the contents of their messages using Server-Side Encryption (SSE).
4+
#ts:skip=AC_AWS_0366 Doesn't apply as the content of the event is stored on S3 not on the log
25
name = var.name
36
tags = var.tags
47
}
@@ -8,6 +11,7 @@ resource "aws_sns_topic_subscription" "this" {
811
protocol = "sqs"
912
endpoint = aws_sqs_queue.this.arn
1013
topic_arn = var.cloudtrail_sns_arn
14+
1115
}
1216

1317
resource "aws_sqs_queue_policy" "this" {

modules/infrastructure/eks/README.md renamed to test/eks/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
```terraform
44
module "eks"{
5-
source = "sysdiglabs/secure-for-cloud/aws//modules/infrastructure/eks"
5+
source = "sysdiglabs/secure-for-cloud/aws//test/eks"
66
default_vpc_subnets = ["<SUBNET_1>", "<SUBNET_2>"]
77
name = "<IDENTIFYING_NAME>"
88
}

0 commit comments

Comments
 (0)