Skip to content

Commit 5b44e67

Browse files
authored
Merge pull request #2 from linuxtips/adicionar_pipeline
fix: precisamos da pipeline para checar o PR
2 parents bdb20ec + b8433cd commit 5b44e67

13 files changed

+237
-5
lines changed

Diff for: .github/workflows/terraform-fmt.yaml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: terraform-fmt
2+
on:
3+
pull_request:
4+
5+
permissions:
6+
id-token: write
7+
contents: read
8+
9+
jobs:
10+
terraform-fmt:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Setup Terraform
18+
uses: hashicorp/setup-terraform@v3
19+
with:
20+
terraform_version: "1.5.5"
21+
22+
- name: Terraform Format
23+
run: terraform fmt -check -recursive -diff
24+

Diff for: .github/workflows/terratests.yaml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: terratest
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
ref:
7+
description: "The branch to run tests from"
8+
default: "main"
9+
required: true
10+
type: string
11+
12+
env:
13+
AWS_REGION: us-east-1
14+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
15+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
16+
17+
concurrency:
18+
group: terratest
19+
20+
permissions:
21+
id-token: write
22+
contents: read
23+
pull-requests: write
24+
25+
jobs:
26+
terratest:
27+
runs-on: ubuntu-latest
28+
environment: production
29+
steps:
30+
- uses: actions/checkout@v4
31+
32+
- uses: actions/setup-go@v5
33+
with:
34+
go-version-file: 'go.mod'
35+
check-latest: true
36+
cache-dependency-path: |
37+
go.sum
38+
39+
- name: Install Terraform
40+
uses: hashicorp/setup-terraform@v3
41+
with:
42+
terraform_version: "1.7.1"
43+
44+
- name: Run terratest only on changed modules
45+
run: |
46+
echo "###### running terratest on module #####"
47+
go test -v tests/*.go -timeout 60m

Diff for: .github/workflows/tflint.yaml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: tflint
2+
on:
3+
pull_request:
4+
5+
permissions:
6+
id-token: write
7+
contents: read
8+
9+
jobs:
10+
tflint:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
name: Checkout source code
16+
17+
- uses: terraform-linters/setup-tflint@v4
18+
name: Setup TFLint
19+
with:
20+
tflint_version: v0.44.1
21+
22+
- name: tflint init
23+
run: tflint --init
24+
25+
- name: Run TFLint
26+
run: tflint --recursive --config "$(pwd)/.tflint.hcl"

Diff for: .github/workflows/tfsec.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
6+
name: tfsec
7+
8+
on:
9+
push:
10+
branches: [ "main" ]
11+
pull_request:
12+
branches: [ "main" ]
13+
schedule:
14+
- cron: '32 14 * * 6'
15+
16+
permissions:
17+
actions: read
18+
contents: read
19+
security-events: write
20+
21+
jobs:
22+
tfsec:
23+
name: Run tfsec sarif report
24+
runs-on: ubuntu-latest
25+
26+
27+
steps:
28+
- name: Clone repo
29+
uses: actions/checkout@v4
30+
31+
- name: Run tfsec
32+
uses: aquasecurity/tfsec-sarif-action@21ded20e8ca120cd9d3d6ab04ef746477542a608
33+
with:
34+
sarif_file: tfsec.sarif
35+
36+
- name: Upload SARIF file
37+
uses: github/codeql-action/upload-sarif@v2
38+
with:
39+
# Path to SARIF file relative to the root of the repository
40+
sarif_file: tfsec.sarif

Diff for: .tflint.hcl

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
plugin "aws" {
2+
enabled = true
3+
version = "0.33.0"
4+
source = "github.com/terraform-linters/tflint-ruleset-aws"
5+
}

Diff for: backend.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
terraform {
2-
backend "s3" {}
2+
backend "s3" {}
33
}

Diff for: examples/.terraform.lock.hcl

+45
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: examples/main.tf

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module "EKS" {
2+
source = "../"
3+
4+
team = "platform"
5+
project = "containers"
6+
cluster_name = "production"
7+
name = "giropops"
8+
}

Diff for: examples/providers.tf

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
terraform {
2+
required_version = ">= 1.5"
3+
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
version = ">= 5.0"
8+
}
9+
}
10+
}
11+
12+
provider "aws" {
13+
region = "us-east-1"
14+
}

Diff for: provider.tf

+5
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@ provider "aws" {
33
}
44

55
terraform {
6+
required_version = "1.5.5"
67
required_providers {
78
aws = {
89
source = "hashicorp/aws"
910
version = "~> 5.0"
1011
}
12+
tls = {
13+
source = "hashicorp/tls"
14+
version = "4.0.6"
15+
}
1116
}
1217
}

Diff for: subnets.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ resource "aws_subnet" "public_subnets" {
99
tags = merge(
1010
var.tags,
1111
{
12-
Name = "${var.name}-public-${var.availability_zones[count.index]}"
13-
"kubernetes.io/role/elb" = "1"
12+
Name = "${var.name}-public-${var.availability_zones[count.index]}"
13+
"kubernetes.io/role/elb" = "1"
1414
"kubernetes.io/cluster/${var.cluster_name}" = "owned"
1515
}
1616
)

Diff for: tests/eks_test.go

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/gruntwork-io/terratest/modules/terraform"
7+
)
8+
9+
func TestEKSExample(t *testing.T) {
10+
11+
terraformOptions := terraform.WithDefaultRetryableErrors(t, &terraform.Options{
12+
TerraformDir: "../examples",
13+
})
14+
15+
defer terraform.Destroy(t, terraformOptions)
16+
17+
terraform.InitAndApply(t, terraformOptions)
18+
}

Diff for: variables.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ variable "node_capacity_type" {
8383
variable "node_labels" {
8484
description = "Key-value mapping of labels for the node group"
8585
type = map(string)
86-
default = {
86+
default = {
8787
role = "general"
8888
}
8989
}
@@ -119,5 +119,5 @@ variable "project" {
119119
variable "node_ami_type" {
120120
description = "AMI ID for worker nodes"
121121
type = string
122-
default = "ami-XXXXXXXXXXXXXXXXX"
122+
default = "AL2_x86_64"
123123
}

0 commit comments

Comments
 (0)