Skip to content

Commit

Permalink
Revert root dependencies and infrastructure vars.
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew-Grayson committed Sep 22, 2023
1 parent 7152315 commit 9fd9178
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 1,415 deletions.
41 changes: 40 additions & 1 deletion infrastructure/cloudtrail.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ resource "aws_cloudtrail" "all-events" {
}

resource "aws_s3_bucket" "cloudtrail_bucket" {
bucket = var.cloudtrail_bucket_name
bucket = var.cloudtrail_bucket_name
force_destroy = true
tags = {
Project = var.project
Stage = var.stage
Expand Down Expand Up @@ -100,4 +101,42 @@ data "template_file" "cloudtrail_bucket_policy" {
bucketName = var.cloudtrail_bucket_name
accountId = data.aws_caller_identity.current.account_id
}
}

# Attach policies to the IAM role allowing access to the S3 bucket and Cloudwatch
resource "aws_iam_role_policy" "cloudtrail_policy" {
name_prefix = "crossfeed-cloudtrail-s3-${var.stage}"
role = aws_iam_role.cloudtrail_role.id
policy = jsonencode({
Version = "2012-10-17",
Statement = [{
Action = [
"s3:PutObject",
"s3:GetBucketAcl",
"s3:ListBucket"
],
Effect = "Allow",
Resource = [
aws_s3_bucket.cloudtrail_bucket.arn,
"${aws_s3_bucket.cloudtrail_bucket.arn}/*"
]
}]
})
}

resource "aws_iam_role_policy" "cloudtrail_cloudwatch_policy" {
name_prefix = "crossfeed-cloudtrail-cloudwatch-${var.stage}"
role = aws_iam_role.cloudtrail_role.id
policy = jsonencode({
Version = "2012-10-17",
Statement = [{
Action = [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
Effect = "Allow",
Resource = "arn:aws:logs:*"
}]
})
}
2 changes: 0 additions & 2 deletions infrastructure/prod.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ cloudtrail_bucket_name = "cisa-crossfeed-prod-cloudtrail"
cloudtrail_role_name = "cisa-crossfeed-prod-cloudtrail"
cloudtrail_log_group_name = "cisa-crossfeed-prod-cloudtrail"
export_bucket_name = "cisa-crossfeed-prod-exports"
infrastructure_bucket_name = "cisa-crossfeed-prod-infrastructure"
infrastructure_log_group_name = "cisa-crossfeed-prod-infrastructure"
reports_bucket_name = "cisa-crossfeed-prod-reports"
pe_db_backups_bucket_name = "cisa-crossfeed-prod-pe-db-backups"
user_pool_name = "crossfeed-prod"
Expand Down
2 changes: 0 additions & 2 deletions infrastructure/stage.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ cloudtrail_bucket_name = "cisa-crossfeed-staging-cloudtrail"
cloudtrail_role_name = "cisa-crossfeed-staging-cloudtrail"
cloudtrail_log_group_name = "cisa-crossfeed-staging-cloudtrail"
export_bucket_name = "cisa-crossfeed-staging-exports"
infrastructure_bucket_name = "cisa-crossfeed-staging-infrastructure"
infrastructure_log_group_name = "cisa-crossfeed-staging-infrastructure"
reports_bucket_name = "cisa-crossfeed-staging-reports"
pe_db_backups_bucket_name = "cisa-crossfeed-staging-pe-db-backups"
user_pool_name = "crossfeed-staging"
Expand Down
12 changes: 0 additions & 12 deletions infrastructure/vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -286,18 +286,6 @@ variable "export_bucket_name" {
default = "cisa-crossfeed-staging-exports"
}

variable "infrastructure_bucket_name" {
description = "infrastructure_bucket_name"
type = string
default = "cisa-crossfeed-staging-infrastructure"
}

variable "infrastructure_log_group_name" {
description = "infrastructure_log_group_name"
type = string
default = "crossfeed-staging-infrastructure-logs"
}

variable "reports_bucket_name" {
description = "reports_bucket_name"
type = string
Expand Down
Loading

0 comments on commit 9fd9178

Please sign in to comment.