Closed JustinTRoss closed 3 years ago
As stated above in the comment: "Get ECS instance info, although not used in this user_data itself" the code below that is not used by the script, therefore we would just remove all the lines or fix them as that line is wrong as you correctly point out.
Thanks. I understand the lines aren't used in user_data.sh itself. Forgive my inexperience with Terraform, but where are they be useful otherwise?
Also, I realize now region=$${az:0:$${#az} - 1}
could actually just be region=$${az:0:-1}
to get az
without the last char. Will this ever differ from the region we specify through terraform variable?
This could be useful when you pass in your own "custom_userdata" to the script and then you already have the 'region' information that you can use. But I think we should remove these lines from the script as the region is already defined on line 60.
P.S. Don't worry about the experience, we are all always learning something new :)
Disclaimer: I don't fully understand the context for this file or this portion of the file, and I'm not especially versed in shell scripting.
These two lines appear to me to have issues.
https://github.com/arminc/terraform-ecs/blob/7eb8a43154e61e68d50fd749c48cb17da65aacbb/modules/ecs_instances/templates/user_data.sh#L97-L98
Should
az=$(curl -s http://instance-data/latest/meta-data/placement/availability-zone)
beaz=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone)
and should
region=$${az:0:$${#az} - 1}
beregion=$${az:0:$${az} - 1}
Would you mind briefly confirming for me and possibly explaining the context for this file and these lines?