Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

engcj-318: adding metrics and user data to asg for datadog #25

Merged
merged 2 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ resource "aws_autoscaling_group" "this" {
wait_for_capacity_timeout = "15m"
vpc_zone_identifier = var.asg_subnets

enabled_metrics = var.enabled_metrics

target_group_arns = concat(
var.asg_additional_target_group_arns,
[aws_lb_target_group.this.arn],
Expand Down Expand Up @@ -87,14 +89,18 @@ resource "aws_ebs_volume" "data" {
)
}

locals {
combined_user_data = "${data.template_cloudinit_config.this.rendered}\n${var.additional_user_data}"
}

resource "aws_launch_configuration" "this" {
name_prefix = var.name
associate_public_ip_address = false
iam_instance_profile = aws_iam_instance_profile.this.id
image_id = var.ami_id
instance_type = var.asg_instance_type
key_name = var.asg_key_name
user_data_base64 = data.template_cloudinit_config.this.rendered
user_data = base64encode(local.combined_user_data)

security_groups = concat(
var.asg_additional_security_groups,
Expand Down
12 changes: 12 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,18 @@ variable "asg_subnets" {
type = list(string)
}

variable "enabled_metrics" {
description = "List of enabled metrics for the Auto Scaling Group"
type = list(string)
default = []
}

variable "additional_user_data" {
description = "Additional user data to configure the EC2 instances"
type = string
default = ""
}

########################################
# Networking Vars
########################################
Expand Down
Loading