Class: Terracop::Cop::Aws::FaultIntolerant

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

Overview

This cop checks for Autoscaling Groups that can only launch instances in a specific Availability Zone. This creates an availability risk, as if that AZ is lost, the ASG will not be able to launch instances anywhere else.

Examples:

# bad
resource "aws_autoscaling_group" "asg" {
  vpc_zone_identifier = ["subnet-123"]
}

# good
resource "aws_autoscaling_group" "asg" {
  # Note that to pass this cop, the two subnets must live in
  # different AZs.
  vpc_zone_identifier = ["subnet-123", "subnet-456"]
}

Constant Summary collapse

MSG =
'This Autoscaling Group can launch instances in only one AZ ' \
'(%<az>s). This setup would not tolerate the loss of that AZ.'

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
# File 'lib/terracop/cop/aws/fault_intolerant.rb', line 32

def check
  return unless attributes['availability_zones'].count < 2

  offense(format(MSG, az: attributes['availability_zones'][0]))
end