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
eea43bff
Commit
eea43bff
authored
Dec 15, 2016
by
Chris Merrett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit
parents
Pipeline
#766
passed with stage
in 8 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
111 additions
and
0 deletions
+111
-0
.gitlab-ci.yml
.gitlab-ci.yml
+12
-0
README.md
README.md
+35
-0
main.tf
main.tf
+36
-0
s3_policy.json.tpl
s3_policy.json.tpl
+28
-0
No files found.
.gitlab-ci.yml
0 → 100644
View file @
eea43bff
image
:
alpine:latest
variables
:
TERRAFORM_URL
:
"
https://releases.hashicorp.com/terraform/0.7.13/terraform_0.7.13_linux_amd64.zip"
before_script
:
-
apk update && apk add ca-certificates && update-ca-certificates && apk add openssl
-
wget -O /tmp/terraform.zip $TERRAFORM_URL
-
unzip /tmp/terraform.zip -d /usr/local/bin
test
:
script
:
terraform validate
README.md
0 → 100644
View file @
eea43bff
tf_mod_aws_cloudtrail_ops
==============
A Terraform module for creating the Cloudtrail server and associated logging bucket for an account.
The role assumes that your environment will be known as "ops", as this module is designed to facilitate
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.
Outputs
-------
-
`bucket_name`
- The name of the logging bucket.
-
`cloudtrail_name`
- The name of the Cloudtrail service that has been created.
Usage
-----
You can use these in your Terraform template with the following steps.
1.
) Adding a module resource to your template, e.g.
`main.tf`
```
#############################################################################################################
# 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}"
}
```
main.tf
0 → 100644
View file @
eea43bff
variable
"customer_name"
{
description
=
"Account canonical name"
}
variable
"environment"
{
description
=
"Account environment type"
default
=
"ops"
}
data
"template_file"
"s3_policy"
{
template
=
"
${
file
(
"
${
path
.
module}
/s3_policy.json.tpl"
)
}
"
vars
{
customer_name
=
"
${
var
.
customer_name
}
"
environment
=
"
${
var
.
environment
}
"
}
}
resource
"aws_s3_bucket"
"main"
{
bucket
=
"
${
var
.
customer_name
}
-
${
var
.
environment
}
-cloudtrail"
force_destroy
=
true
policy
=
"
${data
.
template_file
.
s3_policy
.
rendered
}
"
}
resource
"aws_cloudtrail"
"main"
{
name
=
"
${
var
.
customer_name
}
-
${
var
.
environment
}
-cloudtrail"
s3_bucket_name
=
"
${
aws_s3_bucket
.
main
.
id
}
"
include_global_service_events
=
true
}
output
"bucket_name"
{
value
=
"
${
aws_s3_bucket
.
main
.
id
}
"
}
output
"cloudtrail_name"
{
value
=
"
${
aws_cloudtrail
.
main
.
id
}
"
}
s3_policy.json.tpl
0 → 100644
View file @
eea43bff
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AWSCloudTrailAclCheck",
"Effect": "Allow",
"Principal": {
"Service": "cloudtrail.amazonaws.com"
},
"Action": "s3:GetBucketAcl",
"Resource": "arn:aws:s3:::$
{
customer_name
}
-$
{
environment
}
-cloudtrail"
},
{
"Sid": "AWSCloudTrailWrite",
"Effect": "Allow",
"Principal": {
"Service": "cloudtrail.amazonaws.com"
},
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::$
{
customer_name
}
-$
{
environment
}
-cloudtrail/*",
"Condition": {
"StringEquals": {
"s3:x-amz-acl": "bucket-owner-full-control"
}
}
}
]
}
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