I am fairly new to PowerShell!
What I am trying to do: We have an auto-scaling group connecting to a 3rd party and they are only capable of IP whitelisting (I've suggested domain whitelisting to them), as such this is problem to auto-scaling instances. I am trying to assign free (unallocated) EIPs to auto-scaled instances.
I found this one: https://gist.github.com/cleydson/ff70493ef37cff03669e21ed37d90a8b But I am not sure if there are any dependencies I need to install to the instance before I can start using it.
From what I've read so far, I need to:
Once all is working, I can then bake it into an AMI for use in auto-scaling.
Anyone can lead me further into the right direction? Thanks in advance!
EDIT UPDATE: The script I found above was working properly when I ran inside the a PowerShell window inside the instance itself. So I made an AMI of the instance now, and have made a new Launch Config for the ASG.
My problem now is the user data doesn't seem to be called whenever a new instance is created. Below is my user data script:
<script>
PowerShell -ExecutionPolicy Bypass -Command c:\scripts\setEIP.ps1 "EIP1,EIP2,EIP3"
</script>
<persist>true</persist>
I put placers in for the EIPs. Any thoughts as to why the user data isn't called?
I finally solved it!
The reason why it was not being called was:
Initially "Enable UserData execution for next service start" was unchecked. This is something to do with the EC2Config service installed inside the instance itself.
To summarize the solution:
<script>
PowerShell -ExecutionPolicy Bypass -Command c:\scripts\setEIP.ps1 "EIP1,EIP2,EIP3"
</script>
<persist>true</persist>