Skip to content

Commit 6c83a5b

Browse files
authored
refactor: switch to CP null-label, add new functional (#10)
1 parent f8b1f37 commit 6c83a5b

20 files changed

+551
-141
lines changed

.github/CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @SweetOps

.github/ISSUE_TEMPLATE/bug_report.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: bug
6+
assignees: SweetOps
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior.
15+
16+
**Expected behavior**
17+
A clear and concise description of what you expected to happen.
18+
19+
**Screenshots**
20+
If applicable, add screenshots to help explain your problem.
21+
22+
**Terraform version**
23+
Output of command:
24+
```sh
25+
terraform version
26+
```
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: 'feature'
6+
assignees: 'SweetOps'
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.

.github/main.workflow

-56
This file was deleted.

.github/workflows/docs.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Generate terraform docs
2+
on:
3+
- pull_request
4+
jobs:
5+
docs:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v2
9+
with:
10+
ref: ${{ github.event.pull_request.head.ref }}
11+
12+
- name: main docs
13+
uses: Dirrk/[email protected]
14+
with:
15+
tf_docs_working_dir: .
16+
tf_docs_output_file: README.md
17+
tf_docs_output_method: inject
18+
tf_docs_git_push: 'true'
19+
tf_docs_args: '--sort-inputs-by-required'
20+
21+
- name: basic example docs
22+
uses: Dirrk/[email protected]
23+
with:
24+
tf_docs_working_dir: ./examples/basic/
25+
tf_docs_output_file: README.md
26+
tf_docs_output_method: inject
27+
tf_docs_git_push: 'true'
28+
tf_docs_args: '--sort-inputs-by-required'

.github/workflows/pr-lint.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Lint PR
2+
on:
3+
pull_request:
4+
types:
5+
- opened
6+
- reopened
7+
- edited
8+
- synchronize
9+
10+
jobs:
11+
main:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Lint PR
16+
uses: aslafy-z/conventional-pr-title-action@master
17+
with:
18+
preset: conventional-changelog-angular@^5.0.6
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
22+
- name: Comment for PR title conformance
23+
if: failure()
24+
uses: peter-evans/create-or-update-comment@v1
25+
with:
26+
issue-number: ${{tojson(github.event.number)}}
27+
body: |
28+
Please ensure your PR conforms to conventional commits (see https://www.conventionalcommits.org).
29+
30+
Commits MUST be prefixed with a type, which consists of one of the following:
31+
32+
* **build**: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
33+
* **ci**: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
34+
* **docs**: Documentation only changes
35+
* **feat**: A new feature
36+
* **fix**: A bug fix
37+
* **perf**: A code change that improves performance
38+
* **refactor**: A code change that neither fixes a bug nor adds a feature
39+
* **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
40+
* **test**: Adding missing tests or correcting existing tests

.github/workflows/release.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Release
2+
on:
3+
push:
4+
tags:
5+
- "v*"
6+
jobs:
7+
release-notary:
8+
name: Release-notary
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Check out code
12+
uses: actions/checkout@v2
13+
14+
- name: Release Notary Action
15+
uses: commitsar-app/[email protected]
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/terraform.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: 'Validate TF manifests'
2+
on:
3+
- pull_request
4+
jobs:
5+
terraform:
6+
name: Terraform
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout
10+
uses: actions/checkout@v2
11+
12+
- name: Terraform
13+
uses: hashicorp/setup-terraform@v1
14+
with:
15+
terraform_version: 0.14.7
16+
17+
- name: Terraform Format
18+
run: terraform fmt
19+
20+
- name: Terraform Init
21+
run: terraform init
22+
23+
- name: Terraform Validate
24+
run: terraform validate -no-color
25+
26+
- name: tflint
27+
uses: reviewdog/action-tflint@master
28+
with:
29+
github_token: ${{ secrets.github_token }}
30+
reporter: github-pr-review
31+
fail_on_error: "true"
32+
filter_mode: "nofilter"
33+
flags: "--module"

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Compiled files
22
*.tfstate
33
*.tfstate.backup
4+
.terraform.lock.hcl
45

56
# Module directory
67
.terraform/

.goreleaser.yml

-17
This file was deleted.

.goreleaser/main.go

-4
This file was deleted.

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2017-2019 Vladimir Syromyatnikov
189+
Copyright 2017-2021 Vladimir Syromyatnikov
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

README.md

+58-19
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,75 @@
11
# terraform-google-service-account
2-
Terraform module : GCP : for creation service account.
2+
3+
Terraform module to provision service account with normalized name.
34

45
## Usage
56

67
```terraform
7-
module "s3_service_account" {
8-
source = "git::https://github.com/SweetOps/terraform-google-service-account.git?ref=master"
8+
module "service_account" {
9+
source = "git::https://github.com/SweetOps/terraform-google-service-account.git?ref=master"
910
name = "awesome"
1011
stage = "production"
1112
namespace = "sweetops"
1213
}
1314
```
1415

16+
<!--- BEGIN_TF_DOCS --->
17+
## Requirements
18+
19+
| Name | Version |
20+
|------|---------|
21+
| terraform | >= 0.13 |
22+
| google | >= 3.0 |
23+
24+
## Providers
25+
26+
| Name | Version |
27+
|------|---------|
28+
| google | >= 3.0 |
1529

1630
## Inputs
1731

18-
| Name | Description | Type | Default | Required |
19-
|:------------|:------------------------------------------------------------------------------------------------|:------:|:--------:|:--------:|
20-
| name | Solution name, e.g. 'app' or 'jenkins' | string | n/a | yes |
21-
| namespace | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | string | n/a | yes |
22-
| stage | Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release' | string | n/a | yes |
23-
| attributes | Additional attributes (e.g. `1`) | list | `[]` | no |
24-
| delimiter | Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes` | string | `"-"` | no |
25-
| enabled | Set to false to prevent the module from creating any resources | string | `"true"` | no |
26-
| environment | Environment, e.g. 'prod', 'staging', 'dev', 'pre-prod', 'UAT' | string | `""` | no |
27-
| project | The project in which the resource belongs. If it is not provided, the provider project is used. | string | `""` | no |
28-
| tags | Additional tags (e.g. `map('BusinessUnit','XYZ')` | map | `{}` | no |
32+
| Name | Description | Type | Default | Required |
33+
|------|-------------|------|---------|:--------:|
34+
| additional\_tag\_map | Additional tags for appending to tags\_as\_list\_of\_maps. Not added to `tags`. | `map(string)` | `{}` | no |
35+
| attributes | Additional attributes (e.g. `1`) | `list(string)` | `[]` | no |
36+
| context | Single object for setting entire context at once.<br>See description of individual variables for details.<br>Leave string and numeric variables as `null` to use default value.<br>Individual variable settings (non-null) override settings in context object,<br>except for attributes, tags, and additional\_tag\_map, which are merged. | `any` | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_key_case": null,<br> "label_order": [],<br> "label_value_case": null,<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {}<br>}</pre> | no |
37+
| create\_service\_account\_key | Whether to create service account key | `bool` | `true` | no |
38+
| delimiter | Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes`.<br>Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no |
39+
| description | A text description of the service account. | `string` | `"Managed by Terraform"` | no |
40+
| enabled | Set to false to prevent the module from creating any resources | `bool` | `null` | no |
41+
| environment | Environment, e.g. 'uw2', 'us-west-2', OR 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no |
42+
| id\_length\_limit | Limit `id` to this many characters (minimum 6).<br>Set to `0` for unlimited length.<br>Set to `null` for default, which is `0`.<br>Does not affect `id_full`. | `number` | `null` | no |
43+
| keepers | Arbitrary map of values that, when changed, will trigger a new key to be generated. | `map(string)` | `null` | no |
44+
| key\_algorithm | The algorithm used to generate the key. Possible values: `KEY_ALG_UNSPECIFIED`, `KEY_ALG_RSA_1024`, `KEY_ALG_RSA_2048` | `string` | `"KEY_ALG_RSA_2048"` | no |
45+
| label\_key\_case | The letter case of label keys (`tag` names) (i.e. `name`, `namespace`, `environment`, `stage`, `attributes`) to use in `tags`.<br>Possible values: `lower`, `title`, `upper`.<br>Default value: `title`. | `string` | `"lower"` | no |
46+
| label\_order | The naming order of the id output and Name tag.<br>Defaults to ["namespace", "environment", "stage", "name", "attributes"].<br>You can omit any of the 5 elements, but at least one must be present. | `list(string)` | `null` | no |
47+
| label\_value\_case | The letter case of output label values (also used in `tags` and `id`).<br>Possible values: `lower`, `title`, `upper` and `none` (no transformation).<br>Default value: `lower`. | `string` | `null` | no |
48+
| name | Solution name, e.g. 'app' or 'jenkins' | `string` | `null` | no |
49+
| namespace | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | `string` | `null` | no |
50+
| private\_key\_type | The output format of the private key. | `string` | `"TYPE_GOOGLE_CREDENTIALS_FILE"` | no |
51+
| project | The project in which the resource belongs. If it is not provided, the provider project is used. | `string` | `null` | no |
52+
| public\_key\_data | Public key data to create a service account key for given service account. The expected format for this field is a base64 encoded X509\_PEM and it conflicts with `public_key_type` and `private_key_type`. | `string` | `null` | no |
53+
| public\_key\_type | The output format of the public key requested. | `string` | `"TYPE_X509_PEM_FILE"` | no |
54+
| regex\_replace\_chars | Regex to replace chars with empty string in `namespace`, `environment`, `stage` and `name`.<br>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no |
55+
| roles | The list of roles that should be applied to service account. | `list(string)` | `[]` | no |
56+
| stage | Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no |
57+
| tags | Additional tags (e.g. `map('BusinessUnit','XYZ')` | `map(string)` | `{}` | no |
2958

3059
## Outputs
3160

32-
| Name | Description |
33-
|:----------|:-------------------------------------------------|
34-
| email | The e-mail address of the service account. |
35-
| name | The fully-qualified name of the service account. |
36-
| unique_id | The unique id of the service account. |
61+
| Name | Description |
62+
|------|-------------|
63+
| email | The e-mail address of the service account. |
64+
| id | The id of the service account. |
65+
| key\_id | The id of the service account key. |
66+
| key\_name | The name of the service account key. |
67+
| name | The fully-qualified name of the service account. |
68+
| private\_key | The private key in JSON format, base64 encoded. |
69+
| public\_key | The public key, base64 encoded. |
70+
| unique\_id | The unique id of the service account. |
71+
72+
<!--- END_TF_DOCS --->
73+
74+
## License
75+
The Apache-2.0 license

0 commit comments

Comments
 (0)