-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Steven Nemetz
committed
Mar 27, 2018
0 parents
commit a1fc35d
Showing
19 changed files
with
194 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
version: 2 | ||
|
||
jobs: | ||
build: | ||
docker: | ||
- image: hashicorp/terraform:0.11.3 | ||
entrypoint: /bin/sh | ||
steps: | ||
- checkout | ||
- run: | ||
name: "Validate tf files (terraform validate)" | ||
command: | | ||
find . -type f -name "*.tf" -exec dirname {} \;|sort -u | while read m; do (terraform validate -check-variables=false "$m" && echo "√ $m") || exit 1 ; done | ||
- run: | ||
name: "Check: Terraform formatting (terraform fmt)" | ||
command: | | ||
if [ `terraform fmt --list=true -diff=true -write=false | tee format-issues | wc -c` -ne 0 ]; then | ||
echo "Some terraform files need be formatted, run 'terraform fmt' to fix" | ||
echo "Formatting issues:" | ||
cat format-issues | ||
exit 1 | ||
fi | ||
- run: | ||
name: "Install: tflint" | ||
command: | | ||
apk add jq wget | ||
# Get latest version of tflint | ||
pkg_arch=linux_amd64 | ||
dl_url=$(curl -s https://api.github.com/repos/wata727/tflint/releases/latest | jq -r ".assets[] | select(.name | test(\"${pkg_arch}\")) | .browser_download_url") | ||
wget ${dl_url} | ||
unzip tflint_linux_amd64.zip | ||
mkdir -p /usr/local/tflint/bin | ||
# Setup PATH for later run steps - ONLY for Bash and not in Bash | ||
#echo 'export PATH=/usr/local/tflint/bin:$PATH' >> $BASH_ENV | ||
echo "Installing tflint..." | ||
install tflint /usr/local/tflint/bin | ||
echo "Configuring tflint..." | ||
tf_ver=$(terraform version | awk 'FNR <= 1' | cut -dv -f2) | ||
echo -e "\tConfig for terraform version: ${tf_ver}" | ||
if [ -f '.tflint.hcl' ]; then | ||
sed -i "/terraform_version =/s/\".*\"/\"${tf_ver}\"/" .tflint.hcl | ||
else | ||
{ | ||
echo -e "config {\nterraform_version = \"${tf_ver}\"\ndeep_check = true\nignore_module = {" | ||
for module in $(grep -h '[^a-zA-Z]source[ =]' *.tf | sed -r 's/.*=\s+//' | sort -u); do | ||
# if not ^"../ | ||
echo "${module} = true" | ||
done | ||
echo "}}" | ||
} > .tflint.hcl | ||
fi | ||
echo "tflint configuration:" | ||
cat .tflint.hcl | ||
- run: | ||
# Not supporting modules from registry ?? v0.5.4 | ||
# For now, must ignore in config file | ||
name: "Check: tflint" | ||
command: | | ||
#echo "Initializing terraform..." | ||
#terraform init -input=false | ||
echo "Running tflint..." | ||
/usr/local/tflint/bin/tflint --version | ||
/usr/local/tflint/bin/tflint | ||
workflows: | ||
version: 2 | ||
build: | ||
jobs: | ||
- build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*.tfstate | ||
*.tfstate.backup | ||
.terraform | ||
terraform.tfvars |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
[![CircleCI](https://circleci.com/gh/devops-workflow/terraform-github-members.svg?style=svg)](https://circleci.com/gh/devops-workflow/terraform-github-members) | ||
|
||
terraform-github-members | ||
======================= | ||
|
||
Terraform module for managing Github organization members | ||
|
||
```hcl | ||
module "github-members" { | ||
source = "devops-workflow/members/github" | ||
version = "1.0.0" | ||
users = [ | ||
{ | ||
username = "user1" | ||
}, | ||
{ | ||
username = "user2" | ||
role = "member" | ||
}, | ||
{ | ||
username = "user3" | ||
role = "admin" | ||
}, | ||
] | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
# Example and manual test cases | ||
|
||
Each directory contains a configuration that serves as a manual test case and an example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Example: Module disabled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module "disabled" { | ||
source = "../../" | ||
enabled = false | ||
users = [] | ||
|
||
providers = { | ||
github = "github.devops" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
provider "github" { | ||
alias = "devops" | ||
organization = "devops-workflow" | ||
token = "${var.devops_token}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
variable "devops_token" { | ||
description = "Github personal access token with owner rights for organization devops-workflow" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Example: users |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module "members" { | ||
source = "../../" | ||
|
||
providers = { | ||
github = "github.devops" | ||
} | ||
|
||
users = [ | ||
{ | ||
username = "user1" | ||
}, | ||
{ | ||
username = "user2" | ||
role = "member" | ||
}, | ||
{ | ||
username = "user3" | ||
role = "admin" | ||
}, | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
provider "github" { | ||
alias = "devops" | ||
organization = "devops-workflow" | ||
token = "${var.devops_token}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
variable "devops_token" { | ||
description = "Github personal access token with owner rights for organization devops-workflow" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Other Terraform modules using this | ||
|
||
List of other Terraform modules using this one or that have examples (test cases) | ||
that use this module. | ||
|
||
These can also serve as more examples | ||
|
||
|
||
| Name | GitHub Repo | Terraform Registry | | ||
|-----|-----|-----| | ||
| team-members | [Repo](https://github.com/devops-workflow/terraform-github-team-members) | [Registry]() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# terraform-datadog-users | ||
|
||
# https://www.terraform.io/docs/providers/datadog/r/user.html | ||
|
||
module "enabled" { | ||
source = "devops-workflow/boolean/local" | ||
version = "0.1.1" | ||
value = "${var.enabled}" | ||
} | ||
|
||
resource "github_membership" "this" { | ||
count = "${module.enabled.value ? length(var.users) : 0}" | ||
username = "${lookup(var.users[count.index], "name")}" | ||
role = "${lookup(var.users[count.index], "role", "member")}" | ||
|
||
# member or admin | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Resource provides no attributes | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
variable "enabled" { | ||
description = "Set to false to prevent the module from creating anything" | ||
default = true | ||
} | ||
|
||
variable "users" { | ||
description = "List of organization member user maps to manage" | ||
type = "list" | ||
} |