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

Sample #16

Open
wants to merge 27 commits into
base: main
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
16 changes: 8 additions & 8 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ provider "aws" {
skip_credentials_validation = true
skip_requesting_account_id = true
skip_metadata_api_check = true
access_key = "mock_access_key"
secret_key = "mock_secret_key"
#access_key = "mock_access_key"
#secret_key = "mock_secret_key"
}

resource "aws_iam_account_password_policy" "strict" {
minimum_password_length = 8
#require_lowercase_characters = true
#require_numbers = true
#require_uppercase_characters = true
#require_symbols = true
minimum_password_length = 16
require_lowercase_characters = true
require_numbers = true
require_uppercase_characters = true
require_symbols = true
#allow_users_to_change_password = true
#password_reuse_prevention = 24
max_password_age = 3
Expand All @@ -33,4 +33,4 @@ module "cloudtrail" {

module "pki" {
source = "./modules/pki"
}
}
16 changes: 15 additions & 1 deletion modules/cloudtrail/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
resource "aws_kms_key" "my_kms_key" {
description = "KMS Key for encryption"
key_usage = "ENCRYPT_DECRYPT"
enable_key_rotation = true

tags = {
Name = "snyk-key"
}
}

resource "aws_cloudtrail" "insecure-logging" {
name = "cloudtrail-logging"
cloud_watch_logs_group_arn = "appLogs"
s3_bucket_name = "my-cloudtrail-bucket"
enable_logging = false
enable_logging = true
enable_log_file_validation = true
is_multi_region_trail = true
kms_key_id = aws_kms_key.my_kms_key.id
}
3 changes: 2 additions & 1 deletion modules/pki/main.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
resource "aws_kms_key" "a" {
description = "key 1"
deletion_window_in_days = 10
}
enable_key_rotation = true
}
36 changes: 29 additions & 7 deletions modules/storage/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,39 @@ resource "aws_s3_bucket" "insecure-bucket" {
bucket = "insecure-bucket"
}

# resource "aws_s3_bucket_public_access_block" "insecure-bucket" {
# block_public_acls = true
# block_public_policy = true
# ignore_public_acls = true
# restrict_public_buckets = true
# }
resource "aws_s3_bucket" "logging-bucket" {
bucket = "logging-bucket"
}

resource "aws_s3_bucket_public_access_block" "insecure-bucket" {
block_public_acls = true
block_public_policy = true
ignore_public_acls = true
restrict_public_buckets = true
logging {
target_bucket = aws_s3_bucket.logging-bucket.id
target_prefix = "log/"
}
versioning {
enabled = true
mfa_delete = true
}
}

resource "aws_s3_bucket_versioning" "my_bucket_versioning" {
bucket = aws_s3_bucket.insecure-bucket.id

# MFA Delete must be set to Enabled
versioning {
enabled = true
mfa_delete = true
}
}

resource "aws_ebs_volume" "example" {
availability_zone = "us-east-1a"
size = 20
encrypted = false
encrypted = true
tags = {
Name = "insecure"
}
Expand Down
2 changes: 1 addition & 1 deletion modules/vpc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ resource "aws_security_group" "allow_ssh" {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
cidr_blocks = ["192.16.0.0/24"]
}
}

Expand Down