Created
January 19, 2024 13:43
-
-
Save Yamini-crypto/e714549abda6045a0631b4c43c8833b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data "aws_autoscaling_groups" "app" { | |
filter { | |
name = "tag:id" | |
values = ["app-asg"] | |
} | |
} | |
module "asg-app" { | |
source = "../modules/asg/" | |
name = length(data.aws_autoscaling_groups.app.names) > 0 ? data.aws_autoscaling_groups.app.names[0] : "app-asg" | |
use_name_prefix = false | |
desired_capacity = 2 | |
min_size = 2 | |
max_size = 4 | |
health_check_type = "EC2" | |
vpc_zone_identifier = ["pvt-subnet-1-id", "pvt-subnet-2-id"] ## replace with the VPC private subnet IDs | |
target_group_arns = ["alb_target_group_arn"] ## replace with ARN of the ALB Target Group | |
# Launch template | |
launch_template_name = "app-launch-template" | |
launch_template_description = "Launch Template for application" | |
image_id = "ami-id" ## replace with the AMI ID of youe application | |
instance_type = "t3.large" | |
ebs_optimized = true | |
enable_monitoring = false | |
security_groups = [" sg-xxxxxxx "] ## Add the security group IDs to attach to this ASG instances | |
key_name = "ssh-key-pair" ## Keypair used to launch instances in ASG | |
iam_instance_profile_name = "ec2-role-for-s3-ssm-secret-manager" | |
user_data = base64encode("#!/bin/bash\necho \"Hello\"") | |
block_device_mappings = [ | |
{ | |
device_name = "/dev/sda1" | |
no_device = 0 | |
ebs = { | |
delete_on_termination = true | |
encrypted = true | |
volume_size = 30 | |
volume_type = "gp3" | |
} | |
} | |
] | |
scaling_policies = { | |
dynamic_TTS_policy = { | |
policy_type = "TargetTrackingScaling" | |
target_tracking_configuration = { | |
predefined_metric_specification = { | |
predefined_metric_type = "ASGAverageCPUUtilization" | |
} | |
target_value = 70.0 | |
} | |
} | |
} | |
tags = { | |
Name = "app-asg" | |
terraform = "true" | |
id = "app-asg" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment