-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Removed an empty file, and added a `.gitignore` file to not track artifacts of running `terraform init/plan/apply` * Ran `terraform 0.12-compatibility` to do a basic 0.11->0.12 conversion. * Put proper years in license * Changed input variable structure. This allows for cleaner extension of config if we decide to cover more cloud providers in the future. * Removed commented out old parameters. Added comments. * Updated README to reflect new input variable names/structure. Renamed one varable back to its original name. Deleted an obsolete screenshot from the documentation/README. * Fix a typo in the README and a typo in the variable definition * Use proper 0.12 syntax * Fix variable types to string * Fix more 0.12 syntax issues * Restructured configuration due to limitations in terraform variable definition syntax. See: hashicorp/terraform#19898 * Fix a place I didn't correctly rename a variable reference * Updated code comments and README with correct variable information, and a few typo fixes along the way. * Add dependency documention for required Terraform providers. * Fix some docs, and add the defaults for the optional settings * Remove largely unneeded variable. This also aligns the terraform module more closely to the CloudFormation template.
- Loading branch information
Showing
13 changed files
with
324 additions
and
216 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 @@ | ||
.terraform/ |
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
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
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 |
---|---|---|
@@ -1,48 +1,51 @@ | ||
// AWS Cloudtrail | ||
data "template_file" "aws_iam_cloudtrail_to_cloudwatch_assume_role_policy" { | ||
template = "${file("${path.module}/aws_iam_cloudtrail_to_cloudwatch_assume_role_policy.tpl")}" | ||
template = file( | ||
"${path.module}/aws_iam_cloudtrail_to_cloudwatch_assume_role_policy.tpl", | ||
) | ||
} | ||
|
||
data "template_file" "aws_iam_cloudtrail_to_cloudwatch_policy" { | ||
template = "${file("${path.module}/aws_iam_cloudtrail_to_cloudwatch_policy.tpl")}" | ||
vars { | ||
aws_account_id = "${var.aws_account_id}" | ||
aws_cloudtrail_name = "${var.aws_cloudtrail_name}" | ||
aws_region = "${var.aws_region}" | ||
template = file("${path.module}/aws_iam_cloudtrail_to_cloudwatch_policy.tpl") | ||
vars = { | ||
aws_account_id = var.aws_account_info.account_id | ||
aws_cloudtrail_name = var.aws_optional_conf.cloudtrail_name | ||
aws_region = var.aws_account_info.region | ||
} | ||
} | ||
|
||
|
||
resource "aws_cloudwatch_log_group" "ct" { | ||
name = "/aws/cloudtrail/${var.aws_cloudtrail_name}" | ||
tags { | ||
name = "/aws/cloudtrail/${var.aws_optional_conf.cloudtrail_name}" | ||
tags = { | ||
terraform = "true" | ||
} | ||
depends_on = ["aws_iam_role_policy.ct", "aws_s3_bucket_policy.bucket"] | ||
depends_on = [ | ||
aws_iam_role_policy.ct, | ||
aws_s3_bucket_policy.bucket, | ||
] | ||
} | ||
|
||
resource "aws_iam_role" "ct" { | ||
name = "${var.aws_cloudtrail_name}-CloudTrailToCloudWatch" | ||
assume_role_policy = "${data.template_file.aws_iam_cloudtrail_to_cloudwatch_assume_role_policy.rendered}" | ||
name = "${var.aws_optional_conf.cloudtrail_name}-CloudTrailToCloudWatch" | ||
assume_role_policy = data.template_file.aws_iam_cloudtrail_to_cloudwatch_assume_role_policy.rendered | ||
} | ||
|
||
resource "aws_iam_role_policy" "ct" { | ||
name = "CloudTrailToCloudWatch" | ||
role = "${aws_iam_role.ct.id}" | ||
policy = "${data.template_file.aws_iam_cloudtrail_to_cloudwatch_policy.rendered}" | ||
|
||
name = "CloudTrailToCloudWatch" | ||
role = aws_iam_role.ct.id | ||
policy = data.template_file.aws_iam_cloudtrail_to_cloudwatch_policy.rendered | ||
} | ||
|
||
resource "aws_cloudtrail" "ct" { | ||
name = "${var.aws_cloudtrail_name}" | ||
s3_bucket_name = "${aws_s3_bucket.bucket.id}" | ||
enable_logging = "${var.enable_logging}" | ||
enable_log_file_validation = "${var.enable_log_file_validation}" | ||
include_global_service_events = "${var.include_global_service_events}" | ||
is_multi_region_trail = "${var.is_multi_region_trail}" | ||
cloud_watch_logs_group_arn = "${aws_cloudwatch_log_group.ct.arn}" | ||
cloud_watch_logs_role_arn = "${aws_iam_role.ct.arn}" | ||
sns_topic_name = "${aws_sns_topic.sns.arn}" | ||
depends_on = ["aws_s3_bucket_policy.bucket"] | ||
name = var.aws_optional_conf.cloudtrail_name | ||
s3_bucket_name = aws_s3_bucket.bucket.id | ||
enable_logging = var.aws_flags.enable_logging | ||
enable_log_file_validation = var.aws_flags.enable_log_file_validation | ||
include_global_service_events = var.aws_flags.include_global_service_events | ||
is_multi_region_trail = var.aws_flags.is_multi_region_trail | ||
cloud_watch_logs_group_arn = aws_cloudwatch_log_group.ct.arn | ||
cloud_watch_logs_role_arn = aws_iam_role.ct.arn | ||
sns_topic_name = aws_sns_topic.sns.arn | ||
depends_on = [aws_s3_bucket_policy.bucket] | ||
} | ||
|
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 |
---|---|---|
@@ -1,32 +1,31 @@ | ||
// AWS Iam role for cross account access | ||
|
||
data "template_file" "aws_iam_assume_role_policy" { | ||
template = "${file("${path.module}/aws_iam_assume_role_policy.tpl")}" | ||
vars { | ||
threatstack_account_id = "${var.threatstack_account_id}" | ||
threatstack_external_id = "${var.threatstack_external_id}" | ||
template = file("${path.module}/aws_iam_assume_role_policy.tpl") | ||
vars = { | ||
threatstack_account_id = var.threatstack.account_id | ||
threatstack_external_id = var.threatstack.external_id | ||
} | ||
} | ||
|
||
data "template_file" "aws_iam_role_policy" { | ||
template = "${file("${path.module}/aws_iam_role_policy.tpl")}" | ||
vars { | ||
sqs_queue_arn = "${aws_sqs_queue.sqs.arn}" | ||
s3_resource = "${aws_s3_bucket.bucket.arn}/*" | ||
template = file("${path.module}/aws_iam_role_policy.tpl") | ||
vars = { | ||
sqs_queue_arn = aws_sqs_queue.sqs.arn | ||
s3_resource = "${aws_s3_bucket.bucket.arn}/*" | ||
} | ||
} | ||
|
||
|
||
resource "aws_iam_role" "role" { | ||
name = "${var.aws_iam_role_name}" | ||
assume_role_policy = "${data.template_file.aws_iam_assume_role_policy.rendered}" | ||
depends_on = ["aws_iam_role_policy.ct"] | ||
name = var.aws_optional_conf.iam_role_name | ||
assume_role_policy = data.template_file.aws_iam_assume_role_policy.rendered | ||
depends_on = [aws_iam_role_policy.ct] | ||
} | ||
|
||
resource "aws_iam_role_policy" "role" { | ||
name = "${var.aws_iam_role_name}" | ||
role = "${aws_iam_role.role.id}" | ||
name = var.aws_optional_conf.iam_role_name | ||
role = aws_iam_role.role.id | ||
|
||
policy = "${data.template_file.aws_iam_role_policy.rendered}" | ||
policy = data.template_file.aws_iam_role_policy.rendered | ||
} | ||
|
Oops, something went wrong.