Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: New checkov version #12

Merged
merged 7 commits into from
Jan 10, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 0 additions & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:

env:
TERRAFORM_DOCS_VERSION: v0.16.0
# TFLINT_VERSION: v0.41.0 # use this version with "Invicton-Labs/deepmerge/null" module

jobs:
collectInputs:
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@ override.tf.json
# Include override files you do wish to add to version control using negated pattern
#
# !example_override.tf

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*
*tfplan*
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ repos:
args: ["."]

- repo: https://github.com/bridgecrewio/checkov.git
rev: "2.2.168" # Get the latest from: https://github.com/bridgecrewio/checkov/releases
rev: "2.2.246" # Get the latest from: https://github.com/bridgecrewio/checkov/releases
hooks:
- id: checkov
args: [--skip-check, "CKV2_GHA_1"] #Flase positive for top-level permissions

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.3.0" # Get the latest from: https://github.com/pre-commit/pre-commit-hooks/releases
Expand Down
6 changes: 6 additions & 0 deletions .tflint.hcl
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
config {
ignore_module = {
"Invicton-Labs/deepmerge/null" = true
}
}

rule "terraform_deprecated_interpolation" {
enabled = true
}
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ _Example usage of the module - terraform code snippet_

```terraform
module "template" {
source = "github.com/getindata/terraform-module-template"
source = "getindata/template/null"
# version = "x.x.x"

example_var = "foo"
}
Expand All @@ -48,7 +49,8 @@ _Additional information that should be made public, for ex. how to solve known i

## EXAMPLES

- [Full example](examples/full-example)
- [Simple](examples/simple) - Basic usage of the module
- [Complete](examples/complete) - Advanced usage of the module

<!-- BEGIN_TF_DOCS -->

Expand Down Expand Up @@ -101,7 +103,7 @@ _Additional information that should be made public, for ex. how to solve known i

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.0 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.15.0 |
| <a name="requirement_null"></a> [null](#requirement\_null) | 3.1.1 |

## Resources
Expand Down
Empty file added examples/complete/.env.dist
Empty file.
2 changes: 2 additions & 0 deletions examples/complete/.envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#Override defaults
command -v dotenv && test -f .env && dotenv
11 changes: 11 additions & 0 deletions examples/complete/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
init:
terraform init

plan:
terraform plan -var-file fixtures.tfvars -out tfplan

apply:
terraform apply tfplan

destroy:
terraform destroy -var-file fixtures.tfvars
17 changes: 17 additions & 0 deletions examples/complete/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Complete Example

```terraform
module "terraform_module_template" {
source = "../../"
context = module.this.context

example_var = "This is a example value."
}
```

## Usage
```
terraform init
terraform plan -var-file fixtures.tfvars -out tfplan
terraform apply tfplan
```
File renamed without changes.
7 changes: 7 additions & 0 deletions examples/complete/fixtures.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
descriptor_formats = {

}

tags = {
Terraform = "True"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = ">= 0.13.0"
required_version = ">= 0.15.0"

required_providers {
null = {
Expand Down
Empty file added examples/simple/.env.dist
Empty file.
2 changes: 2 additions & 0 deletions examples/simple/.envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#Override defaults
command -v dotenv && test -f .env && dotenv
maciejmacq-dev marked this conversation as resolved.
Show resolved Hide resolved
11 changes: 11 additions & 0 deletions examples/simple/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
init:
terraform init

plan:
terraform plan -out tfplan

apply:
terraform apply tfplan

destroy:
terraform destroy
16 changes: 16 additions & 0 deletions examples/simple/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Simple Example

```terraform
module "terraform_module_template" {
source = "../../"

example_var = "This is a example value."
}
```

## Usage
```
terraform init
terraform plan -out tfplan
terraform apply tfplan
```
5 changes: 5 additions & 0 deletions examples/simple/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module "terraform_module_template" {
source = "../../"

example_var = "This is a example value."
}
4 changes: 4 additions & 0 deletions examples/simple/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
output "example_output" {
description = "Example output of the module"
value = module.terraform_module_template
}
3 changes: 3 additions & 0 deletions examples/simple/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
provider "null" {
# Configuration options
}
10 changes: 10 additions & 0 deletions examples/simple/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
terraform {
required_version = ">= 0.15.0"

required_providers {
null = {
source = "hashicorp/null"
version = "3.1.1"
}
}
}
4 changes: 3 additions & 1 deletion locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ locals {
# Get a name from the descriptor. If not available, use default naming convention.
# Trim and replace function are used to avoid bare delimiters on both ends of the name and situation of adjacent delimiters.
name_from_descriptor = trim(replace(
lookup(module.this.descriptors, "module-resource-name", module.this.id), "/${module.this.delimiter}${module.this.delimiter}+/", ""
lookup(module.this.descriptors, "module-resource-name", module.this.id), "/${module.this.delimiter}${module.this.delimiter}+/", module.this.delimiter
), module.this.delimiter)

enabled = module.this.enabled
}
2 changes: 2 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# echoes it's base64 encoded version locally

resource "null_resource" "output_input" {
count = local.enabled ? 1 : 0

triggers = {
name = local.name_from_descriptor
input = var.example_var
Expand Down
2 changes: 1 addition & 1 deletion outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

output "example_output" {
description = "Example output of the module"
value = var.example_var
value = one(null_resource.output_input[*].id)
}
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Example configuration of terraform providers

terraform {
required_version = ">= 0.13.0"
required_version = ">= 0.15.0"

required_providers {
null = {
Expand Down