我正在使用Red Hat EC2实例来运行AWS CLI命令并使用Glacier和S3管理一些任务。我还在设计一个Rest API,以便执行我在EC2上部署的脚本。使用Postman向EC2的公共DNS地址发送POST请求,我的脚本将接受原始JSON并对其解码我的PHP脚本将参与的参数。当我尝试在我的内部执行AWS CLI命令时遇到错误PHP脚本。当我在终端中运行AWS命令时,AWS命令会起作用。
我从这个帖子尝试过的东西
https://github.com/aws/aws-cli/issues/3542:
邮差回应
Traceback (most recent call last):
File "/usr/bin/aws", line 19, in <module>
import awscli.clidriver
File "/usr/lib/python2.7/site-packages/awscli/clidriver.py", line 17, in <module>
import botocore.session
File "/usr/lib/python2.7/site-packages/botocore/session.py", line 30, in <module>
import botocore.credentials
File "/usr/lib/python2.7/site-packages/botocore/credentials.py", line 42, in <module>
from botocore.utils import InstanceMetadataFetcher, parse_key_val_file
File "/usr/lib/python2.7/site-packages/botocore/utils.py", line 31, in <module>
import botocore.httpsession
File "/usr/lib/python2.7/site-packages/botocore/httpsession.py", line 7, in <module>
from urllib3.util.ssl_ import (
ImportError: cannot import name DEFAULT_CIPHERS
Php脚本
exec("aws s3 cp s3://$BucketName /path/to/dir/ --recursive 2>&1",$output,$return);
我期望AWS CLI命令由exec命令执行并返回一个字符串输出,我将作为响应发回。
通过运行此命令解决了此问题
sudo pip install awscli --force-reinstall --upgrade