Skip to content

Commit

Permalink
feat: shape our TF module scaffolding (#1)
Browse files Browse the repository at this point in the history
Signed-off-by: Salim Afiune Maya <afiune@lacework.net>
  • Loading branch information
matthew zeier authored and danifitz committed Oct 21, 2022
1 parent b113501 commit bc307ea
Show file tree
Hide file tree
Showing 17 changed files with 541 additions and 17 deletions.
28 changes: 13 additions & 15 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
# Terraform
# Local .terraform directories
**/.terraform/*

# Don't add terraform lock file
terraform/.terraform.lock.hcl

# .tfstate files
*.tfstate
*.tfstate.*

# .lock files
# https://www.terraform.io/docs/language/dependency-lock.html
*.lock.hcl

# Crash log files
crash.log
crash.*.log

# Exclude all .tfvars files, which are likely to contain sensitive data, such as
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# to change depending on the environment.
*.tfvars
*.tfvars.json
# Ignore any .tfvars files that are generated automatically for each Terraform run. Most
# .tfvars files are managed as part of configuration and so should be included in
# version control.
#
# example.tfvars

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
Expand All @@ -27,12 +25,12 @@ override.tf.json
*_override.tf
*_override.tf.json

# vim
*.swp

# Include override files you do wish to add to version control using negated pattern
#
# !example_override.tf

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*

# Ignore CLI configuration files
.terraformrc
terraform.rc
Empty file added CHANGELOG.md
Empty file.
7 changes: 7 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
default: ci

ci:
scripts/ci_tests.sh

release: ci
scripts/release.sh prepare
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Lacework, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
<a href="https://lacework.com"><img src="https://techally-content.s3-us-west-1.amazonaws.com/public-content/lacework_logo_full.png" width="600"></a>

# terraform-lacework-alerts-to-aws-s3

[![GitHub release](https://img.shields.io/github/release/lacework/terraform-lacework-alerts-to-aws-s3.svg)](https://github.com/lacework/terraform-lacework-alerts-to-aws-s3/releases/)
[![Codefresh build status]( https://g.codefresh.io/api/badges/pipeline/lacework/terraform-modules%2Ftest-compatibility?type=cf-1&key=eyJhbGciOiJIUzI1NiJ9.NWVmNTAxOGU4Y2FjOGQzYTkxYjg3ZDEx.RJ3DEzWmBXrJX7m38iExJ_ntGv4_Ip8VTa-an8gBwBo)]( https://g.codefresh.io/pipelines/edit/new/builds?id=607e25e6728f5a6fba30431b&pipeline=test-compatibility&projects=terraform-modules&projectId=607db54b728f5a5f8930405d)

A Terraform Module to pipe alerts from Lacework via AWS Eventbridge to an AWS S3 bucket with Lacework.

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|----------|

## Outputs

| Name | Description |
|------|-------------|

# Lacework S3 alert channel

## What does this do?

Creates resources in AWS and Lacework to pipe alerts from Lacework via AWS Eventbridge to AWS S3 bucket.
Creates resources in AWS and Lacework to pipe alerts from Lacework via AWS Eventbridge to an AWS S3 bucket.

The flows goes as so:

Expand Down Expand Up @@ -73,4 +92,4 @@ Install the Lacework CLI and configure an API key. Install the AWS CLI.
}
]
}
```
```
2 changes: 2 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Release Notes
Release notes are automatically generated during a release.
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0-dev
20 changes: 20 additions & 0 deletions examples/default/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Default Example

Every Terraform module must have one or more examples.

```hcl
terraform {
required_providers {
lacework = {
source = "lacework/lacework"
}
}
}
provider "lacework" {}
module "lacework_module" {
source = "lacework/<NAME>/<PROVIDER>"
version = "~> 0.1"
}
```
5 changes: 5 additions & 0 deletions examples/default/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
provider "lacework" {}

module "lacework_module" {
source = "../.."
}
9 changes: 9 additions & 0 deletions examples/default/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
terraform {
required_version = ">= 0.12.26"

required_providers {
lacework = {
source = "lacework/lacework"
}
}
}
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Your Terraform code goes here :)
4 changes: 4 additions & 0 deletions output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#output "example" {
# value = var.example
# description = "This is just an example of an output"
#}
44 changes: 44 additions & 0 deletions scripts/ci_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash
#
# Name:: ci_tests.sh
# Description:: Use this script to run ci tests of this repository
# Author:: Salim Afiune Maya (<afiune@lacework.net>)
#
set -eou pipefail

readonly project_name=terraform-<PROVIDER>-<NAME>

TEST_CASES=(
examples/default
)

log() {
echo "--> ${project_name}: $1"
}

warn() {
echo "xxx ${project_name}: $1" >&2
}

integration_tests() {
for tcase in ${TEST_CASES[*]}; do
log "Running tests at $tcase"
( cd $tcase || exit 1
terraform init
terraform validate
terraform plan
) || exit 1
done
}

lint_tests() {
log "terraform fmt check"
terraform fmt -check
}

main() {
lint_tests
integration_tests
}

main || exit 99
69 changes: 69 additions & 0 deletions scripts/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash
#
# Name:: release.sh
# Description:: Use this script to prepare a new release on Github,
# the automation will create a GH tag like 'v0.1.0'
# (using the VERSION file)
# Author:: Salim Afiune Maya (<afiune@lacework.net>)
#
set -eou pipefail

# common release functions
source scripts/release_helpers.sh

# Required Variables
readonly org_name=lacework
readonly project_name=terraform-<PROVIDER>-<NAME>
readonly git_user="Lacework Inc."
readonly git_email="ops+releng@lacework.net"
readonly required_files_for_release=(
RELEASE_NOTES.md
CHANGELOG.md
VERSION
)
readonly main_branch=main

# Variable that changes during release
VERSION=$(cat VERSION)

usage() {
local _cmd
_cmd="$(basename "${0}")"
cat <<USAGE
${_cmd}: A tool that helps you do releases!
Use this script to prepare a new Github release, the automation will generate
release notes, update the changelog and create a Github tag like 'v0.1.0'.
USAGE:
${_cmd} [command]
COMMANDS:
prepare Generates release notes, updates version and CHANGELOG.md
verify Check if the release is ready to be applied
trigger Trigger a release by creating a git tag
publish Creates a Github tag like 'v0.1.0'
USAGE
}

main() {
case "${1:-}" in
prepare)
prepare_release
;;
publish)
publish_release
;;
verify)
verify_release
;;
trigger)
trigger_release
;;
*)
usage
;;
esac
}

main "$@" || exit 99
Loading

0 comments on commit bc307ea

Please sign in to comment.