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

chore: add http token configure option to clients #289

Merged
merged 2 commits into from
Sep 30, 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
1 change: 1 addition & 0 deletions clients.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ module "clients" {
custom_data = var.clients_custom_data
arch = var.client_arch
capacity_reservation_id = var.client_capacity_reservation_id
metadata_http_tokens = var.metadata_http_tokens
depends_on = [aws_autoscaling_group.autoscaling_group, module.network]
}
1 change: 1 addition & 0 deletions modules/clients/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ No modules.
| <a name="input_instance_iam_profile_arn"></a> [instance\_iam\_profile\_arn](#input\_instance\_iam\_profile\_arn) | Instance IAM profile ARN | `string` | n/a | yes |
| <a name="input_instance_type"></a> [instance\_type](#input\_instance\_type) | The virtual machine type (sku) to deploy | `string` | n/a | yes |
| <a name="input_key_pair_name"></a> [key\_pair\_name](#input\_key\_pair\_name) | Ssh key pair name to pass to the instances. | `string` | n/a | yes |
| <a name="input_metadata_http_tokens"></a> [metadata\_http\_tokens](#input\_metadata\_http\_tokens) | Whether or not the metadata service requires session tokens, also referred to as Instance Metadata Service Version 2 (IMDSv2) | `string` | `"required"` | no |
| <a name="input_placement_group_name"></a> [placement\_group\_name](#input\_placement\_group\_name) | Placement group name | `string` | `null` | no |
| <a name="input_proxy_url"></a> [proxy\_url](#input\_proxy\_url) | Weka proxy url | `string` | `""` | no |
| <a name="input_sg_ids"></a> [sg\_ids](#input\_sg\_ids) | Security group ids | `list(string)` | `[]` | no |
Expand Down
2 changes: 1 addition & 1 deletion modules/clients/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ region=${region}
subnet_id=${subnet_id}
additional_nics_num=${additional_nics_num}

instance_type=$(curl -s http://169.254.169.254/latest/meta-data/instance-type)
instance_type=$(curl -H "X-aws-ec2-metadata-token: $TOKEN" -v http://169.254.169.254/latest/meta-data/instance-type)
max_network_cards=$(aws ec2 describe-instance-types --region $region --instance-types $instance_type --query "InstanceTypes[0].NetworkInfo.MaximumNetworkCards" --output text)

counter=0
Expand Down
2 changes: 1 addition & 1 deletion modules/clients/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ resource "aws_launch_template" "this" {

metadata_options {
http_endpoint = "enabled"
http_tokens = "optional" #required
http_tokens = var.metadata_http_tokens
http_put_response_hop_limit = 1
instance_metadata_tags = "enabled"
}
Expand Down
6 changes: 6 additions & 0 deletions modules/clients/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,9 @@ variable "capacity_reservation_id" {
default = null
description = "The ID of the capacity reservation in which to run the clients"
}

variable "metadata_http_tokens" {
type = string
default = "required"
description = "Whether or not the metadata service requires session tokens, also referred to as Instance Metadata Service Version 2 (IMDSv2)"
}