Skip to content

Commit b1101fd

Browse files
authored
added cloudtrailEnable option to fix #173 (#243)
1 parent 0199b7b commit b1101fd

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

templates/terraform/environments/prod/user_access.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,12 @@ data "aws_iam_policy_document" "operator_access" {
8787
statement {
8888
effect = "Allow"
8989
actions = ["s3:ListBucket"]
90-
resources = ["arn:aws:s3:::${data.terraform_remote_state.shared.outputs.cloudtrail_bucket_id}"]
90+
resources = ["arn:aws:s3:::*-cloudtrail"]
9191
}
9292
statement {
9393
effect = "Allow"
9494
actions = ["s3:GetObject", "s3:PutObject"]
95-
resources = ["arn:aws:s3:::${data.terraform_remote_state.shared.outputs.cloudtrail_bucket_id}/*"]
95+
resources = ["arn:aws:s3:::*-cloudtrail/*"]
9696
}
9797

9898
# Application secret management - this role can view and edit application secrets in the production environment

templates/terraform/environments/shared/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ locals {
1515
account_id = "<% index .Params `accountId` %>"
1616
random_seed = "<% index .Params `randomSeed` %>"
1717
shared_resource_prefix = "<% if ne (index .Params `sharedResourcePrefix`) "none" %><% index .Params `sharedResourcePrefix` %><% end %>"
18+
enable_cloudtrail = <%if eq (index .Params `cloudtrailEnable`) "yes" %>1<% else %>0<% end %>
1819
}
1920

2021
provider "aws" {
@@ -144,6 +145,7 @@ module "secret_keys" {
144145

145146
# Enable AWS CloudTrail to help you audit governance, compliance, and operational risk of your AWS account, with logs stored in S3 bucket.
146147
module "cloudtrail" {
148+
count = local.enable_cloudtrail
147149
source = "commitdev/zero/aws//modules/cloudtrail"
148150
version = "0.1.10"
149151

tests/fixtures/test-project/zero-project.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ modules:
1010
accountId: "123456781234"
1111
database: mysql
1212
fileUploads: "no"
13+
cloudtrailEnable: "yes"
1314
loggingType: kibana
1415
metricsType: prometheus
1516
productionBackendSubdomain: api.

zero-module.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,3 +209,10 @@ parameters:
209209
- field: sharedResourcePrefix
210210
label: "Mostly for development - Allow shared resources to have a unique prefix. This is only necessary if many zero projects will be run in the same AWS account."
211211
value: "none"
212+
- field: cloudtrailEnable
213+
label: Enable cloudtrail?
214+
info: "CloudTrail monitors and records account activity across your AWS infrastructure, giving you control over storage, analysis, and remediation actions. It can add $5-10 per month and may not provide much value to a smaller company"
215+
default: no
216+
options:
217+
"yes": "Yes"
218+
"no": "No"

0 commit comments

Comments
 (0)