0

I'm deploying a very resource intensive web scraper, to optimize costs I opted to use AWS Spot Instances knowing the default behavior of IP addresses when dealing with EC2 instances the 1st question that came up to mind was if it's possible to maintain a fixed IP address when spots are reissued by AWS.

it is crucial to be able to do this without any human intervention (the whole thing is connected to multiple gitlab pipelines)

LordGoats
  • 25
  • 1
  • 7

2 Answers2

1

Put them behind a NAT gateway - that way they’ll extenally use the NAT GW IP address.

MLu
  • 24,849
  • 5
  • 59
  • 86
  • Thanks man, I've thought about the NAT gateway but as Tim said, it would cost me more than I can handle (it's a small startup, so I have to really tighten the belt when it comes to Cloud cost) – LordGoats Dec 09 '20 at 09:47
0

Your public IP will change when a spot instance is issued. The main way around this is to use an elastic IP, you can probably write a lambda function to assign the EIP to the instance triggered by an EC2 create event. You will be charged $0.005 per hour (which is $3.60 per month) for any EIP not attached to a running instance.

MLu suggested a NAT Gateway, which would work, but they cost US$32 per month and and addition $0.045 per GB of data that goes through it, which could get expensive. An on-demand NAT instance with an elastic IP could do a similar job at no additional cost if the NAT instance is in the same AZ. Traffic inside an AZ is free, then you just pay standard AWS internet traffic rates. It means you do end up paying for an additional instance.

Tim
  • 31,888
  • 7
  • 52
  • 78