I am using AWS code deploy agent and deploying my project to the server through bitbucket plugin.
The code deployment agent first executes the script files which has the command to execute my spring-boot project.
Since I have two environments one development and another production. I want the script to do things differently based on the environment i.e two different instances.
My plan is to fetch the aws static ip-address which is mapped and from that determine the environment (production or stage).
How to fetch the elastic ip address through sh commands.
edited
You could do the following:
The above gets the
instance-id
from metadata, then uses theaws cli
to look for elastic IPs filtered by the id from metadata. Usingjq
this output can then be parsed down to the IP you are looking for.