Class: Terracop::Cop::Style::DashInResourceName

Inherits:
Base
  • Object
show all
Defined in:
lib/terracop/cop/style/dash_in_resource_name.rb

Overview

Note:

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

This cop checks for the use of dashes in terraform resource names. Terraform uses underscores for resource types and attributes. Using dashes for resource names makes for awkward combinations.

Examples:

# bad
resource "aws_security_group" "load-balancer" { }

# good
resource "aws_security_group" "load_balancer" { }

Constant Summary collapse

MSG =
'Use underscores in terraform resource names instead of dashes.'

Instance Attribute Summary

Attributes inherited from Base

#attributes, #index, #name, #offenses, #type

Instance Method Summary collapse

Methods inherited from Base

config, cop_name, #human_name, #initialize, #offense, run

Constructor Details

This class inherits a constructor from Terracop::Cop::Base

Instance Method Details

#checkObject



27
28
29
30
31
# File 'lib/terracop/cop/style/dash_in_resource_name.rb', line 27

def check
  return unless name.index('-')

  offense(MSG)
end