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

feat: (IAC-1078) Linting Updates and Code Formatting #235

Merged
merged 6 commits into from
Sep 29, 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
13 changes: 10 additions & 3 deletions .github/workflows/linter-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Linter Analysis

on:
push:
branches: ['*'] # '*' will cause the workflow to run on all commits to all branches.
branches: [ '**' ] # '**' will cause the workflow to run on all commits to all branches, including those with path separators

jobs:
# Hadolint: Job-1
Expand Down Expand Up @@ -54,8 +54,15 @@ jobs:
tflint_version: latest
github_token: ${{ secrets.LINTER_TEST_TOKEN }}

# Necessary so we can recursively tflint our modules folder
# with the plugin, not needed for regular project use.
- name: Initializing modules
run: |
terraform -chdir=modules/aws_autoscaling init
terraform -chdir=modules/aws_ebs_csi init

- name: Initializing TFLint
run: TFLINT_LOG=info tflint --init -c .tflint.hcl
run: TFLINT_LOG=info tflint --init -c "$(pwd)/linting-configs/.tflint.hcl"

- name: Run TFLint Action
run: TFLINT_LOG=info tflint -c .tflint.hcl
run: TFLINT_LOG=info tflint -c "$(pwd)/linting-configs/.tflint.hcl" --recursive
2 changes: 1 addition & 1 deletion linting-configs/.tflint.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ config {

plugin "aws" {
enabled = true
version = "0.23.0"
version = "0.27.0"
source = "github.com/terraform-linters/tflint-ruleset-aws"
}

Expand Down
68 changes: 47 additions & 21 deletions modules/aws_vm/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# SPDX-License-Identifier: Apache-2.0

variable "name" {
type = string
description = "Name to assign the VM"
type = string
}

variable "tags" {
Expand All @@ -12,77 +13,102 @@ variable "tags" {
}

variable "vm_type" {
default = "m5.4xlarge"
description = "EC2 instance type"
type = string
default = "m5.4xlarge"
}

variable "cloud_init" {
default = ""
}

variable "postgres_administrator_login" {
jarpat marked this conversation as resolved.
Show resolved Hide resolved
description = "The Administrator Login for the PostgreSQL Server. Changing this forces a new resource to be created."
default = "pgadmin"
description = "Cloud init script to execute"
type = string
default = ""
}

variable "vm_admin" {
description = "OS Admin User for VMs of AKS Cluster nodes"
description = "OS Admin User for VMs of EC2 instance"
type = string
default = "azureuser"
}

variable "ssh_public_key" {
description = "Path to ssh public key"
type = string
default = ""
}

variable "security_group_ids" {
default = []
description = "List of security group ids to associate with the EC2 instance"
type = list(string)
default = []
}

variable "create_public_ip" {
default = false
description = "Toggle the creation of a public EIP to be associated with the EC2 instance"
type = bool
default = false
}

variable "data_disk_count" {
default = 0
description = "Number of disks to attach to the EC2 instance"
type = number
default = 0
}

variable "data_disk_size" {
default = 128
description = "Size of disk to attach to the EC2 instance in GiBs"
type = number
default = 128
}

variable "data_disk_type" {
default = "gp2"
description = "The type of EBS volume for the data disk"
type = string
default = "gp2"
}

variable "data_disk_availability_zone" {
default = ""
description = "The AZ where the EBS volume will exist"
type = string
default = ""
}

variable "data_disk_iops" {
default = 0
description = "The amount of IOPS to provision for the data disk"
type = number
default = 0
}

variable "os_disk_size" {
default = 64
description = "The size of the OS disk"
type = number
default = 64
}

variable "os_disk_type" {
default = "standard"
description = "The type of EBS volume for the OS disk"
type = string
default = "standard"
}

variable "os_disk_delete_on_termination" {
default = true
description = "Delete disk on termination"
type = bool
default = true
}

variable "os_disk_iops" {
default = 0
description = "The amount of IOPS to provision for the OS disk"
type = number
default = 0
}

variable "subnet_id" {
type = string
description = "The VPC Subnet ID to launch in."
type = string
}

variable "enable_ebs_encryption" {
description = "Enable encryption on EBS volumes."
type = bool
default = false
}
2 changes: 1 addition & 1 deletion modules/aws_vpc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ locals {
existing_private_subnets = local.existing_subnets && contains(keys(var.existing_subnet_ids), "private") ? (length(var.existing_subnet_ids["private"]) > 0 ? true : false) : false
existing_database_subnets = local.existing_subnets && contains(keys(var.existing_subnet_ids), "database") ? (length(var.existing_subnet_ids["database"]) > 0 ? true : false) : false

public_subnets = local.existing_public_subnets ? data.aws_subnet.public : aws_subnet.public
# public_subnets = local.existing_public_subnets ? data.aws_subnet.public : aws_subnet.public # not used keeping for ref
private_subnets = local.existing_private_subnets ? data.aws_subnet.private : aws_subnet.private

}
Expand Down
19 changes: 4 additions & 15 deletions modules/aws_vpc/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ variable "azs" {

variable "vpc_id" {
description = "Existing vpc id"
type = string
default = null
}

variable "name" {
type = string
default = null
description = "Prefix used when creating VPC resources"
type = string
default = null
}

variable "cidr" {
Expand All @@ -39,18 +41,6 @@ variable "existing_nat_id" {
description = "Pre-existing VPC NAT Gateway id"
}

variable "enable_nat_gateway" {
jarpat marked this conversation as resolved.
Show resolved Hide resolved
description = "Should be true if you want to provision NAT Gateways for each of your private networks"
type = bool
default = true
}

variable "single_nat_gateway" {
description = "Should be true if you want to provision a single shared NAT Gateway across all of your private networks"
type = bool
default = true
}

variable "enable_dns_hostnames" {
description = "Should be true to enable DNS hostnames in the VPC"
type = bool
Expand All @@ -63,7 +53,6 @@ variable "enable_dns_support" {
default = true
}


variable "tags" {
description = "The tags to associate with your network and subnets."
type = map(string)
Expand Down
File renamed without changes.
5 changes: 5 additions & 0 deletions modules/kubeconfig/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ variable "namespace" {
}

variable "region" {
description = "AWS Region this cluster was provisioned in"
type = string
default = null
}
Expand All @@ -24,17 +25,21 @@ variable "create_static_kubeconfig" {
}

variable "path" {
description = "Path to output the kubeconfig file"
type = string
}

variable "cluster_name" {
description = "Kubernetes cluster name"
type = string
}

variable "endpoint" {
description = "Kubernetes cluster endpoint"
type = string
}

variable "ca_crt" {
description = "Kubernetes CA certificate"
type = string
}