As an attempted solution, We had implemented IMDSv2 for AWS EC2 instance the following way:
resource “aws_instance” “example” {
…
instance_type = “t2.micro”
metadata_options {
…
http_endpoint = “enabled”
http_tokens = “required”
}
…
}
The above code is used to ensure IMDSv2 is enabled in EC2.
But metadata_options is not supported by terraform for AWS Batch.
The above parameters need to be made available in this terraform resource - aws_batch_compute_environment.