Skip to content
Closed
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/tf-fmt-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: tfactions
on:
push:
branches:
- main
pull_request:
jobs:
tfactions:
name: tfactions
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- uses: hashicorp/setup-terraform@v3
with:
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}

- name: Terraform fmt
id: fmt
run: terraform fmt -check
continue-on-error: true
22 changes: 17 additions & 5 deletions .github/workflows/tfsec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,25 @@ on:
pull_request:
jobs:
tfsec:
name: tfsec
name: tfsec sarif report
runs-on: ubuntu-latest

permissions:
actions: read
contents: read
security-events: write
steps:
- name: Clone repo
uses: actions/checkout@master
uses: actions/checkout@v2
with:
persist-credentials: false

- name: tfsec
uses: aquasecurity/tfsec-action@v1.0.0
uses: aquasecurity/tfsec-sarif-action@v0.1.0
with:
sarif_file: tfsec.sarif

- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v1
with:
soft_fail: true
# Path to SARIF file relative to the root of the repository
sarif_file: tfsec.sarif
25 changes: 25 additions & 0 deletions .terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,0 +1,7 @@
resource "aws_s3_bucket" "my_bucket" {
bucket = "test-bucket-42353242213123"
tags = {
Name = "MyS3Bucket"
Environment = "Dev"
}
}
Comment on lines +1 to +7

Check failure

Code scanning / defsec

S3 Access block should block public ACL Error

No public access block so not blocking public acls
Comment on lines +1 to +7

Check failure

Code scanning / defsec

S3 Access block should block public policy Error

No public access block so not blocking public policies
Comment on lines +1 to +7

Check failure

Code scanning / defsec

Unencrypted S3 bucket. Error

Bucket does not have encryption enabled
Comment on lines +1 to +7

Check warning

Code scanning / defsec

S3 Bucket does not have logging enabled. Warning

Bucket does not have logging enabled
Comment on lines +1 to +7

Check warning

Code scanning / defsec

S3 Data should be versioned Warning

Bucket does not have versioning enabled
Comment on lines +1 to +7

Check failure

Code scanning / defsec

S3 encryption should use Customer Managed Keys Error

Bucket does not encrypt data with a customer managed key.
Comment on lines +1 to +7

Check failure

Code scanning / defsec

S3 Access Block should Ignore Public Acl Error

No public access block so not ignoring public acls
Comment on lines +1 to +7

Check failure

Code scanning / defsec

S3 Access block should restrict public bucket to limit access Error

No public access block so not restricting public buckets
Comment on lines +1 to +7

Check notice

Code scanning / defsec

S3 buckets should each define an aws_s3_bucket_public_access_block Note

Bucket does not have a corresponding public access block.
2 changes: 1 addition & 1 deletion provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ provider "aws" {
allowed_account_ids = [var.aws_account]

assume_role {
role_arn = "arn:aws:iam::${var.aws_account}:role/svc_terraform"
role_arn = "arn:aws:iam::${var.aws_account}:role/terraform-service"
session_name = "Terraform"
}

Expand Down
13 changes: 13 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
variable "name" {
type = string
}

variable "region" {
description = "AWS region to create resources in"
type = string
default = "us-east-1"
}

variable "aws_account" {
description = "Account number to create AWS resources in. This variable should be defined in the Terraform Cloud workspace settings"
}
Loading