Giter Site home page Giter Site logo

tf_aws_ec2_auto_recovery's Introduction

tf_aws_ec2_auto_recovery

A Terraform template for EC2 Auto Recovery

This terraform module implements

This is useful when

  • You need to have a group of EC2 instances that need static public IPs (EIP)
  • The software on EC2 instances is relatively reliable and you only need to worry about EC2 system errors
  • EC2 instances type is one of C3, C4, M3, R3, and T2

Alternatives

  • When static IP (EIP) is not needed, ELB with auto scaling group should be considered.
  • An auto scaling group with (1,1,1) configured and attach EIP at provision time. (need IAM role for instance)

Components

  • aws_eip.eip: an EIP to be assigned to the EC2 instance
  • aws_instance.instance: the EC2 instance
  • aws_cloudwatch_metric_alarm.auto_recovery_alarm: the Cloudwatch alarm to trigger EC2 instance Auto Recovery
  • aws_route53_health_check.route53_health_check: an HTTP health check for the health of the EC2 instance (Assuming the instance serves HTTP traffic and has a health check)
  • aws_route53_record.route53_record: a Route53 record point to the EIP attached to the EC2 instnace with healthcheck.

Example

module "static-ip-ec2-instances" {
  source                 = "github.com/cxmcc/tf_aws_ec2_auto_recovery"
  count                  = 2
  domain                 = "static-ip.example.com"
  route53_hosted_zone_id = "ZZZZFFFFEEEENNNN"
  ami                    = "ami-1234567"
  health_check_path      = "/route53_health_check"
  instance_type          = "m3.medium"
  name                   = "static-ip-instance"
  key_name               = "default"
  subnet_ids             = ["subnet-123456", "subnet-234567"]
  vpc_security_group_ids = ["sg-1234567"]

  user_data = <<EOF
#cloud-config
hostname: static-ip-instance
manage_etc_hosts: true
EOF
}

tf_aws_ec2_auto_recovery's People

Contributors

cxmcc avatar paulomigalmeida avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

tf_aws_ec2_auto_recovery's Issues

Should the CloudWatch alarm's Statistic be set to "Maximum"?

Hi there,

In the CloudWatch alarm, the Statistic is set to "Minimum" and is being evaluated over 3 periods. Let's say the System Status Check came back as 1, 0, then 1 (fail, pass, fail), then with Statistic set to "Minimum", the auto-recover action won't be triggered (Threshold >= 1). Now this may be what you're going for, but personally I'd rather the action be triggered in this scenario, so I'd set the Statistic to Maximum.

Please let me know if my logic and/or understanding of CW is incorrect.
Thanks!

-- Khalid

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.