class Terracop::Cop::Style::ResourceTypeInName

This cop checks terraform resource names that include the type in them. This makes for very long and redundant names.

@example

# bad
resource "aws_security_group" "load_balancer_security_group" { }
resource "aws_security_group" "load_balancer_sg" { }
resource "aws_security_group_rule" "ingress_rule" { }

# good
resource "aws_security_group" "load_balancer" { }
resource "aws_security_group_rule" "ingress" { }

@note

When you rename a resource terraform will destroy and recreate it.
Use `terraform mv` on the state file to avoid this from happening.

Constants

BLACKLIST

Public Instance Methods

check() click to toggle source
# File lib/terracop/cop/style/resource_type_in_name.rb, line 41
def check
  blacklist = BLACKLIST[type]
  blacklist&.each do |word|
    if name.downcase.gsub('-', '_').include?(word)
      offense 'Do not include the resource type in its name.'
      return
    end
  end
end