Instance lookup by IP and hostname via private IP addresses on attached NIC#54
Instance lookup by IP and hostname via private IP addresses on attached NIC#54ncatelli merged 16 commits intodisneystreaming:developfrom ncatelli:feature/instance-loopkup-by-nic-association
Conversation
|
This is ONLY implemented for the |
|
Ported changes over to |
| } | ||
|
|
||
| // AddsAttributeFlag adds the --attribute flag to command. | ||
| func AddAttributeFlag(cmd *cobra.Command) { |
There was a problem hiding this comment.
Small addition to add the ability to include additional formatting flags at the selection level, to supplement the --tags flag.
ec2/helpers.go
Outdated
| } | ||
|
|
||
| // GetEC2InstanceAttributes accepts any number of instance strings and returns a populated InstanceAttributes{} object for each instance | ||
| func GetEC2InstanceAttributes(client ec2iface.EC2API, instances []*string) (ec2Attributes map[string]map[string]string, err error) { |
There was a problem hiding this comment.
Retrieves instance attributes. Currently it only does VpcId. TBH i kinda hate this and am wondering if we should just transmute fields on the ec2.Instance struct into a map if the value is a non-compound type. i.e. strings or numeric types
| for _, instance := range page.InstanceInformationList { | ||
| output = append(output, instance) | ||
| } | ||
| output = append(output, page.InstanceInformationList...) |
| } | ||
|
|
||
| func addInstanceInfo(instanceID *string, tags map[string]string, instancePool *instance.InstanceInfoSafe, profile string, region string) { | ||
| func addInstanceInfo(instanceID *string, ec2Instance ec2.Instance, instancePool *instance.InstanceInfoSafe, profile string, region string) { |
There was a problem hiding this comment.
Strips out the individual tags and attributes in favor of formatting to the struct from within this method.
|
Got the signoff from @sendqueery , going to merge. |
General
This PR adds the capability to lookup an instance ID via the private address of an attached NIC.
Functionally this would be similar to the following bash one-liner
ssm session -i $(aws ec2 describe-network-interfaces --filters Name=addresses.private-ip-address,Values=<SOME PRIVATE IP> --query 'NetworkInterfaces[0].Attachment.InstanceId' | tr -d '"')However this allows the added convenience of checking across multiple accounts, regions and handling the IP resolution.
Example commands
Session
Run
Changes
--address/-a--attributeflag for additional formatting dataVpcIdTODO