Repository navigation
ec2rolecreds: Add method for getting instance identity doc - #590
Conversation
|
Thanks for submitting this PR @radeksimko I'll review the change, and check if there is a standard for the metadata endpoint. |
| if err != nil { | ||
| return EC2InstanceIdentityDocument{}, | ||
| awserr.New("EC2RoleRequestError", | ||
| fmt.Sprint("failed to get EC2 instance identity document"), err) |
There was a problem hiding this comment.
Probably can drop the fmt.Sprintf since not needed. Here and the error case below.
There was a problem hiding this comment.
Agreed, that's useless there, I will remove it.
|
Updated according to feedback. Also when I'm now looking into Would something like this be considered "stable" or recommended way to verify EC2 metadata endpoint? metadataSvc := ec2metadata.New(session.New(cfg))
if metadataSvc.Available() {
// it is verified
}which doesn't mean the time implementing this PR was wasted as I believe it may be useful anyway, but probably not in the context I thought it would be. |
| // GetDynamicData uses the path provided to request | ||
| func (c *EC2Metadata) GetDynamicData(p string) (string, error) { | ||
| op := &request.Operation{ | ||
| Name: "GetMetadata", |
There was a problem hiding this comment.
Name's value should be GetDynamicData in this case. Its not directly used in the HTTP request, but is useful for logging.
|
Good point, I think its fair to expect Adding the retrieval for the ident doc is a good addition too :) so not a waste of time. When initially created I was thinking you were looking for a more detailed way of verifying the ec2's host's identity. I should of mentioned available. But i think your right |
|
The change looks good, thanks for taking the time to investigate this and implement the PR. Even though Available also exists, this will be a helpful update. |
ec2rolecreds: Add method for getting instance identity doc
Fix for deserialization code generation to use time.ParseDateTime.
This is an implementation of a very basic check for "authenticity" of an EC2 metadata API as discussed in #543
This is how I'd expect people to use it:
Is there any standardised name for the ENV variable (
AWS_METADATA_ENDPOINT)?The PKCS7 signature verification can be a next iteration in a separate PR - I tried to keep this simple for the beginning.