Class: Terracop::Cop::Aws::EnsurePropagatedTags

Inherits:
Base
  • Object
show all
Defined in:
lib/terracop/cop/aws/ensure_propagated_tags.rb

Overview

This cop makes sure that EC2 instances launched by Autoscaling Groups also have tags. It is configured like the Aws/EnsureTags cop.

Examples:

# bad
resource "aws_asg" "asg" {
  tag {
    key = "Name"
    value = "asg"
    propagate_at_launch = false
  }
}

# good
resource "aws_asg" "asg" {
  tag {
    key = "Name"
    value = "asg"
    propagate_at_launch = true
  }
}

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



33
34
35
36
37
38
39
40
# File 'lib/terracop/cop/aws/ensure_propagated_tags.rb', line 33

def check
  if self.class.config['Required']
    check_required(propagated_tags, self.class.config['Required'])
  elsif propagated_tags.empty?
    offense 'The EC2 instances launched by this Autoscaling group ' \
            'will not have any tags.'
  end
end