Skip to content

Commit

Permalink
Merge pull request #25 from rhythmictech/release/v1.0.0
Browse files Browse the repository at this point in the history
engcj-318: adding metrics and user data to asg for datadog
  • Loading branch information
jjduverge authored Aug 13, 2024
2 parents c39228e + cded989 commit 4f7a308
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
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" {

Check failure on line 96 in main.tf

View workflow job for this annotation

GitHub Actions / tfsec

[tfsec] main.tf#L96 <AVD-AWS-0130>(https://aquasecurity.github.io/tfsec/v1.28.10/checks/aws/ec2/enforce-launch-config-http-token-imds/)

Launch configuration does not require IMDS access to require a token
Raw output
message:"Launch configuration does not require IMDS access to require a token"  location:{path:"/home/runner/work/terraform-aws-nexus/terraform-aws-nexus/main.tf"  range:{start:{line:96}}}  severity:ERROR  source:{name:"tfsec"  url:"https://github.com/aquasecurity/tfsec"}  code:{value:"AVD-AWS-0130"  url:"https://aquasecurity.github.io/tfsec/v1.28.10/checks/aws/ec2/enforce-launch-config-http-token-imds/"}
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

0 comments on commit 4f7a308

Please sign in to comment.