File tree Expand file tree Collapse file tree 10 files changed +199
-16
lines changed
create-lines-of-code-report
infrastructure/terraform/components Expand file tree Collapse file tree 10 files changed +199
-16
lines changed Original file line number Diff line number Diff line change 3232 run : zip lines-of-code-report.json.zip lines-of-code-report.json
3333 - name : " Upload CLOC report as an artefact"
3434 if : ${{ !env.ACT }}
35- uses : actions/upload-artifact@v3
35+ uses : actions/upload-artifact@v4
3636 with :
3737 name : lines-of-code-report.json.zip
3838 path : ./lines-of-code-report.json.zip
Original file line number Diff line number Diff line change 3232 run : zip sbom-repository-report.json.zip sbom-repository-report.json
3333 - name : " Upload SBOM report as an artefact"
3434 if : ${{ !env.ACT }}
35- uses : actions/upload-artifact@v3
35+ uses : actions/upload-artifact@v4
3636 with :
3737 name : sbom-repository-report.json.zip
3838 path : ./sbom-repository-report.json.zip
4747 run : zip vulnerabilities-repository-report.json.zip vulnerabilities-repository-report.json
4848 - name : " Upload vulnerabilities report as an artefact"
4949 if : ${{ !env.ACT }}
50- uses : actions/upload-artifact@v3
50+ uses : actions/upload-artifact@v4
5151 with :
5252 name : vulnerabilities-repository-report.json.zip
5353 path : ./vulnerabilities-repository-report.json.zip
Original file line number Diff line number Diff line change 66 - name : " TFSec Scan - Components"
77 shell : bash
88 run : |
9- for component in $(find infrastructure/terraform/components -mindepth 1 -type d); do
10- scripts/terraform/tfsec.sh $component
11- done
12- - name : " TFSec Scan - Modules"
13- shell : bash
14- run : |
15- for module in $(find infrastructure/terraform/modules -mindepth 1 -type d); do
16- scripts/terraform/tfsec.sh $module
17- done
9+ components_exit_code=0
10+ modules_exit_code=0
11+
12+ ./scripts/terraform/tfsec.sh ./infrastructure/terraform/components || components_exit_code=$?
13+ ./scripts/terraform/tfsec.sh ./infrastructure/terraform/modules || modules_exit_code=$?
14+
15+ if [ $components_exit_code -ne 0 ] || [ $modules_exit_code -ne 0 ]; then
16+ echo "One or more TFSec scans failed."
17+ exit 1
18+ fi
Original file line number Diff line number Diff line change 1+ resource "aws_iam_policy" "github_deploy_overload" {
2+ name = " ${ local . csi } -github-deploy-overload"
3+ description = " Overloads the github permission to perform build actions for services in this account"
4+ policy = data. aws_iam_policy_document . github_deploy . json
5+ }
6+
7+ resource "aws_iam_role_policy_attachment" "github_deploy_overload" {
8+ role = local. bootstrap . iam_github_deploy_role [" name" ]
9+ policy_arn = aws_iam_policy. github_deploy_overload . arn
10+ }
11+
12+ # tfsec:ignore:aws-iam-no-policy-wildcards Policy voilation expected for CI user role
13+ data "aws_iam_policy_document" "github_deploy" {
14+ statement {
15+ effect = " Allow"
16+
17+ actions = [
18+ " grafana:*" ,
19+ ]
20+ resources = [" *" ]
21+ }
22+ }
Original file line number Diff line number Diff line change 1+ locals {
2+ bootstrap = data. terraform_remote_state . bootstrap . outputs
3+ }
4+
5+ data "terraform_remote_state" "bootstrap" {
6+ backend = " s3"
7+
8+ config = {
9+ bucket = local.terraform_state_bucket
10+
11+ key = format (
12+ " %s/%s/%s/%s/bootstrap.tfstate" ,
13+ var. project ,
14+ var. aws_account_id ,
15+ " eu-west-2" ,
16+ " bootstrap"
17+ )
18+
19+ region = " eu-west-2"
20+ }
21+ }
Original file line number Diff line number Diff line change 1+ locals {
2+ bootstrap = data. terraform_remote_state . bootstrap . outputs
3+ acct = data. terraform_remote_state . acct . outputs
4+ }
5+
6+ data "terraform_remote_state" "bootstrap" {
7+ backend = " s3"
8+
9+ config = {
10+ bucket = local.terraform_state_bucket
11+
12+ key = format (
13+ " %s/%s/%s/%s/bootstrap.tfstate" ,
14+ var. project ,
15+ var. aws_account_id ,
16+ " eu-west-2" ,
17+ " bootstrap"
18+ )
19+
20+ region = " eu-west-2"
21+ }
22+ }
23+
24+ data "terraform_remote_state" "acct" {
25+ backend = " s3"
26+
27+ config = {
28+ bucket = local.terraform_state_bucket
29+
30+ key = format (
31+ " %s/%s/%s/%s/acct.tfstate" ,
32+ var. project ,
33+ var. aws_account_id ,
34+ " eu-west-2" ,
35+ var. parent_acct_environment
36+ )
37+
38+ region = " eu-west-2"
39+ }
40+ }
Original file line number Diff line number Diff line change 1+ locals {
2+ terraform_state_bucket = format (
3+ " %s-tfscaffold-%s-%s" ,
4+ var. project ,
5+ var. aws_account_id ,
6+ var. region ,
7+ )
8+
9+ csi = replace (
10+ format (
11+ " %s-%s-%s" ,
12+ var. project ,
13+ var. environment ,
14+ var. component ,
15+ ),
16+ " _" ,
17+ " " ,
18+ )
19+
20+ # CSI for use in resources with a global namespace, i.e. S3 Buckets
21+ csi_global = replace (
22+ format (
23+ " %s-%s-%s-%s-%s" ,
24+ var. project ,
25+ var. aws_account_id ,
26+ var. region ,
27+ var. environment ,
28+ var. component ,
29+ ),
30+ " _" ,
31+ " " ,
32+ )
33+
34+ default_tags = merge (
35+ var. default_tags ,
36+ {
37+ Project = var.project
38+ Environment = var.environment
39+ Component = var.component
40+ Group = var.group
41+ Name = local.csi
42+ },
43+ )
44+ }
Original file line number Diff line number Diff line change 1- # Define the variables that will be initialised in etc/{env,versions}_<region>_<environment>.tfvars...
1+ # #
2+ # Basic Required Variables for tfscaffold Components
3+ # #
4+
5+ variable "project" {
6+ type = string
7+ description = " The name of the tfscaffold project"
8+ }
9+
10+ variable "environment" {
11+ type = string
12+ description = " The name of the tfscaffold environment"
13+ }
14+
15+ variable "aws_account_id" {
16+ type = string
17+ description = " The AWS Account ID (numeric)"
18+ }
19+
20+ variable "region" {
21+ type = string
22+ description = " The AWS Region"
23+ }
24+
25+ variable "group" {
26+ type = string
27+ description = " The group variables are being inherited from (often synonmous with account short-name)"
28+ }
29+
30+ # #
31+ # tfscaffold variables specific to this component
32+ # #
33+
34+ # This is the only primary variable to have its value defined as
35+ # a default within its declaration in this file, because the variables
36+ # purpose is as an identifier unique to this component, rather
37+ # then to the environment from where all other variables come.
38+ variable "component" {
39+ type = string
40+ description = " The variable encapsulating the name of this component"
41+ default = " examplecomponent"
42+ }
43+
44+ variable "default_tags" {
45+ type = map (string )
46+ description = " A map of default tags to apply to all taggable resources within the component"
47+ default = {}
48+ }
49+
50+ # #
51+ # Variables specific to the component
52+ # #
53+
54+ variable "log_retention_in_days" {
55+ type = number
56+ description = " The retention period in days for the Cloudwatch Logs events to be retained, default of 0 is indefinite"
57+ default = 0
58+ }
Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ terraform-sec: # TFSEC check against Terraform files - optional: terraform_dir|d
6161 --exclude-downloaded-modules \
6262 --tfvars-file infrastructure/terraform/etc/global.tfvars \
6363 --tfvars-file infrastructure/terraform/etc/env_eu-west-2_main.tfvars \
64- --config-file scripts/config/tfsec.yml
64+ --config-file scripts/config/tfsec.yaml
6565
6666# ==============================================================================
6767# Module tests and examples - please DO NOT edit this section!
Original file line number Diff line number Diff line change @@ -37,12 +37,10 @@ function run-tfsec-natively() {
3737
3838 echo " Running TFSec on directory: $dir_to_scan "
3939 tfsec \
40- --concise-output \
4140 --force-all-dirs \
4241 --exclude-downloaded-modules \
4342 --config-file scripts/config/tfsec.yaml \
4443 --format text \
45- --soft-fail \
4644 " $dir_to_scan "
4745
4846 check-tfsec-status
You can’t perform that action at this time.
0 commit comments