I try this example:
https://aws.github.io/aws-sdk-go-v2/docs/sdk-utilities/ec2-imds/
and go.mod is using:
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.15
but the localip prints as:
&{{0xc0002d1680} {map[{}:{[{ false false {map[]}}]}]}}
Anyone have this working?
2
Answers
This solves the problem if anyone is interested: https://github.com/natemarks/ec2metadata
The client.GetMetadata function returns a GetMetadataOutput object with a Content element which is the HTTP resp.Body of type io.Reader. That element needs to be additionally converted to a string, e.g., via a function like this
So, a correct version of the AWS sample should return