-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
9 changed files
with
225 additions
and
2 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,56 @@ | ||
workflow "Terraform" { | ||
resolves = "terraform-validate" | ||
on = "pull_request" | ||
} | ||
|
||
workflow "Release" { | ||
on = "push" | ||
resolves = ["goreleaser"] | ||
} | ||
|
||
action "filter-to-pr-open-synced" { | ||
uses = "actions/bin/filter@master" | ||
args = "action 'opened|synchronize'" | ||
} | ||
|
||
action "terraform-fmt" { | ||
uses = "hashicorp/terraform-github-actions/[email protected]" | ||
needs = "filter-to-pr-open-synced" | ||
secrets = ["GITHUB_TOKEN"] | ||
|
||
env = { | ||
TF_ACTION_WORKING_DIR = "." | ||
} | ||
} | ||
|
||
action "terraform-init" { | ||
uses = "hashicorp/terraform-github-actions/[email protected]" | ||
needs = "terraform-fmt" | ||
secrets = ["GITHUB_TOKEN"] | ||
|
||
env = { | ||
TF_ACTION_WORKING_DIR = "./examples/basic" | ||
} | ||
} | ||
|
||
action "terraform-validate" { | ||
uses = "hashicorp/terraform-github-actions/[email protected]" | ||
needs = "terraform-init" | ||
secrets = ["GITHUB_TOKEN"] | ||
|
||
env = { | ||
TF_ACTION_WORKING_DIR = "./examples/basic" | ||
} | ||
} | ||
|
||
action "is-tag" { | ||
uses = "actions/bin/filter@master" | ||
args = "tag" | ||
} | ||
|
||
action "goreleaser" { | ||
uses = "docker://goreleaser/goreleaser" | ||
secrets = ["GITHUB_TOKEN"] | ||
args = "release" | ||
needs = ["is-tag"] | ||
} |
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 @@ | ||
builds: | ||
- | ||
main: ./.goreleaser/main.go | ||
binary: dirty-hack | ||
ignore: | ||
- goos: darwin | ||
goarch: 386 | ||
- goos: darwin | ||
goarch: amd64 | ||
- goos: linux | ||
goarch: 386 | ||
archive: | ||
name_template: "dirty-hack-for-goreleaser" | ||
files: | ||
- README.md | ||
release: | ||
name_template: "{{.Tag}}" |
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 @@ | ||
package main | ||
|
||
func main() { | ||
} |
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
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 |
---|---|---|
@@ -1,2 +1,40 @@ | ||
# terraform-google-project | ||
terraform-google-project | ||
|
||
The terraform module for creation and management of a GCP project with normalized name and labels. | ||
|
||
## Usage | ||
|
||
```hcl | ||
module "my_awesome_project" { | ||
source = "git::https://github.com/SweetOps/terraform-google-project.git?ref=master" | ||
name = "awesome" | ||
stage = "production" | ||
namespace = "sweetops" | ||
} | ||
``` | ||
|
||
## Inputs | ||
|
||
|
||
| Name | Description | Type | Default | Required | | ||
|:---------------------------|:------------------------------------------------------------------------------------------------|:------:|:---------:|:--------:| | ||
| name | Solution name, e.g. 'app' or 'jenkins' | string | n/a | yes | | ||
| namespace | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | string | n/a | yes | | ||
| stage | Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release' | string | n/a | yes | | ||
| attributes | Additional attributes (e.g. `1`) | list | `[]` | no | | ||
| auto_create_network | Create the 'default' network automatically | string | `"true"` | no | | ||
| context | Default context to use for passing state between label invocations | map | `{}` | no | | ||
| delimiter | Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes` | string | `"-"` | no | | ||
| enable_deletion_protection | If true, the Terraform resource can be deleted without deleting the Project via the Google API. | string | `"false"` | no | | ||
| enabled | Set to false to prevent the module from creating any resources | string | `"true"` | no | | ||
| environment | Environment, e.g. 'prod', 'staging', 'dev', 'pre-prod', 'UAT' | string | `""` | no | | ||
| folder_id | The numeric ID of the folder this project should be created under | string | `""` | no | | ||
| org_id | The numeric ID of the organization this project belongs to | string | `""` | no | | ||
| tags | Additional tags (e.g. `map('BusinessUnit','XYZ')` | map | `{}` | no | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|:-------|:--------------------------------------| | ||
| name | The project ID | | ||
| number | The numeric identifier of the project | |
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,6 @@ | ||
module "my_awesome_project" { | ||
source = "../../" | ||
name = "awesome" | ||
stage = "production" | ||
namespace = "sweetops" | ||
} |
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,23 @@ | ||
module "label" { | ||
source = "git::https://github.com/SweetOps/terraform-null-label.git?ref=tags/0.6.0" | ||
enabled = "${var.enabled}" | ||
namespace = "${var.namespace}" | ||
name = "${var.name}" | ||
stage = "${var.stage}" | ||
environment = "${var.environment}" | ||
delimiter = "${var.delimiter}" | ||
attributes = "${var.attributes}" | ||
context = "${var.context}" | ||
tags = "${var.tags}" | ||
} | ||
|
||
resource "google_project" "default" { | ||
count = "${var.enabled == "true" ? 1 : 0}" | ||
name = "${module.label.id}" | ||
project_id = "${module.label.id}" | ||
labels = "${module.label.gcp_list_of_maps}" | ||
org_id = "${var.org_id}" | ||
folder_id = "${var.folder_id}" | ||
skip_delete = "${var.enable_deletion_protection}" | ||
auto_create_network = "${var.auto_create_network}" | ||
} |
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 @@ | ||
output "number" { | ||
value = "${join("", google_project.default.*.number)}" | ||
description = "The numeric identifier of the project" | ||
} | ||
|
||
output "name" { | ||
value = "${join("", google_project.default.*.name)}" | ||
description = "The project ID" | ||
} |
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,70 @@ | ||
variable "namespace" { | ||
type = "string" | ||
description = "Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp'" | ||
} | ||
|
||
variable "environment" { | ||
type = "string" | ||
default = "" | ||
description = "Environment, e.g. 'prod', 'staging', 'dev', 'pre-prod', 'UAT'" | ||
} | ||
|
||
variable "stage" { | ||
type = "string" | ||
description = "Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release'" | ||
} | ||
|
||
variable "name" { | ||
type = "string" | ||
description = "Solution name, e.g. 'app' or 'jenkins'" | ||
} | ||
|
||
variable "enabled" { | ||
type = "string" | ||
default = "true" | ||
description = "Set to false to prevent the module from creating any resources" | ||
} | ||
|
||
variable "delimiter" { | ||
type = "string" | ||
default = "-" | ||
description = "Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes`" | ||
} | ||
|
||
variable "attributes" { | ||
type = "list" | ||
default = [] | ||
description = "Additional attributes (e.g. `1`)" | ||
} | ||
|
||
variable "tags" { | ||
type = "map" | ||
default = {} | ||
description = "Additional tags (e.g. `map('BusinessUnit','XYZ')`" | ||
} | ||
|
||
variable "context" { | ||
type = "map" | ||
default = {} | ||
description = "Default context to use for passing state between label invocations" | ||
} | ||
|
||
variable "org_id" { | ||
default = "" | ||
description = "The numeric ID of the organization this project belongs to" | ||
} | ||
|
||
variable "folder_id" { | ||
default = "" | ||
description = "The numeric ID of the folder this project should be created under" | ||
} | ||
|
||
variable "enable_deletion_protection" { | ||
default = "false" | ||
description = "If true, the Terraform resource can be deleted without deleting the Project via the Google API." | ||
} | ||
|
||
variable "auto_create_network" { | ||
default = "true" | ||
description = "Create the 'default' network automatically" | ||
} |