Coder Social home page Coder Social logo

kudaz28 / terraform-aws-ec2-instance-group Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cloudposse/terraform-aws-ec2-instance-group

0.0 2.0 0.0 31 KB

Terraform Module for provisioning multiple general purpose EC2 hosts for stateful applications.

Home Page: https://cloudposse.com/

License: Apache License 2.0

Makefile 1.97% HCL 95.43% Shell 2.60%

terraform-aws-ec2-instance-group's Introduction

README Header

Cloud Posse

terraform-aws-ec2-instance-group Build Status Latest Release Slack Community

Terraform Module for providing N general purpose EC2 hosts.

If you only need to provision a single EC2 instance, consider using the terraform-aws-ec2-instance module instead.

IMPORTANT This module by-design does not provision an AutoScaling group. It was designed to provision a discrete number of instances suitable for running stateful services such as databases (E.g. Kafka, Redis, etc).

Included features:

  • Automatically create a Security Group
  • Option to switch EIP attachment
  • CloudWatch monitoring and automatic reboot if instance hangs
  • Assume Role capability

This project is part of our comprehensive "SweetOps" approach towards DevOps.

Terraform Open Source Modules

It's 100% Open Source and licensed under the APACHE2.

We literally have hundreds of terraform modules that are Open Source and well-maintained. Check them out!

Usage

Note: add ${var.ssh_key_pair} private key to the ssh agent.

Include this repository as a module in your existing terraform code.

Simple example:

module "instance" {
  source                      = "git::https://github.com/cloudposse/terraform-aws-ec2-instance-group.git?ref=master"
  namespace                   = "cp"
  stage                       = "prod"
  name                        = "app"
  ami                         = "ami-a4dc46db"
  ssh_key_pair                = "${var.ssh_key_pair}"
  instance_type               = "${var.instance_type}"
  vpc_id                      = "${var.vpc_id}"
  security_groups             = ["${var.security_groups}"]
  subnet                      = "${var.subnet}"

  instance_count              = "3"
}

Example with additional volumes and EIP

module "kafka_instance" {
  source                      = "git::https://github.com/cloudposse/terraform-aws-ec2-instance-group.git?ref=master"
  namespace                   = "cp"
  stage                       = "prod"
  name                        = "app"
  ami                         = "ami-a4dc46db"
  ssh_key_pair                = "${var.ssh_key_pair}"
  vpc_id                      = "${var.vpc_id}"
  security_groups             = ["${var.security_groups}"]
  subnet                      = "${var.subnet}"
  associate_public_ip_address = "true"
  additional_ips_count        = "1"
  ebs_volume_count            = "2"
  allowed_ports               = ["22", "80", "443"]

  instance_count              = "3"
}

Additional complete working example with variations of how to use the module

In /examples directory

This module depends on these modules:

It is necessary to run terraform get or terraform init to download this module.

Now reference the label when creating an instance (for example):

resource "aws_ami_from_instance" "example" {
  count              = "${length(module.instance.*.id)}"
  name               = "terraform-example"
  source_instance_id = "${element(module.instance.*.id, count.index)}"
}

Makefile Targets

Available targets:

  help                                Help screen
  help/all                            Display help for all targets
  help/short                          This help short screen
  lint                                Lint terraform code

Inputs

Name Description Type Default Required
additional_ips_count Count of additional EIPs string 0 no
allowed_ports List of allowed ingress ports list <list> no
ami The AMI to use for the instance. string - yes
applying_period The period in seconds over which the specified statistic is applied string 60 no
assign_eip_address Assign an Elastic IP address to the instance string true no
associate_public_ip_address Associate a public IP address with the instance string true no
attributes Additional attributes (e.g. policy or role) list <list> no
availability_zone Availability Zone the instance is launched in. If not set, will be launched in the first AZ of the region string `` no
comparison_operator The arithmetic operation to use when comparing the specified Statistic and Threshold. Possible values are: GreaterThanOrEqualToThreshold, GreaterThanThreshold, LessThanThreshold, LessThanOrEqualToThreshold. string GreaterThanOrEqualToThreshold no
create_default_security_group Create default Security Group with only Egress traffic allowed string true no
default_alarm_action - string action/actions/AWS_EC2.InstanceId.Reboot/1.0 no
delete_on_termination Whether the volume should be destroyed on instance termination string true no
delimiter - string - no
disable_api_termination Enable EC2 Instance Termination Protection string false no
ebs_device_names Name of the EBS device to mount list <list> no
ebs_iops Amount of provisioned IOPS. This must be set with a volume_type of io1 string 0 no
ebs_optimized Launched EC2 instance will be EBS-optimized string false no
ebs_volume_count Count of EBS volumes that will be attached to the instance string 0 no
ebs_volume_size Size of the EBS volume in gigabytes string 10 no
ebs_volume_type The type of EBS volume. Can be standard, gp2 or io1 string gp2 no
evaluation_periods The number of periods over which data is compared to the specified threshold. string 5 no
generate_ssh_key_pair If true, create a new key pair and save the pem for it to the current working directory string false no
instance_count Count of ec2 instances to create string 1 no
instance_enabled Flag to control the instance creation. Set to false if it is necessary to skip instance creation string true no
instance_type The type of the instance string t2.micro no
ipv6_address_count Number of IPv6 addresses to associate with the primary network interface. Amazon EC2 chooses the IPv6 addresses from the range of your subnet string 0 no
ipv6_addresses List of IPv6 addresses from the range of the subnet to associate with the primary network interface list <list> no
metric_name The name for the alarm's associated metric. Allowed values can be found in https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/ec2-metricscollected.html string StatusCheckFailed_Instance no
metric_namespace The namespace for the alarm's associated metric. Allowed values can be found in https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/aws-namespaces.html string AWS/EC2 no
metric_threshold The value against which the specified statistic is compared string 1 no
monitoring Launched EC2 instance will have detailed monitoring enabled string true no
name Name (e.g. bastion or db) - required for terraform-terraform-label module string - yes
namespace Namespace (e.g. cp or cloudposse) - required for terraform-terraform-label module string - yes
private_ips Private IP address to associate with the instances in the VPC list <list> no
region AWS Region the instance is launched in string `` no
root_iops Amount of provisioned IOPS. This must be set if root_volume_type is set to io1 string 0 no
root_volume_size Size of the root volume in gigabytes string 10 no
root_volume_type Type of root volume. Can be standard, gp2 or io1 string gp2 no
security_groups List of Security Group IDs allowed to connect to the instance list <list> no
source_dest_check Controls if traffic is routed to the instance when the destination address does not match the instance. Used for NAT or VPNs string true no
ssh_key_pair SSH key pair to be provisioned on the instance string `` no
ssh_key_pair_path Path to where the generated key pairs will be created. Defaults to $${path.cwd} string `` no
stage Stage (e.g. prod, dev, staging - required for terraform-terraform-label module string - yes
statistic_level The statistic to apply to the alarm's associated metric. Allowed values are: SampleCount, Average, Sum, Minimum, Maximum string Maximum no
subnet VPC Subnet ID the instance is launched in string - yes
tags Additional tags map <map> no
user_data Instance user data. Do not pass gzip-compressed data via this argument string `` no
vpc_id The ID of the VPC that the instance security group belongs to string - yes
welcome_message - string `` no

Outputs

Name Description
alarm_ids CloudWatch Alarm IDs
aws_key_pair_name Name of AWS key pair
ebs_ids IDs of EBSs
eip_per_instance_count Number of EIPs per instance.
eni_to_eip_map Map of ENI with EIP
ids Disambiguated IDs list
instance_count Total number of instances created.
network_interface_ids IDs of the network interface that was created with the instance
new_ssh_keypair_generated Was a new ssh_key_pair generated
primary_network_interface_ids IDs of the instance's primary network interface
private_dns Private DNS records of instances
private_ips Private IPs of instances
public_dns All public DNS records for the public interfaces and ENIs
public_ips List of Public IPs of instances (or EIP)
role_names Names of AWS IAM Roles associated with creating instance
security_group_ids ID on the new AWS Security Group associated with creating instance
ssh_key_pem_path Path where SSH key pair was created (if applicable)

Share the Love

Like this project? Please give it a ★ on our GitHub! (it helps us a lot)

Are you using this project or any of our other projects? Consider leaving a testimonial. =)

Related Projects

Check out these related projects.

References

For additional context, refer to some of these links.

Help

Got a question?

File a GitHub issue, send us an email or join our Slack Community.

README Commercial Support

Commercial Support

Work directly with our team of DevOps experts via email, slack, and video conferencing.

We provide commercial support for all of our Open Source projects. As a Dedicated Support customer, you have access to our team of subject matter experts at a fraction of the cost of a full-time engineer.

E-Mail

  • Questions. We'll use a Shared Slack channel between your team and ours.
  • Troubleshooting. We'll help you triage why things aren't working.
  • Code Reviews. We'll review your Pull Requests and provide constructive feedback.
  • Bug Fixes. We'll rapidly work to fix any bugs in our projects.
  • Build New Terraform Modules. We'll develop original modules to provision infrastructure.
  • Cloud Architecture. We'll assist with your cloud strategy and design.
  • Implementation. We'll provide hands-on support to implement our reference architectures.

Terraform Module Development

Are you interested in custom Terraform module development? Submit your inquiry using our form today and we'll get back to you ASAP.

Slack Community

Join our Open Source Community on Slack. It's FREE for everyone! Our "SweetOps" community is where you get to talk with others who share a similar vision for how to rollout and manage infrastructure. This is the best place to talk shop, ask questions, solicit feedback, and work together as a community to build totally sweet infrastructure.

Newsletter

Signup for our newsletter that covers everything on our technology radar. Receive updates on what we're up to on GitHub as well as awesome new projects we discover.

Contributing

Bug Reports & Feature Requests

Please use the issue tracker to report any bugs or file feature requests.

Developing

If you are interested in being a contributor and want to get involved in developing this project or help out with our other projects, we would love to hear from you! Shoot us an email.

In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow.

  1. Fork the repo on GitHub
  2. Clone the project to your own machine
  3. Commit changes to your own branch
  4. Push your work back up to your fork
  5. Submit a Pull Request so that we can review your changes

NOTE: Be sure to merge the latest changes from "upstream" before making a pull request!

Copyright

Copyright © 2017-2019 Cloud Posse, LLC

License

License

See LICENSE for full details.

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

  https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.

Trademarks

All other trademarks referenced herein are the property of their respective owners.

About

This project is maintained and funded by Cloud Posse, LLC. Like it? Please let us know by leaving a testimonial!

Cloud Posse

We're a DevOps Professional Services company based in Los Angeles, CA. We ❤️ Open Source Software.

We offer paid support on all of our projects.

Check out our other projects, follow us on twitter, apply for a job, or hire us to help with your cloud strategy and implementation.

Contributors

Erik Osterman
Erik Osterman
Jamie Nelson
Jamie Nelson
Vladimir
Vladimir

README Footer Beacon

terraform-aws-ec2-instance-group's People

Contributors

jamie-bitflight avatar osterman avatar sweetops avatar vadim-hleif avatar

Watchers

 avatar  avatar

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.