【问题标题】:How do I start AWS EC2 instance using awscli interface?如何使用 awscli 界面启动 AWS EC2 实例?
【发布时间】:2017-09-10 21:02:43
【问题描述】:

我正在尝试使用 awscli 界面启动我的 AWS EC2 实例,但没有任何运气。这是我的命令:

aws ec2 start-instances --instance-ids <my-instance-id>

我收到以下错误:

An error occurred (InvalidInstanceID.NotFound) when calling the StopInstances operation: The instance ID '<my-instance-id>' does not exist

当我使用 boto3 库时,我遇到了同样的错误。 我错过了什么?

【问题讨论】:

    标签: amazon-web-services amazon-ec2 boto3


    【解决方案1】:

    AWS Command-Line Interface (CLI) 语法是:

    aws ec2 start-instances --instance-ids i-abcd1234 --region us-west-2
    

    (如果您定义了默认区域,则不需要--region。)

    通过boto3

    import boto3
    
    ec2 = boto3.client('ec2', region_name = 'us-west-2')
    ec2.start_instances(InstanceIds=['i-abcd1234'])
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-31
      • 1970-01-01
      • 2013-04-20
      • 2022-11-18
      • 2023-04-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多