boto3将安全组添加到EC2实例
我创建类似的实例:
client = boto3.client('ec2', region_name="eu-central-1")
client.run_instances(ImageId="ami-0df63501d4a3233e8", MinCount=1, MaxCount=1)
但是如何指定类型, SecurityGroup 等?
它们已经存储在ami
中吗?
我已经看到了使用boto3.resources(“ ec2”)
的解决方案,但我已经尝试过,但是我无法正确运行它。
I create instances like so:
client = boto3.client('ec2', region_name="eu-central-1")
client.run_instances(ImageId="ami-0df63501d4a3233e8", MinCount=1, MaxCount=1)
But how can I specify the type, securitygroup, etc. ?
Are they already stored in the ami
?
I have seen a solution using boto3.resources("ec2")
which I have already tried, but then I can't properly run UnitTests on it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果要按照安全组的名称添加,请添加参数
securityGroupids
如果要添加一个或多个 securitygroups ,则将添加一个或多个。这两个都应属于list
。用您的真实安全组ID替换
SG-0000000000000
。You would add the parameter
SecurityGroupIds
if you want to add one or more by the ID orSecurityGroups
if you want to add by the name of the security group. Both of these should be of typelist
.Replace
sg-000000000000000
with your real security group ID.