Class: Terracop::Cop::Aws::PreferLaunchTemplates

Inherits:
SecurityGroupRuleCop show all
Defined in:
lib/terracop/cop/aws/prefer_launch_templates.rb

Overview

This cop warns against an ingress rule from 0.0.0.0/0 on port 22 (SSH). That is a Very Bad Idea™.

Examples:

# bad
resource "aws_launch_configuration" "lc" {}

resource "aws_autoscaling_group" "asg" {
  launch_configuration = aws_launch_configuration.lc.name
}

# good
resource "aws_launch_template" "tpl" {}

resource "aws_autoscaling_group" "asg" {
  launch_template {
    id      = aws_launch_template.tpl.id
    version = "$Latest"
  }
}

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



32
33
34
35
36
37
# File 'lib/terracop/cop/aws/prefer_launch_templates.rb', line 32

def check
  if type == 'aws_launch_configuration' ||
     attributes['launch_configuration']
    offense('Prefer Launch Templates to Launch Configurations.')
  end
end