Skip to content

Commit bb25820

Browse files
feat: Added workflow for cloudformation linter and security scan (#83)
1 parent ebc9389 commit bb25820

File tree

5 files changed

+55
-3
lines changed

5 files changed

+55
-3
lines changed

.github/workflows/cf-lint.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
name: cloudformation-linter
3+
on:
4+
workflow_call:
5+
inputs:
6+
cf_file_path:
7+
required: true
8+
type: string
9+
description: 'path of cloudformation template.'
10+
11+
jobs:
12+
cloudformation-linter:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: cfn-lint-action
20+
uses: ScottBrenner/cfn-lint-action@v2
21+
with:
22+
command: cfn-lint -t ${{ inputs.cf_file_path }}
23+
24+
- name: cfn security checks
25+
uses: minchao/[email protected]
26+
with:
27+
args: '--input-path ${{ inputs.cf_file_path }}'
28+
...

.github/workflows/terraform_workflow.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ on:
4242
type: number
4343
default: 10
4444
description: 'Timeout for approval step'
45+
minimum-approvals:
46+
required: false
47+
type: string
48+
default: 1
49+
description: 'Minimum approvals required to accept the plan'
4550
secrets:
4651
AZURE_CREDENTIALS:
4752
required: false
@@ -73,6 +78,9 @@ on:
7378
SPACES_SECRET_ACCESS_KEY:
7479
required: false
7580
description: 'Spaces secret access key for digitalocean if required'
81+
TF_VAR_access_token:
82+
required: false
83+
description: 'TF var access token'
7684

7785
jobs:
7886
terraform-workflow:
@@ -82,6 +90,8 @@ jobs:
8290
DIGITALOCEAN_TOKEN: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
8391
SPACES_ACCESS_KEY_ID: ${{ secrets.SPACES_ACCESS_KEY_ID }}
8492
SPACES_SECRET_ACCESS_KEY: ${{ secrets.SPACES_SECRET_ACCESS_KEY }}
93+
TF_VAR_access_token: ${{ secrets.TF_VAR_access_token }}
94+
8595
outputs:
8696
tfplanExitCode: ${{ steps.tf-plan.outputs.exitcode }}
8797

@@ -193,6 +203,7 @@ jobs:
193203
with:
194204
secret: ${{ github.TOKEN }}
195205
approvers: ${{ inputs.approvers }}
206+
minimum-approvals: ${{ inputs.minimum-approvals }}
196207
issue-title: "Terraform Plan for Infrastructure Update"
197208

198209
- name: terraform apply
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
name: YAML-LINTER
3+
on: [pull_request]
4+
5+
jobs:
6+
YAML-LINTER:
7+
uses: clouddrove/github-shared-workflows/.github/workflows/ymllint.yml@master
8+
...

.github/workflows/ymllint.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
2-
name: Yaml Lint
3-
on: [pull_request]
2+
name: YAML-LINTER
3+
on:
4+
workflow_call:
45
jobs:
56
Yaml-Lint:
67
runs-on: ubuntu-latest
@@ -41,7 +42,7 @@ jobs:
4142
empty-lines:
4243
level: error
4344
empty-values:
44-
level: error
45+
level: warning
4546
float-values:
4647
level: error
4748
hyphens:

docs/terraform_workflow.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
var_file: # name of tfvar file e.g "variable.tfvar"
2424
aws_region: # specify region eg. us-east-2
2525
approvers: # Assignee name for approve apply or destroy step
26+
minimum-approvals: # Minimum number of approvals required to progress the workflow, deafault value is 1
2627
terraform_version: # Specify terraform version e.g 1.3.6
2728
destroy: # If the value is set to true, the workflow proceeds to the destroy step. However, the default value is false
2829
secrets:
@@ -49,6 +50,7 @@ jobs:
4950
working_directory: # Specify terraform code directory in repo
5051
var_file: # Name of tfvar file e.g "variable.tfvar"
5152
approvers: # Assignee name for approve apply or destroy step
53+
minimum-approvals: # Minimum number of approvals required to progress the workflow, deafault value is 1
5254
terraform_version: # Specify terraform version e.g 1.3.6
5355
destroy: # If the value is set to true, the workflow proceeds to the destroy step. However, the default value is false
5456
secrets:
@@ -72,6 +74,7 @@ jobs:
7274
working_directory: # Specify terraform code directory in repo
7375
var_file: # Name of tfvar file e.g "variable.tfvar"
7476
approvers: # Assignee name for approve apply or destroy step
77+
minimum-approvals: # Minimum number of approvals required to progress the workflow, deafault value is 1
7578
terraform_version: # Specify terraform version e.g 1.3.6
7679
destroy: # If the value is set to true, the workflow proceeds to the destroy step. However, the default value is false
7780
secrets:
@@ -97,6 +100,7 @@ jobs:
97100
working_directory: # Specify terraform code directory in repo
98101
var_file: # Name of tfvar file e.g "variable.tfvar"
99102
approvers: # Assignee name for approve apply or destroy step
103+
minimum-approvals: # Minimum number of approvals required to progress the workflow, deafault value is 1
100104
terraform_version: # Specify terraform version e.g 1.3.6
101105
destroy: # If the value is set to true, the workflow proceeds to the destroy step. However, the default value is false
102106
secrets:

0 commit comments

Comments
 (0)