【问题标题】:Use Systems Manager to Run AWS CLI Commands on Windows EC2 Instance使用 Systems Manager 在 Windows EC2 实例上运行 AWS CLI 命令
【发布时间】:2020-02-06 03:35:21
【问题描述】:

目前我正在尝试使用 Systems Manager 在 EC2 实例上执行 AWS CLI 命令。我想让系统管理员运行以下命令:

aws s3 cp <origin directory> s3://<destination directory>

但是当我通过 AWS-RunPowerShellScript 文档运行它时,我收到的输出如下:

aws : The term 'aws' is not recognized as the name of a cmdlet, function, script file, or 
operable program. Check the 
spelling of the name, or if a path was included, verify that the path is correct and try 
again.
At C:\ProgramData\Amazon\SSM\InstanceData\i- 
06a4de60a263996a1\document\orchestration\11f5777e-08c8-4385-9ab4-cdc85c846f
24\awsrunPowerShellScript\0.awsrunPowerShellScript\_script.ps1:1 char:1
+ aws s3 cp C:\private s3://private
+ ~~~
+ CategoryInfo          : ObjectNotFound: (aws:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

当我 RDP 进入 Windows 实例并执行相同的命令时,文件被放入 AWS 的 S3 存储桶中,没有任何问题。

我在这里遗漏了什么,还是有更好的方法来做到这一点?我正在尝试使此过程尽可能可编写脚本,而无需 SSH 连接。感谢所有输入,谢谢!

【问题讨论】:

  • 听起来系统管理器使用的 Windows 用户在其路径中没有 aws 程序。

标签: amazon-web-services amazon-s3 amazon-ec2 aws-cli ssm


【解决方案1】:

如上述评论所述,AWS Systems Manager 使用的用户没有将 AWS CLI 添加为 PATH 变量。

【讨论】:

    【解决方案2】:

    我认为 AmazonSSMAgent 需要重新启动才能获取对 Path 变量的更改。

    【讨论】:

      猜你喜欢
      • 2019-04-29
      • 2020-10-08
      • 2020-02-25
      • 2021-04-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多