forked from cloudposse/terraform-aws-ec2-instance-group
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.yaml
166 lines (146 loc) · 5.51 KB
/
README.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#
# This is the canonical configuration for the `README.md`
# Run `make readme` to rebuild the `README.md`
#
# Name of this project
name: terraform-aws-ec2-instance-group
# Logo for this project
#logo: docs/logo.png
# License of this project
license: "APACHE2"
# Canonical GitHub repo
github_repo: cloudposse/terraform-aws-ec2-instance-group
# Badges to display
badges:
- name: "Latest Release"
image: "https://img.shields.io/github/release/cloudposse/terraform-aws-ec2-instance-group.svg"
url: "https://github.com/cloudposse/terraform-aws-ec2-instance-group/releases/latest"
- name: "Slack Community"
image: "https://slack.cloudposse.com/badge.svg"
url: "https://slack.cloudposse.com"
related:
- name: "terraform-aws-ec2-instance"
description: "Terraform Module for providing a general EC2 instance provisioned by Ansible"
url: "https://github.com/cloudposse/terraform-aws-ec2-instance"
- name: "terraform-aws-ec2-bastion-server"
description: "Terraform Module to define a generic Bastion host with parameterized user_data"
url: "https://github.com/cloudposse/terraform-aws-ec2-bastion-server"
- name: "https://github.com/cloudposse/terraform-aws-rds-cluster"
description: "Terraform module to provision an RDS Aurora cluster for MySQL or Postgres"
url: "https://github.com/cloudposse/terraform-aws-rds-cluster"
# Short description of this project
description: |-
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](https://github.com/cloudposse/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
# How to use this project
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:
```hcl
module "instance" {
source = "cloudposse/ec2-instance-group/aws"
# Cloud Posse recommends pinning every module to a specific version
# version = "x.x.x"
namespace = "eg"
stage = "prod"
name = "app"
ami = "ami-a4dc46db"
ami_owner = "099720109477"
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
```hcl
module "kafka_instance" {
source = "cloudposse/ec2-instance-group/aws"
# Cloud Posse recommends pinning every module to a specific version
# version = "x.x.x"
namespace = "eg"
stage = "prod"
name = "app"
ami = "ami-a4dc46db"
ami_owner = "099720109477"
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
instance_count = 3
security_group_rules = [
{
type = "egress"
from_port = 0
to_port = 65535
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
},
{
type = "ingress"
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
},
{
type = "ingress"
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
},
{
type = "ingress"
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
]
}
```
### Additional complete working example with variations of how to use the module
In /examples directory
This module depends on these modules:
* [terraform-terraform-label](https://github.com/cloudposse/terraform-terraform-label)
It is necessary to run `terraform get` or `terraform init` to download this module.
Now reference the label when creating an instance (for example):
```hcl
resource "aws_ami_from_instance" "example" {
count = length(module.instance.*.id)
name = "app"
source_instance_id = element(module.instance.*.id, count.index)
}
```
references:
- name: "terraform-aws-ec2-bastion-server"
description: "Terraform module to define a generic Bastion host with parameterized user_data"
url: "https://github.com/cloudposse/terraform-aws-ec2-bastion-server"
include:
- "docs/targets.md"
- "docs/terraform.md"
# Contributors to this project
contributors:
- name: "Erik Osterman"
github: "osterman"
- name: "Jamie Nelson"
github: "Jamie-BitFlight"
- name: "Vladimir Syromyatnikov"
github: "SweetOps"
- name: "Andriy Knysh"
github: "aknysh"
- name: "Chris Weyl"
github: "rsrchboy"