-
Notifications
You must be signed in to change notification settings - Fork 23
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
feat(nomad): add metadata_options to enable imdsv2 #297
Conversation
metadata_options { | ||
http_endpoint = "enabled" | ||
http_tokens = "required" | ||
http_put_response_hop_limit = 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When enabling IMDSv2 on a Terraform Enterprise EC2 host, it is required to set the http-put-response-hop-limit option key to a value of 2 or greater. This meta-data option key
limits the number of hops that metadata requests can travel across a network, and will affect Terraform Enterprise’s ability to interact with S3 buckets. This is required due to the Terraform Enterprise application being a set of containers running on the EC2 instance, making the minimum hop limit 2. Please note the exact setting required is entirely dependent on the environment that Terraform Enterprise is deployed in. The maximum value for the http-put-response-hop-limit key is 64, but testing may be required to determine an exact value to set the key to.
@@ -9,8 +9,7 @@ locals { | |||
} | |||
|
|||
module "nomad_servers" { | |||
source = "hashicorp/nomad/aws//modules/nomad-cluster" | |||
version = "0.7.1" | |||
source = "../nomad-cluster" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use the copied nomad-cluster
terraform module which has the metadata_options
. Spot price is set to an empty string which means maximum price of a the dedicated instance.
spot_price = var.spot_price | ||
|
||
# added to https://github.com/hashicorp/terraform-aws-vault/tree/v0.14.1/modules/vault-cluster | ||
metadata_options { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addition to the copied source code to enable imdsv2
user_data = var.user_data | ||
|
||
# added to https://github.com/hashicorp/terraform-aws-vault/tree/v0.14.1/modules/vault-cluster | ||
metadata_options { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addition to the copied source code to enable imdsv2
removed from the vault-cluster, tags are not supported anymore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, since this is mostly copied from a archived source code with the metadata option added
Motivation and Context
https://aws.amazon.com/blogs/security/defense-in-depth-open-firewalls-reverse-proxies-ssrf-vulnerabilities-ec2-instance-metadata-service/
Amazon recommends the migration to IMDSv2, a session based approach to accessing metadata to the instances.
Description
As hashicorp has archived their
terraform-aws-vault
,terraform-aws-consul
, andterraform-aws-nomad
public repository, we cannot contribute to the open source and edit the downstream modules to enable IMDSv2 in the launch configurations for these service. The solution is to copy the source code pinned to the version and edit from there, as seen from the example ofnomad-cluster
.Copied folders for consul
Copied folders for vault
How has this been tested?
For nomad servers (don't have the diff for nomad client, but similar)
For vault cluster and consul cluster