Skip to content

Commit 31f1dcf

Browse files
authored
Added pre-commit hook (#11)
* Added pre-commit hook pre-commit fixes * pre-commit run fixes
1 parent d199a70 commit 31f1dcf

File tree

15 files changed

+91
-160
lines changed

15 files changed

+91
-160
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ about: If something isn't working as expected.
2121
...version and build of the project, OS and runtime versions, virtualised environment (if any), etc. ...
2222

2323
### Additional Context:
24-
...add any other context about the problem here. If applicable, add screenshots to help explain...
24+
...add any other context about the problem here. If applicable, add screenshots to help explain...

.github/workflows/ci.yaml

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,19 @@ on:
1010
workflow_dispatch:
1111

1212
jobs:
13+
pre-commit:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
- uses: actions/setup-python@v3
18+
- uses: terraform-linters/setup-tflint@v3
19+
- uses: pre-commit/action@v3.0.0
20+
with:
21+
extra_args: "-a"
22+
1323
validate:
1424
name: Validate
25+
needs: [pre-commit]
1526
runs-on: ubuntu-latest
1627
permissions:
1728
pull-requests: write
@@ -50,50 +61,26 @@ jobs:
5061
terraform init -backend=false -upgrade -reconfigure
5162
terraform validate
5263
53-
tflint:
54-
name: tflint
55-
runs-on: ubuntu-latest
56-
permissions:
57-
pull-requests: write
58-
needs: [validate]
59-
steps:
60-
- name: Checkout code
61-
uses: actions/checkout@v3
62-
- uses: actions/cache@v3
63-
name: Cache plugin dir
64-
with:
65-
path: ~/.tflint.d/plugins
66-
key: ${{ runner.os }}-tflint
67-
- uses: terraform-linters/setup-tflint@v3
68-
name: Setup TFLint
69-
with:
70-
github_token: ${{ github.token }}
71-
tflint_version: latest
72-
- name: Run TFLint
73-
run: |
74-
tflint --init
75-
tflint -f compact
76-
7764
tfsec:
7865
name: tfsec
7966
runs-on: ubuntu-latest
8067
permissions:
8168
pull-requests: write
8269
needs: [validate]
8370
steps:
84-
- name: Checkout code
85-
uses: actions/checkout@v3
86-
- name: tfsec
87-
uses: aquasecurity/tfsec-action@v1.0.2
88-
with:
89-
additional_args: "--force-all-dirs --concise-output --code-theme=dark"
90-
version: "latest"
71+
- name: Checkout code
72+
uses: actions/checkout@v3
73+
- name: tfsec
74+
uses: aquasecurity/tfsec-action@v1.0.2
75+
with:
76+
additional_args: "--force-all-dirs --concise-output --code-theme=dark"
77+
version: "latest"
9178

9279
caller-identity-check:
9380
if: contains(github.event_name, 'pull_request')
9481
runs-on: ubuntu-latest
9582
name: Return the IAM user
96-
needs: [validate, tflint, tfsec]
83+
needs: [validate, tfsec]
9784
permissions:
9885
contents: read
9986
id-token: write

.pre-commit-config.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
repos:
2+
- repo: https://github.com/antonbabenko/pre-commit-terraform
3+
rev: v1.77.0
4+
hooks:
5+
- id: terraform_fmt
6+
- id: terraform_tflint
7+
- id: terraform_validate
8+
- repo: https://github.com/pre-commit/pre-commit-hooks
9+
rev: v4.4.0
10+
hooks:
11+
- id: check-case-conflict
12+
- id: check-merge-conflict
13+
- id: check-vcs-permalinks
14+
- id: check-yaml
15+
- id: end-of-file-fixer
16+
- id: trailing-whitespace

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,4 @@ Project maintainers who do not follow or enforce the Code of Conduct in good fai
6262
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
6363

6464
[homepage]: http://contributor-covenant.org
65-
[version]: http://contributor-covenant.org/version/1/4/
65+
[version]: http://contributor-covenant.org/version/1/4/

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This Terraform module enables you to configure GitLab Actions as an AWS IAM OIDC
77

88
- AWS Account(s) and credentials
99
- GitLab repository
10-
- Terraform >= 1.0.x
10+
- Terraform >= 1.x
1111
- Profit?
1212

1313
## Deployment / Usage

TERRAFORM.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
| Name | Version |
44
|------|---------|
5-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | ~> 1.0 |
5+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | ~> 1 |
66
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4 |
77
| <a name="requirement_tls"></a> [tls](#requirement\_tls) | >= 4 |
88

99
## Providers
1010

1111
| Name | Version |
1212
|------|---------|
13-
| <a name="provider_aws"></a> [aws](#provider\_aws) | 4.46.0 |
13+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 4.47.0 |
1414
| <a name="provider_tls"></a> [tls](#provider\_tls) | 4.0.4 |
1515

1616
## Modules

exmaples/complete/main.tf

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ provider "aws" {
55
module "gitlab_oidc" {
66
source = "../../"
77

8-
attach_admin_policy = true
9-
attach_read_only_policy = true
10-
create_oidc_provider = true
11-
enabled = true
12-
force_detach_policies = false
8+
attach_admin_policy = var.attach_admin_policy
9+
attach_read_only_policy = var.attach_read_only_policy
10+
create_oidc_provider = var.create_oidc_provider
11+
enabled = var.enabled
12+
force_detach_policies = var.force_detach_policies
1313
gitlab_organisation = var.gitlab_organisation
14-
gitlab_repositories = [{ name = "terraform-aws-gitlab-oidc", branches = ["main", "pr-*", "*pull*", "*"] }]
15-
iam_role_name = "gitlab-runner"
16-
iam_role_path = "/"
17-
iam_role_permissions_boundary = ""
18-
iam_role_policy_arns = []
19-
max_session_duration = 3600
20-
tags = {}
21-
url = "gitlab.com"
22-
}
14+
gitlab_repositories = var.gitlab_repositories
15+
iam_role_name = var.iam_role_name
16+
iam_role_path = var.iam_role_path
17+
iam_role_permissions_boundary = var.iam_role_permissions_boundary
18+
iam_role_policy_arns = var.iam_role_policy_arns
19+
max_session_duration = var.max_session_duration
20+
tags = var.tags
21+
url = var.url
22+
}

exmaples/complete/outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ output "thumbprint" {
88
description = "GitLab certificates thumbprint"
99
value = module.gitlab_oidc.thumbprint
1010
sensitive = false
11-
}
11+
}

exmaples/complete/terraform.tfvars

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ enabled = true
55
force_detach_policies = false
66
gitlab_organisation = "saidsef"
77
gitlab_repositories = [
8-
{
9-
"branches" : null,
10-
"name" : null
8+
{ name = "terraform-aws-gitlab-oidc",
9+
branches = ["main", "pr-*", "*pull*", "*"]
1110
}
1211
]
1312
iam_role_name = "gitlab-runner"

exmaples/complete/versions.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
terraform {
2+
required_providers {
3+
aws = {
4+
source = "hashicorp/aws"
5+
version = ">= 4"
6+
}
7+
8+
tls = {
9+
source = "hashicorp/tls"
10+
version = ">= 4"
11+
}
12+
}
13+
14+
required_version = "~> 1"
15+
}

0 commit comments

Comments
 (0)