简体   繁体   English

AWS Lambda 从 EC2 实例释放弹性 IP 地址

[英]AWS Lambda to release elastic IP Address from EC2 instance

I am relatively new to AWS and Lambdas.我对 AWS 和 Lambdas 比较陌生。 I have deployed a lambda and its API gateway.我已经部署了一个 lambda 及其 API 网关。 This Lambda is using the aws-sdk to describe EC2 instances.此 Lambda 使用 aws-sdk 来描述 EC2 实例。 I would like to know if it's possible to use aws-sdk within the Lambda to release the IP Address from a given EC2 Instance Id.我想知道是否可以在 Lambda 中使用 aws-sdk 从给定的 EC2 实例 ID 中释放 IP 地址。 I can see in the aws-sdk documentation other methods to in example create an EC2 instance, create tags on the instance or reboot, start, stop the EC2 instance but so far in the aws-sdk documentation I don't find a method that I can use to release the IP Address from the EC2 instance.我可以在 aws-sdk 文档中看到其他方法,例如创建 EC2 实例、在实例上创建标签或重新启动、启动、停止 EC2 实例,但到目前为止在 aws-sdk 文档中我没有找到一种方法我可以用来从 EC2 实例中释放 IP 地址。 The only option I have found is in this SO question Call aws-cli from AWS Lambda that is for calling aws-cli commands within the Lambda but that seems it will require a complicated and cumbersome deployment and packaging process.我发现的唯一选项是在这个 SO 问题Call aws-cli from AWS Lambda 中,它用于在 Lambda 中调用 aws-cli 命令,但这似乎需要一个复杂而繁琐的部署和打包过程。 Any help will be greatly appreciated.任何帮助将不胜感激。

The API call to disassociate elastic IP address from an instance is (in boto3):将弹性 IP 地址与实例解除关联的 API 调用是(在 boto3 中):

Once disassociated, you can then release_address to the AWS pool as to not pay for it, if you want.解除关联后,如果需要,您可以将地址释放到 AWS 池中,无需为此付费。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM