mirror of
https://github.com/farcasclaudiu/terraform-course.git
synced 2026-06-29 01:02:16 +03:00
+27
-17
@@ -17,18 +17,19 @@ locals {
|
||||
demo-node-userdata = <<USERDATA
|
||||
#!/bin/bash
|
||||
set -o xtrace
|
||||
/etc/eks/bootstrap.sh --apiserver-endpoint '${aws_eks_cluster.demo.endpoint}' --b64-cluster-ca '${aws_eks_cluster.demo.certificate_authority.0.data}' '${var.cluster-name}'
|
||||
/etc/eks/bootstrap.sh --apiserver-endpoint '${aws_eks_cluster.demo.endpoint}' --b64-cluster-ca '${aws_eks_cluster.demo.certificate_authority[0].data}' '${var.cluster-name}'
|
||||
USERDATA
|
||||
|
||||
}
|
||||
|
||||
resource "aws_launch_configuration" "demo" {
|
||||
associate_public_ip_address = true
|
||||
iam_instance_profile = "${aws_iam_instance_profile.demo-node.name}"
|
||||
image_id = "${data.aws_ami.eks-worker.id}"
|
||||
instance_type = "t2.large"
|
||||
name_prefix = "terraform-eks-demo"
|
||||
security_groups = ["${aws_security_group.demo-node.id}"]
|
||||
user_data_base64 = "${base64encode(local.demo-node-userdata)}"
|
||||
iam_instance_profile = aws_iam_instance_profile.demo-node.name
|
||||
image_id = data.aws_ami.eks-worker.id
|
||||
instance_type = "t2.large"
|
||||
name_prefix = "terraform-eks-demo"
|
||||
security_groups = [aws_security_group.demo-node.id]
|
||||
user_data_base64 = base64encode(local.demo-node-userdata)
|
||||
|
||||
lifecycle {
|
||||
create_before_destroy = true
|
||||
@@ -36,22 +37,31 @@ resource "aws_launch_configuration" "demo" {
|
||||
}
|
||||
|
||||
resource "aws_autoscaling_group" "demo" {
|
||||
desired_capacity = 2
|
||||
launch_configuration = "${aws_launch_configuration.demo.id}"
|
||||
max_size = 2
|
||||
min_size = 1
|
||||
name = "terraform-eks-demo"
|
||||
vpc_zone_identifier = ["${module.vpc.public_subnets}"]
|
||||
desired_capacity = 2
|
||||
launch_configuration = aws_launch_configuration.demo.id
|
||||
max_size = 2
|
||||
min_size = 1
|
||||
name = "terraform-eks-demo"
|
||||
# TF-UPGRADE-TODO: In Terraform v0.10 and earlier, it was sometimes necessary to
|
||||
# force an interpolation expression to be interpreted as a list by wrapping it
|
||||
# in an extra set of list brackets. That form was supported for compatibilty in
|
||||
# v0.11, but is no longer supported in Terraform v0.12.
|
||||
#
|
||||
# If the expression in the following list itself returns a list, remove the
|
||||
# brackets to avoid interpretation as a list of lists. If the expression
|
||||
# returns a single list item then leave it as-is and remove this TODO comment.
|
||||
vpc_zone_identifier = module.vpc.public_subnets
|
||||
|
||||
tag {
|
||||
key = "Name"
|
||||
value = "terraform-eks-demo"
|
||||
key = "Name"
|
||||
value = "terraform-eks-demo"
|
||||
propagate_at_launch = true
|
||||
}
|
||||
|
||||
tag {
|
||||
key = "kubernetes.io/cluster/${var.cluster-name}"
|
||||
value = "owned"
|
||||
key = "kubernetes.io/cluster/${var.cluster-name}"
|
||||
value = "owned"
|
||||
propagate_at_launch = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user