aws / aws-cdi-sdk

AWS Cloud Digital Interface (CDI) SDK. Documentation at: https://aws.github.io/aws-cdi-sdk/mainline/index.html
BSD 2-Clause "Simplified" License
59 stars 20 forks source link

IMDSv2 problem with CDI test programs #136

Open mpeg2tom opened 3 months ago

mpeg2tom commented 3 months ago

Instances with IMDSv2 required throw errors with cdi_test_min and cdi_test, for example:

[root@ip-xxx-xxx-xxx-xxx aws-cdi-sdk]# ./build/debug/bin/cdi_test_min_rx --rx AVM --local_ip xxx.xxx.xxx.xxx --dest_port xxxx 
[2024-06-07T22:42:12.578728Z] [main:240] Initializing test.
[2024-06-07T22:42:12.586850Z] [ProcessFormattedStatement:308] AWS-SDK: [[ERROR] 2024-06-07 22:42:12.586 EC2MetadataClient [140486344184576] Http request to retrieve credentials failed with error code 401].
[2024-06-07T22:42:12.586895Z] [ProcessFormattedStatement:308] AWS-SDK: [[ERROR] 2024-06-07 22:42:12.586 EC2MetadataClient [140486344184576] Can not retrieve resource from http://169.254.169.254/latest/meta-data/placement/availability-zone-id].
[2024-06-07T22:42:12.586916Z] WARNING: [MetricsGatherer:502] Retrieval of availability-zone-id failed, falling back to availability-zone
[2024-06-07T22:42:12.587552Z] [ProcessFormattedStatement:308] AWS-SDK: [[ERROR] 2024-06-07 22:42:12.587 EC2MetadataClient [140486344184576] Http request to retrieve credentials failed with error code 401].
[2024-06-07T22:42:12.587611Z] [ProcessFormattedStatement:308] AWS-SDK: [[ERROR] 2024-06-07 22:42:12.587 EC2MetadataClient [140486344184576] Can not retrieve resource from http://169.254.169.254/latest/meta-data/placement/availability-zone].
[2024-06-07T22:42:12.588386Z] [ProcessFormattedStatement:308] AWS-SDK: [[ERROR] 2024-06-07 22:42:12.588 EC2MetadataClient [140486344184576] Http request to retrieve credentials failed with error code 401].
[2024-06-07T22:42:12.588407Z] [ProcessFormattedStatement:308] AWS-SDK: [[ERROR] 2024-06-07 22:42:12.588 EC2MetadataClient [140486344184576] Can not retrieve resource from http://169.254.169.254/latest/meta-data/instance-id].
[2024-06-07T22:42:12.729067Z] [ProcessFormattedStatement:308] AWS-SDK: [[ERROR] 2024-06-07 22:42:12.728 AWSJsonClient [140486344184576] HTTP response code: 400Resolved remote host IP address: 52.203.81.111Request ID: c0629436-3def-4073-80de-950ec9a2cb1dException name: ParamValidationErrorError message: Unable to parse ExceptionName: ParamValidationError Message: Parameter validation failed: [Invalid length for parameter AvailabilityZone, value: 0, valid range: 1-128 Invalid length for parameter Ec2InstanceId, value: 0, valid range: 1-128]7 response headers:content-length : 249content-type : application/jsondate : Fri, 07 Jun 2024 22:42:12 GMTx-amz-apigw-id : ZBLuxHzeoAMEIIQ=x-amzn-errortype : ParamValidationErrorx-amzn-requestid : c0629436-3def-4073-80de-950ec9a2cb1dx-amzn-trace-id : Root=1-66638cc4-6179da506f439844656d2c01].
mhhen commented 3 months ago

Reverting to using IMDSv1 did resolve the problem.

mpeg2tom commented 3 months ago

Yes, modifying instance metadata options to "IMDSv2 Optional" (instead of "IMDSv2 Required"), stopping and restarting the instance resolves the errors.