Skip to content

Commit

Permalink
Refine config modules
Browse files Browse the repository at this point in the history
  • Loading branch information
posquit0 committed Dec 7, 2023
1 parent 9e203b8 commit 1463825
Show file tree
Hide file tree
Showing 15 changed files with 3,586 additions and 336 deletions.
31 changes: 31 additions & 0 deletions examples/config-recorder-simple/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
provider "aws" {
region = "us-east-1"
}


###################################################
# Config Recorder
###################################################

module "recorder" {
source = "../../modules/config-recorder"
# source = "tedilabs/security/aws//modules/config-recorder"
# version = "~> 0.6.0"

name = "test"
enabled = true

scope = {
strategy = "ALL_WITHOUT_GLOBAL"
}

delivery_channels = {
s3_bucket = {
name = module.bucket.name
}
}

tags = {
"project" = "terraform-aws-security-examples"
}
}
3 changes: 3 additions & 0 deletions examples/config-recorder-simple/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "recorder" {
value = module.recorder
}
73 changes: 73 additions & 0 deletions examples/config-recorder-simple/s3.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
data "aws_iam_policy_document" "config" {
statement {
sid = "AWSConfigBucketExistenceAndPermissionsCheck"

effect = "Allow"
actions = [
"s3:GetBucketAcl",
"s3:ListBucket",
]
resources = [
module.bucket.arn,
]

principals {
type = "Service"
identifiers = ["config.amazonaws.com"]
}
}
statement {
sid = "AWSConfigBucketDelivery"

effect = "Allow"
actions = [
"s3:PutObject",
]
resources = [
module.bucket.arn,
"${module.bucket.arn}/AWSLogs/*/Config/*",
]

principals {
type = "Service"
identifiers = ["config.amazonaws.com"]
}
condition {
test = "StringEquals"
variable = "s3:x-amz-acl"
values = ["bucket-owner-full-control"]
}
}
}


###################################################
# S3 Bucket
###################################################

resource "random_string" "this" {
length = 32
special = false
numeric = false
upper = false
}

locals {
bucket_name = random_string.this.id
}

module "bucket" {
source = "tedilabs/data/aws//modules/s3-bucket"
version = "~> 0.6.0"

name = local.bucket_name
force_destroy = true

policy = data.aws_iam_policy_document.config.json

tags = {
"project" = "terraform-aws-data-examples"
}
}


10 changes: 10 additions & 0 deletions examples/config-recorder-simple/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
terraform {
required_version = "~> 1.6"

required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}
2 changes: 1 addition & 1 deletion modules/config-managed-rule/raw.json

Large diffs are not rendered by default.

Loading

0 comments on commit 1463825

Please sign in to comment.