Skip to content

Commit

Permalink
Merge pull request #108 from silinternational/develop
Browse files Browse the repository at this point in the history
Release 8.12.0 -- create IAM access key for Cloudtrail bucket user
  • Loading branch information
briskt authored Jul 8, 2024
2 parents d16facc + 501ee92 commit f6b58ce
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
9 changes: 8 additions & 1 deletion aws/cloudtrail/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# Deprecation Notice

This module is deprecated. Use https://registry.terraform.io/modules/silinternational/cloudtrail/aws/latest instead.

# aws/cloudtrail - CloudTrail
This module is used to set up CloudTrail logging for your AWS account.

## What this does

- Create S3 bucket for CloudTrail logs
- Create IAM user with read-only access to CloudTrail S3 bucket
- (Optional:) Create an Access Key and Secret for that IAM user
- Enable CloudTrail logging

## Required Inputs
Expand All @@ -15,10 +20,12 @@ This module is used to set up CloudTrail logging for your AWS account.

- `cloudtrail_name` - The name for your Trail in AWS CloudTrail. Default: `"aws-account-cloudtrail"`
- `is_multi_region_trail` - Whether the trail is created in the current region or in all regions. Default: `false`
- `create_access_key` - Whether to create an Access Key/Secret for the created IAM user. Default: `false`

## Outputs

_none_
- `s3_access_key_id` - The Access Key ID for the IAM user that has access to the S3 bucket, if requested.
- `s3_access_key_secret` - The Access Key Secret for the IAM user that has access to the S3 bucket, if requested.

## Example Usage

Expand Down
5 changes: 5 additions & 0 deletions aws/cloudtrail/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ resource "aws_iam_user_policy" "cloudtrail-s3" {
})
}

resource "aws_iam_access_key" "cloudtrail-s3" {
count = var.create_access_key ? 1 : 0
user = aws_iam_user.cloudtrail-s3.name
}

resource "aws_cloudtrail" "cloudtrail" {
count = 1
name = var.cloudtrail_name
Expand Down
10 changes: 10 additions & 0 deletions aws/cloudtrail/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
output "s3_access_key_id" {
value = one(aws_iam_access_key.cloudtrail-s3[*].id)
description = "The (optional) Access Key ID for the IAM user"
}

output "s3_access_key_secret" {
value = one(aws_iam_access_key.cloudtrail-s3[*].secret)
sensitive = true
description = "The (optional) Access Key Secret for the IAM user"
}
6 changes: 6 additions & 0 deletions aws/cloudtrail/vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ variable "cloudtrail_name" {
type = string
}

variable "create_access_key" {
description = "Whether to create an Access Key/Secret for the created IAM user"
default = false
type = bool
}

variable "is_multi_region_trail" {
description = "Whether the trail is created in the current region or in all regions"
type = bool
Expand Down

0 comments on commit f6b58ce

Please sign in to comment.