将静态IP分配给自动缩放的EC2实例 [英] Assigning static IPs to auto scaled EC2 instance

查看:168
本文介绍了将静态IP分配给自动缩放的EC2实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个第三方集成,需要将EC2实例IP列入白名单.第三方将其服务器上的IP列入白名单,然后只有EC2实例可以与它们通信. 在单实例的情况下,这可行. 但是,当自动缩放开始时,我们将在多个实例中结束.这些新实例会为每个自动缩放操作自动获取新IP. 我们是否可以要求AWS从一组4个预定义的弹性IP中分配IP? (假设自动缩放限制为4,我们有4个浮动EIP)

We have a 3rd party integration which needs the EC2 instance IP to be whitelisted. The 3rd party whitelists the IP on their server and then only the EC2 instance can communicate with them. In the case of single instance this works. However when auto scaling kicks in, we would end up in more than 1 instance. These new instances automatically get new IPs for every autoscale action. Is it possible for us to ask AWS to assign IPs from a say a set of 4 predefined Elastic IPs? ( Assumption is that autoscaling is restricted to say 4 and we have 4 floating EIPs )

我试图避免网关NAT,因为与此相关的费用很高.

I'm trying to avoid gateway NAT since there is a big cost associated with it.

有什么想法吗?

推荐答案

使用自动缩放,这不可能直接将弹性IP分配给自动缩放的实例.但是,您可以考虑几个选项.

With autoscaling this is not directly possible to assign an Elastic IP to autoscaled instances. However there are couple of options you can consider.

  • 实例自动缩放后,使用带有AWS EC2 CLI命令的启动脚本(例如Linux中的UserData)来
  • After instance autoscales, having a boot up script(e.g UserData in Linux) with AWS EC2 CLI commands to associate an Elastic IP address you have allocated to your account writing a command line script. Note that you need to handle the health checks accordingly for the transition to happen smoothly.
  • Having a CloudWatch alarm trigger to execute an Lambda function which will associate an Elastic IP address to the instance newly started. For this you can use AWS SDK and code to check the instance without EIP and Associate an available EIP to it.

这篇关于将静态IP分配给自动缩放的EC2实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆