mirror of
https://github.com/farcasclaudiu/terraform-course.git
synced 2026-06-29 13:02:23 +03:00
+26
-24
@@ -1,28 +1,30 @@
|
||||
resource "aws_launch_configuration" "example-launchconfig" {
|
||||
name_prefix = "example-launchconfig"
|
||||
image_id = "${lookup(var.AMIS, var.AWS_REGION)}"
|
||||
instance_type = "t2.micro"
|
||||
key_name = "${aws_key_pair.mykeypair.key_name}"
|
||||
security_groups = ["${aws_security_group.myinstance.id}"]
|
||||
user_data = "#!/bin/bash\napt-get update\napt-get -y install nginx\nMYIP=`ifconfig | grep 'addr:10' | awk '{ print $2 }' | cut -d ':' -f2`\necho 'this is: '$MYIP > /var/www/html/index.html"
|
||||
lifecycle { create_before_destroy = true }
|
||||
}
|
||||
|
||||
resource "aws_autoscaling_group" "example-autoscaling" {
|
||||
name = "example-autoscaling"
|
||||
vpc_zone_identifier = ["${aws_subnet.main-public-1.id}", "${aws_subnet.main-public-2.id}"]
|
||||
launch_configuration = "${aws_launch_configuration.example-launchconfig.name}"
|
||||
min_size = 2
|
||||
max_size = 2
|
||||
health_check_grace_period = 300
|
||||
health_check_type = "ELB"
|
||||
load_balancers = ["${aws_elb.my-elb.name}"]
|
||||
force_delete = true
|
||||
|
||||
tag {
|
||||
key = "Name"
|
||||
value = "ec2 instance"
|
||||
propagate_at_launch = true
|
||||
name_prefix = "example-launchconfig"
|
||||
image_id = var.AMIS[var.AWS_REGION]
|
||||
instance_type = "t2.micro"
|
||||
key_name = aws_key_pair.mykeypair.key_name
|
||||
security_groups = [aws_security_group.myinstance.id]
|
||||
user_data = "#!/bin/bash\napt-get update\napt-get -y install nginx\nMYIP=`ifconfig | grep 'addr:10' | awk '{ print $2 }' | cut -d ':' -f2`\necho 'this is: '$MYIP > /var/www/html/index.html"
|
||||
lifecycle {
|
||||
create_before_destroy = true
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_autoscaling_group" "example-autoscaling" {
|
||||
name = "example-autoscaling"
|
||||
vpc_zone_identifier = [aws_subnet.main-public-1.id, aws_subnet.main-public-2.id]
|
||||
launch_configuration = aws_launch_configuration.example-launchconfig.name
|
||||
min_size = 2
|
||||
max_size = 2
|
||||
health_check_grace_period = 300
|
||||
health_check_type = "ELB"
|
||||
load_balancers = [aws_elb.my-elb.name]
|
||||
force_delete = true
|
||||
|
||||
tag {
|
||||
key = "Name"
|
||||
value = "ec2 instance"
|
||||
propagate_at_launch = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user