本文介绍了禁用源/目的地检查AWS Python Boto的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用python boto自动部署aws VPN [IPSec]实例.我正在使用"ec2.run_instances"启动新实例.

I am trying to automate deployment of a aws VPN [IPSec] instance using python boto. I am launching new instance using, 'ec2.run_instances'.

reservations = ec2.run_instances(
image_id,
subnet_id=subnet_id,
instance_type=instance_type,
instance_initiated_shutdown_behavior='stop',
key_name=key_name,
security_group_ids=[security_group])

为使此脚本正常工作,我需要为此实例禁用源/目标检查.我找不到使用python boto禁用此功能的方法.根据boto文档,我可以使用"modify_instance_attribute"来做到这一点.

For this script to work, I need to disable source/destination check for this instance. I couldn't find a way to disable this using python boto. As per the boto documentation I can do this using 'modify_instance_attribute'.

http://boto.likedoc.net/en/latest/ref/ec2.html

但是,我找不到使用此属性的任何示例脚本.请给我一些例子,以便我完成.

However I couldn't find any sample script using this attribute. Please give me some examples so that I can complete this.

谢谢.

推荐答案

来自 boto3文档您将执行以下操作:

From boto3 documentation the way you would do this is:

response = requests.get('http://169.254.169.254/latest/meta-data/instance-id')
instance_id = response.text
ec2_client = boto3.client('ec2')
result = ec2_client.modify_instance_attribute(InstanceId=instance_id, SourceDestCheck={'Value': False})

这篇关于禁用源/目的地检查AWS Python Boto的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 07:15