Dynamically get network interface name in domainjoin_unix_script.go
- Dominant language
- Go
- Stars
- 1.2k
- Forks
- 357
- PR merge metrics
- No merged PRs in 30d
Description
As part of the domain join script for Unix, there is a line where we get the interface IP address, but the interface name is hard-coded (`eth0`) as you can see here: https://github.com/aws/amazon-ssm-agent/blob/baf58f0dedc4dc84d719101259cea5ed73c9f842/agent/plugins/domainjoin/domainjoin_unix_script.go#L555
Although this works for `t2` instance types, it doesn't work for `t3`and `t3a` since the network interface name has changed to `ensX`.
I suggest to change this line to dynamically fetch the the IP without specifying the interface name.
There are 2 options to do this:
```bash
# Option 1:
ip_address="$(hostname -I)"
# Option 2:
ip_address="$(ip -o -4 addr show $(ip route list | grep default | grep -E 'dev (\w+)' -o | awk '{print $2}') | awk '{print $4}' | cut -d/ -f1)"
```
This is an important fix as there is currently an issue with this script when running on newer machine types
Contributor guide
Research direction
Start in agent/plugins/domainjoin/domainjoin_unix_script.go around line 555, where the Unix domain-join script reads the interface IP using the hard-coded eth0 name. Compare the two proposed shell approaches and verify the script obtains the active interface IP on both eth0 and ensX systems. Done means the domain-join script no longer depends on a fixed interface name.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, shell
- Domain
- infrastructure, operating-systems
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100