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

add s3_key_prefix variable #48

Merged
merged 4 commits into from Nov 29, 2021
Merged

add s3_key_prefix variable #48

merged 4 commits into from Nov 29, 2021

Conversation

niraj8
Copy link
Contributor

@niraj8 niraj8 commented Mar 31, 2021

what

  • Add s3_key_prefix variable

why

  • To allow users of this module to be able to store Cloudtrail logs in s3 bucket with a chosen prefix

@niraj8 niraj8 requested review from a team as code owners March 31, 2021 20:19
@niraj8 niraj8 requested a review from a team as a code owner March 31, 2021 20:20
@Gowiem
Copy link
Member

Gowiem commented Jun 29, 2021

/test all

@mergify
Copy link

mergify bot commented Aug 21, 2021

This pull request is now in conflict. Could you fix it @niraj8? 🙏

@vzanlnx
Copy link

vzanlnx commented Nov 24, 2021

Hello, I'm interested in having this option in the official module, any chances of merging this? cc @Gowiem

@Gowiem
Copy link
Member

Gowiem commented Nov 24, 2021

@vzanlnx sorry -- This one ended up sitting and that looks to be on me. Let's get it moving along.

@niraj8 your work got out of date. Would you mind pulling the latest from master (or rebasing), run make init && make readme, and then push the results?

@Gowiem Gowiem self-requested a review November 24, 2021 15:50
# Conflicts:
#	README.md
#	docs/terraform.md
@niraj8 niraj8 dismissed a stale review via fede373 November 26, 2021 15:32
@@ -12,7 +12,7 @@ resource "aws_cloudtrail" "default" {
tags = module.this.tags
kms_key_id = var.kms_key_arn
is_organization_trail = var.is_organization_trail

s3_key_prefix = var.s3_key_prefix
Copy link

@bridgecrew bridgecrew bot Nov 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MEDIUM   Ensure CloudTrail trail is integrated with CloudWatch Log
    Resource: aws_cloudtrail.default | ID: BC_AWS_LOGGING_27

How to Fix

resource "aws_cloudtrail" "aws_cloudtrail_ok" {
  name                          = "tf-trail-foobar"
  cloud_watch_logs_group_arn = "${aws_cloudwatch_log_group.example.arn}:*"
}

Description

AWS CloudTrail is a web service that records AWS API calls made in a given AWS account. The recorded information includes the identity of the API caller, the time of the API call, the source IP address of the API caller, the request parameters, and the response elements returned by the AWS service. CloudTrail uses Amazon S3 for log file storage and delivery, so log files are stored durably. In addition to capturing CloudTrail logs within a specified S3 bucket for long term analysis, realtime analysis can be performed by configuring CloudTrail to send logs to CloudWatch logs. For a trail that is enabled in all regions in an account, CloudTrail sends log files from all those regions to a CloudWatch logs log group. It is recommended that CloudTrail logs be sent to CloudWatch logs.

@@ -12,7 +12,7 @@ resource "aws_cloudtrail" "default" {
tags = module.this.tags
kms_key_id = var.kms_key_arn
is_organization_trail = var.is_organization_trail

s3_key_prefix = var.s3_key_prefix
Copy link

@bridgecrew bridgecrew bot Nov 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MEDIUM   Ensure AWS CloudTrail logs are encrypted using CMKs
    Resource: aws_cloudtrail.default | ID: BC_AWS_LOGGING_7
Error in referred variable: variable "kms_key_arn"

How to Fix

Resources:
	myTrail: 
  	Type: AWS::CloudTrail::Trail
		Properties: 
			...
+			KMSKeyId: alias/MyAliasName

Description

AWS CloudTrail is a web service that records AWS API calls for an account, and makes those logs available to users and resources in accordance with IAM policies. AWS Key Management Service (KMS) is a managed service that helps create and control the encryption keys used to encrypt account data. It uses Hardware Security Modules (HSMs) to protect the security of encryption keys. CloudTrail logs can be configured to leverage server-side encryption (SSE) and KMS customer created master keys (CMK) to further protect CloudTrail logs.

We recommend that CloudTrail logs are configured to use SSE-KMS, providing additional confidentiality controls on log data. A given user must have S3 read permission on the corresponding log bucket and must be granted decrypt permission by the CMK policy.

Benchmarks

  • SOC2 CC6.3.3
  • PCI-DSS V3.2 3, 10
  • HIPAA 164.312(D) Person or entity authentication
  • NIST-800-53 AC-17
  • ISO27001 A.12.4.2
  • CIS AWS V1.2 2.7
  • PCI-DSS V3.2.1 10.5.1
  • FEDRAMP (MODERATE) AU-9, SC-28
  • CIS AWS V1.3 3.7

Copy link

@bridgecrew bridgecrew bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️   Due to fede373 - Merge remote-tracking branch 'upstream/master' - 2 new errors were added

Change details

Error ID Change Path Resource
BC_AWS_LOGGING_7 Added /main.tf aws_cloudtrail.default
BC_AWS_LOGGING_27 Added /main.tf aws_cloudtrail.default

@@ -12,7 +12,7 @@ resource "aws_cloudtrail" "default" {
tags = module.this.tags
kms_key_id = var.kms_key_arn
is_organization_trail = var.is_organization_trail

s3_key_prefix = var.s3_key_prefix
Copy link

@bridgecrew bridgecrew bot Nov 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MEDIUM   Ensure AWS CloudTrail logs are encrypted using CMKs
    Resource: aws_cloudtrail.default | ID: BC_AWS_LOGGING_7
Error in referred variable: variable "kms_key_arn"

How to Fix

Resources:
	myTrail: 
  	Type: AWS::CloudTrail::Trail
		Properties: 
			...
+			KMSKeyId: alias/MyAliasName

Description

AWS CloudTrail is a web service that records AWS API calls for an account, and makes those logs available to users and resources in accordance with IAM policies. AWS Key Management Service (KMS) is a managed service that helps create and control the encryption keys used to encrypt account data. It uses Hardware Security Modules (HSMs) to protect the security of encryption keys. CloudTrail logs can be configured to leverage server-side encryption (SSE) and KMS customer created master keys (CMK) to further protect CloudTrail logs.

We recommend that CloudTrail logs are configured to use SSE-KMS, providing additional confidentiality controls on log data. A given user must have S3 read permission on the corresponding log bucket and must be granted decrypt permission by the CMK policy.

Benchmarks

  • SOC2 CC6.3.3
  • PCI-DSS V3.2 3, 10
  • HIPAA 164.312(D) Person or entity authentication
  • NIST-800-53 AC-17
  • ISO27001 A.12.4.2
  • CIS AWS V1.2 2.7
  • PCI-DSS V3.2.1 10.5.1
  • FEDRAMP (MODERATE) AU-9, SC-28
  • CIS AWS V1.3 3.7

@@ -12,7 +12,7 @@ resource "aws_cloudtrail" "default" {
tags = module.this.tags
kms_key_id = var.kms_key_arn
is_organization_trail = var.is_organization_trail

s3_key_prefix = var.s3_key_prefix
Copy link

@bridgecrew bridgecrew bot Nov 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MEDIUM   Ensure CloudTrail trail is integrated with CloudWatch Log
    Resource: aws_cloudtrail.default | ID: BC_AWS_LOGGING_27

How to Fix

resource "aws_cloudtrail" "aws_cloudtrail_ok" {
  name                          = "tf-trail-foobar"
  cloud_watch_logs_group_arn = "${aws_cloudwatch_log_group.example.arn}:*"
}

Description

AWS CloudTrail is a web service that records AWS API calls made in a given AWS account. The recorded information includes the identity of the API caller, the time of the API call, the source IP address of the API caller, the request parameters, and the response elements returned by the AWS service. CloudTrail uses Amazon S3 for log file storage and delivery, so log files are stored durably. In addition to capturing CloudTrail logs within a specified S3 bucket for long term analysis, realtime analysis can be performed by configuring CloudTrail to send logs to CloudWatch logs. For a trail that is enabled in all regions in an account, CloudTrail sends log files from all those regions to a CloudWatch logs log group. It is recommended that CloudTrail logs be sent to CloudWatch logs.

Copy link

@bridgecrew bridgecrew bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️   Due to 8284892 - Auto Format - 2 new errors were added

Change details

Error ID Change Path Resource
BC_AWS_LOGGING_7 Added /main.tf aws_cloudtrail.default
BC_AWS_LOGGING_27 Added /main.tf aws_cloudtrail.default

@niraj8
Copy link
Contributor Author

niraj8 commented Nov 26, 2021

@Gowiem
Updated the PR.
I think the bridgecrew errors are due to default empty values for kms_key_arn & cloud_watch_logs_group_arn, not sure though.

Let me know if these need to be fixed.

@Gowiem
Copy link
Member

Gowiem commented Nov 29, 2021

/test all

@Gowiem Gowiem merged commit 8d30d01 into cloudposse:master Nov 29, 2021
@Gowiem
Copy link
Member

Gowiem commented Nov 29, 2021

@niraj8 thanks! Released as 0.21.0 👍

cc @vzanlnx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants