我通过 aws 命令部署静态应用程序。我通过以下命令将所有文件从我的文件夹复制到 s3 存储桶:
aws s3 sync C:\app s3://myBucket
Run Code Online (Sandbox Code Playgroud)
我想将内容编码设置为 gzip 仅用于 js、jpg 和 html 文件。通过此命令,我成功地为所有文件夹执行了此操作:--content-encoding gzip
如何仅针对特定文件类型执行此操作?
我有一些 EC2 实例。我想使用该ec2 describe-instances命令根据标签的特定值获取实例列表。
该表显示了我的用例。
Instance | Value (key:Purpose) | Outcome
----------+-------------------------+------------
InstanceA | Going | Filter
InstanceB | Shopping,Going | Filter
InstanceC | Going,Shoping | Filter
InstanceD | Shopping,Going,Chatting | Filter
InstanceE | GoingGreat | DONT Filter
InstanceF | NotGoing | DONT Filter
Run Code Online (Sandbox Code Playgroud)
所以我想以某种方式在 ec2-describe-instances 命令中使用通配符,以便获得预期的结果。
我正在使用 AmazonAwsCli 编写一个 shell 脚本来更新 dynamodb 表中项目的属性。我想为多个项目更新表中的属性。我正在从文件中读取属性值,并尝试通过在命令中注入 shell 脚本变量的值来更新表。http://docs.aws.amazon.com/cli/latest/reference/dynamodb/update-item.html 上的文档建议使用单独的 json 文件作为 expression-attribute-names 和 expression-attribute-values。但是,我不想创建单独的 json 文件。相反,我想编写一个命令来更新给定属性值的项目。
My table name = MY_TABLE_NAME
hashkey = AccountId
shell script variable holding the value of AccountId = accountId
attribute name that needs to be updated = Version
shell script variable holding the value of Version = ver
Run Code Online (Sandbox Code Playgroud)
我有类似的东西:
aws dynamodb update-item --table-name MY_TABLE_NAME --key '{"AccountId": {"S": '$accountId'}}' --update-expression "SET Version = '{"Version": {"S ": '$ver'}}'" --condition-expression "attribute_exists(Version)" --return-values UPDATED_NEW
但是,上面的命令不起作用。有人能指出我正确的语法吗?
关于 AWS S3 工具“同步”和“客户提供的加密密钥”,它在这里说,
--sse-c-key(字符串)客户提供的加密密钥,用于服务器端加密 S3 中的对象。如果您提供此值,则还要指定 --sse-c。提供的密钥不应是 base64 编码的。
如何在命令行上提供一个不是 base64 编码的密钥?
如果密钥不是 base64 编码的,那么密钥的某些字节肯定不能表示为字符?
我有一个脚本可以通过 CLI 使用 Spark 和 Zeppelin 启动 EMR,还有一个引导操作来安装 Anaconda python。
aws emr create-cluster --applications Name=Hadoop Name=Hive Name=Spark \
Name=Zeppelin-Sandbox \
...... \
--bootstrap-actions \
'[{"Path":"s3://mybucket/python_config.sh","Name":"Python_Config"},\
{"Path":"s3://mybucket/export_var.sh","Name":"Export_Variables"}]'
Run Code Online (Sandbox Code Playgroud)
我尝试在引导操作期间配置 zeppelin-env.sh,以便将笔记本存储到 s3 存储桶中。我有第二个脚本可以向文件中插入三行,但是没有用。
#!/bin/bash
echo 'export ZEPPELIN_NOTEBOOK_S3_BUCKET=mybucket' | sudo tee -a /etc/zeppelin/conf.dist/zeppelin-env.sh
echo 'export ZEPPELIN_NOTEBOOK_S3_USER=zeppelin' | sudo tee -a /etc/zeppelin/conf.dist/zeppelin-env.sh
echo 'export ZEPPELIN_NOTEBOOK_STORAGE=org.apache.zeppelin.notebook.repo.S3NotebookRepo' | sudo tee -a /etc/zeppelin/conf.dist/zeppelin-env.sh
Run Code Online (Sandbox Code Playgroud)
然后我尝试添加另一个引导操作以通过 yum 而不是应用程序命令“Name=Zeppelin-Sandbox”安装 zeppelin。
#!/bin/bash
cd /home/hadoop/
sudo yum -y install zeppelin
echo 'export ZEPPELIN_NOTEBOOK_S3_BUCKET=mybucket' | sudo tee -a /etc/zeppelin/conf.dist/zeppelin-env.sh
echo 'export ZEPPELIN_NOTEBOOK_S3_USER=zeppelin' | sudo …Run Code Online (Sandbox Code Playgroud) 我之前做过aws configure并测试过它是否有效。但是今天没有用,我在尝试获取托管区域时遇到了错误
$ aws route53 list-hosted-zones
An error occurred (InvalidClientTokenId) when calling the ListHostedZones operation: The security token included in the request is invalid.
Run Code Online (Sandbox Code Playgroud)
我删除了 ~/.aws 并aws configure再次执行,但我仍然遇到相同的错误。能否请你帮忙?谢谢!
我正在寻找使用 python 的 boto3 模块向 dynamodb 批量写入项目,我得到了这个。这是我第一次使用 aws cli 或 boto3。文档说当存在空值和可能不正确的数据类型时会发生验证异常错误,但我已经玩过所有这些并且它似乎不起作用。
dynamodb 是否只喜欢一次写入 25 个项目?如果是这样,我如何控制这些批次?
我的请求:
client = boto3.client('dynamodb')
response = client.batch_write_item(RequestItems=batch_dict)
Run Code Online (Sandbox Code Playgroud)
batch_dict 的顶部:
{'scraper_exact_urls': [{'PutRequest': {'Item': {'Sku': {'S': 'T104P3'},
'pps_id': {'N': '427285976'},
'scraper_class_name': {'S': 'scraper_class_name'},
'store_id': {'N': '1197386754'},
'updated_by': {'S': 'user'},
'updated_on': {'N': '1480714223'},
'updated_url': {'S': 'http://www.blah.com'}}}},
{'PutRequest': {'Item': {'Sku': {'S': 'T104P3'},
'pps_id': {'N': '427285976'},
'scraper_class_name': {'S': 'scraper_class_name'},
'store_id': {'N': '1197386754'},
'updated_by': {'S': 'user'},
'updated_on': {'N': '1480714223'},
'updated_url': {'S': 'http://www.blah.com'}}}},....
Run Code Online (Sandbox Code Playgroud)
架构:
属性:“pps_id”=>\Aws\DynamoDb\Enum\Type::NUMBER、“sku”=>\Aws\DynamoDb\Enum\Type::STRING、“scraper_class_name”=>\Aws\DynamoDb\Enum\Type: :STRING, "store_id"=>\Aws\DynamoDb\Enum\Type::NUMBER, "updated_url"=>\Aws\DynamoDb\Enum\Type::STRING, "updated_by"=>\Aws\DynamoDb\Enum\Type ::STRING, "updated_on"=>\Aws\DynamoDb\Enum\Type::NUMBER, 字段: …
我想使用 awscli 编辑/更新我的 CloudFront 分配。
我正在使用最新的 cli 版本:
aws-cli/1.11.56 Python/2.7.10 Darwin/16.4.0 botocore/1.5.19
要在 awscli 中使用 cloudfront 功能,您需要将其添加到 aws 配置文件中:
[preview]
cloudfront = true
Run Code Online (Sandbox Code Playgroud)
我正在获取要修改的发行版的配置:
aws cloudfront get-distribution-config --id FOO_BAR_ID > cf_config.json
看起来它按预期工作。配置对我来说没问题。现在我正在尝试使用相同的配置重新配置我的 CF 发行版。
aws cloudfront update-distribution --distribution-config file://cf_config.json --id FOO_BAR_ID
我得到:
Parameter validation failed:
Missing required parameter in DistributionConfig: "CallerReference"
Missing required parameter in DistributionConfig: "Origins"
Missing required parameter in DistributionConfig: "DefaultCacheBehavior"
Missing required parameter in DistributionConfig: "Comment"
Missing required parameter in DistributionConfig: "Enabled"
Unknown parameter in DistributionConfig: "ETag", …Run Code Online (Sandbox Code Playgroud) 我正在构建一个更大的 AWS CLI 工作,但其中一个构建块让我感到困惑;
如何获取当前正在运行的每个 AWS Cloudformation 堆栈的名称列表?
我可以使用以下内容很好地列出堆栈,但我无法获得将其与堆栈名称配对的查询。
aws cloudformation list-stacks --stack-status-filter CREATE_COMPLETE --output text
Run Code Online (Sandbox Code Playgroud)
我可以在 bash 中减少结果表,但如果存在更优雅的 aws 解决方案,我会喜欢。
我正在使用 AWS CLI 在脚本中创建 CloudFront 分配:
aws configure set preview.cloudfront true
aws cloudfront create-invalidation --distribution-id ABCD1234 --paths '/*'
Run Code Online (Sandbox Code Playgroud)
我用这个语句设置了一个策略:
{
"Sid": "xxx",
"Effect": "Allow",
"Action": [
"cloudfront:CreateInvalidation"
],
"Resource": [
"arn:aws:cloudfront::xxx:distribution/ABCD1234"
]
}
Run Code Online (Sandbox Code Playgroud)
该策略附加到运行命令的用户。但是,我仍然收到此错误:
调用 CreateInvalidation 操作时出现客户端错误 (AccessDenied):用户:arn:aws:iam::xxx:user/yyy 未获授权执行:cloudfront:CreateInvalidation