diff --git a/sky/clouds/aws.py b/sky/clouds/aws.py index be1ecce0350..2207a977f25 100644 --- a/sky/clouds/aws.py +++ b/sky/clouds/aws.py @@ -299,7 +299,10 @@ def get_zone_shell_cmd(cls) -> Optional[str]: # The command for getting the current zone is from: # https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-identity-documents.html # pylint: disable=line-too-long command_str = ( - 'curl -s http://169.254.169.254/latest/dynamic/instance-identity/document' # pylint: disable=line-too-long + 'TOKEN=`curl -X PUT "http://169.254.169.254/latest/api/token" ' + '-H "X-aws-ec2-metadata-token-ttl-seconds: 21600"` && ' + 'curl -H "X-aws-ec2-metadata-token: $TOKEN" -s ' + 'http://169.254.169.254/latest/dynamic/instance-identity/document' f' | {constants.SKY_PYTHON_CMD} -u -c "import sys, json; ' 'print(json.load(sys.stdin)[\'availabilityZone\'])"') return command_str diff --git a/sky/templates/aws-ray.yml.j2 b/sky/templates/aws-ray.yml.j2 index 6afdf381cc0..11c3c3e1a3c 100644 --- a/sky/templates/aws-ray.yml.j2 +++ b/sky/templates/aws-ray.yml.j2 @@ -131,6 +131,9 @@ available_node_types: - Key: {{ label_key }} Value: {{ label_value|tojson }} {%- endfor %} + # Use IDMSv2 + MetadataOptions: + HttpTokens: required head_node_type: ray.head.default