Skip to content

Commit 39ac42f

Browse files
author
Steven Nemetz
committed
Add disabled test
1 parent 6f31239 commit 39ac42f

File tree

4 files changed

+140
-0
lines changed

4 files changed

+140
-0
lines changed

examples/asg_disabled/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Auto Scaling Group without ELB example
2+
======================================
3+
4+
Configuration in this directory creates Launch Configuration and Auto Scaling Group.
5+
6+
Data sources are used to discover existing VPC resources (VPC, subnet and security group) as well as AMI details.
7+
8+
Usage
9+
=====
10+
11+
To run this example you need to execute:
12+
13+
```bash
14+
$ terraform init
15+
$ terraform plan
16+
$ terraform apply
17+
```
18+
19+
Note that this example may create resources which cost money. Run `terraform destroy` when you don't need these resources.

examples/asg_disabled/main.tf

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
provider "aws" {
2+
region = "${var.region}"
3+
4+
# Make it faster by skipping something
5+
skip_get_ec2_platforms = true
6+
skip_metadata_api_check = true
7+
skip_region_validation = true
8+
skip_credentials_validation = true
9+
skip_requesting_account_id = true
10+
}
11+
12+
##############################################################
13+
# Data sources to get VPC, subnets and security group details
14+
##############################################################
15+
data "aws_vpc" "vpc" {
16+
tags {
17+
Env = "${var.environment}"
18+
}
19+
}
20+
21+
data "aws_subnet_ids" "all" {
22+
vpc_id = "${data.aws_vpc.vpc.id}"
23+
}
24+
25+
data "aws_security_group" "default" {
26+
vpc_id = "${data.aws_vpc.vpc.id}"
27+
name = "default"
28+
}
29+
30+
data "aws_ami" "amazon_linux" {
31+
most_recent = true
32+
33+
filter {
34+
name = "name"
35+
36+
values = [
37+
"amzn-ami-hvm-*-x86_64-gp2",
38+
]
39+
}
40+
41+
filter {
42+
name = "owner-alias"
43+
44+
values = [
45+
"amazon",
46+
]
47+
}
48+
}
49+
50+
######
51+
# Launch configuration and autoscaling group
52+
######
53+
module "example" {
54+
source = "../../"
55+
56+
name = "example-with-ec2"
57+
enabled = false
58+
59+
# Launch configuration
60+
#
61+
# launch_configuration = "my-existing-launch-configuration" # Use the existing launch configuration
62+
# create_lc = false # disables creation of launch configuration
63+
#lc_name = "example-lc"
64+
environment = "${var.environment}"
65+
66+
image_id = "${data.aws_ami.amazon_linux.id}"
67+
instance_type = "t2.micro"
68+
security_groups = ["${data.aws_security_group.default.id}"]
69+
associate_public_ip_address = true
70+
71+
ebs_block_device = [
72+
{
73+
device_name = "/dev/xvdz"
74+
volume_type = "gp2"
75+
volume_size = "50"
76+
delete_on_termination = true
77+
},
78+
]
79+
80+
root_block_device = [
81+
{
82+
volume_size = "50"
83+
volume_type = "gp2"
84+
delete_on_termination = true
85+
},
86+
]
87+
88+
# Auto scaling group
89+
#asg_name = "example-asg"
90+
vpc_zone_identifier = ["${data.aws_subnet_ids.all.ids}"]
91+
health_check_type = "EC2"
92+
min_size = 0
93+
max_size = 1
94+
desired_capacity = 1
95+
wait_for_capacity_timeout = 0
96+
97+
tags_ag = [
98+
{
99+
key = "Project"
100+
value = "megasecret"
101+
propagate_at_launch = true
102+
},
103+
]
104+
}

examples/asg_disabled/outputs.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Launch configuration
2+
output "launch_configuration_id" {
3+
description = "The ID of the launch configuration"
4+
value = "${module.example.launch_configuration_id}"
5+
}
6+
7+
# Autoscaling group
8+
output "autoscaling_group_id" {
9+
description = "The autoscaling group id"
10+
value = "${module.example.autoscaling_group_id}"
11+
}

examples/asg_disabled/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
variable "environment" {
2+
default = "one"
3+
}
4+
variable "region" {
5+
default = "us-west-2"
6+
}

0 commit comments

Comments
 (0)