Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tf_mod_aws_cloudtrail_ops
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
steamhaus
tf_mod_aws_cloudtrail_ops
Commits
2aef5c52
Commit
2aef5c52
authored
Dec 15, 2016
by
Chris Merrett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for delegated access to ops Cloudtrail bucket
parent
eea43bff
Pipeline
#772
passed with stage
in 5 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
8 deletions
+64
-8
README.md
README.md
+11
-2
main.tf
main.tf
+53
-6
No files found.
README.md
View file @
2aef5c52
...
...
@@ -8,6 +8,8 @@ Input Variables
-
`customer_name`
- The name of the custmer/enduser that you're using within Terraform.
-
`environment`
- The environment name that you're assigning. As this module is designed for "ops" accounts, "ops" is the default.
-
`child_accounts`
- A list of AWS account ID's that will also be writing Cloudtrail information to the ops bucket.
Outputs
-------
...
...
@@ -23,13 +25,20 @@ You can use these in your Terraform template with the following steps.
1.
) Adding a module resource to your template, e.g.
`main.tf`
```
variable "name" {}
variable "environment" {}
variable "aws_child_accounts" {
type = "list"
}
#############################################################################################################
# CloudTrail (Ops Account)
#############################################################################################################
module "cloudtrail_ops" {
source = "git::https://git.steamhaus.co.uk/steamhaus/tf_mod_aws_cloudtrail_ops"
customer_name = "${var.name}"
environment = "${var.environment}"
customer_name = "${var.name}"
environment = "${var.environment}"
child_accounts = "${var.aws_child_accounts}"
}
```
main.tf
View file @
2aef5c52
...
...
@@ -7,18 +7,65 @@ variable "environment" {
default
=
"ops"
}
data
"template_file"
"s3_policy"
{
template
=
"
${
file
(
"
${
path
.
module}
/s3_policy.json.tpl"
)
}
"
vars
{
customer_name
=
"
${
var
.
customer_name
}
"
environment
=
"
${
var
.
environment
}
"
variable
"child_accounts"
{
description
=
"List of child AWS account ID's"
type
=
"list"
}
data
"aws_iam_policy_document"
"main"
{
statement
{
sid
=
"AWSCloudTrailAclCheck"
effect
=
"Allow"
actions
=
[
"s3:GetBucketAcl"
]
resources
=
"arn:aws:s3:::
${
var
.
customer_name
}
-
${
var
.
environment
}
-cloudtrail"
principals
{
type
=
"Service"
identifiers
=
[
"cloudtrail.amazonaws.com"
]
}
}
statement
{
sid
=
"AWSCloudTrailWrite"
effect
=
"Allow"
actions
=
[
"s3:PutObject"
]
resources
=
"arn:aws:s3:::
${
var
.
customer_name
}
-
${
var
.
environment
}
-cloudtrail/*"
principals
{
type
=
"Service"
identifiers
=
[
"cloudtrail.amazonaws.com"
]
}
condition
{
test
=
"StringEquals"
variable
=
"s3:x-amz-acl"
values
=
[
"bucket-owner-full-control"
]
}
}
statement
{
sid
=
"AWSCloudTrailWrite"
effect
=
"Allow"
actions
=
[
"s3:PutObject"
]
resources
=
[
"
${
formatlist
(
"arn:aws:s3:::
$
${
var
.
customer_name
}
-
$
${
var
.
environment
}
-cloudtrail/AWSLogs/%s/*"
,
var
.
child_accounts
)
}
"
]
principals
{
type
=
"Service"
identifiers
=
[
"cloudtrail.amazonaws.com"
]
}
condition
{
test
=
"StringEquals"
variable
=
"s3:x-amz-acl"
values
=
[
"bucket-owner-full-control"
]
}
}
}
resource
"aws_s3_bucket"
"main"
{
bucket
=
"
${
var
.
customer_name
}
-
${
var
.
environment
}
-cloudtrail"
force_destroy
=
true
policy
=
"
${data
.
template_file
.
s3_policy
.
rendered
}
"
policy
=
"
${data
.
aws_iam_policy_document
.
main
.
json
}
"
}
resource
"aws_cloudtrail"
"main"
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment