我目前正在使用 AWS cli 在 DynamoDB 中创建一个表。我正在使用的命令是
aws dynamodb create-table --cli-input-json file://.feature_promotions-dynamodb.json --endpoint-url http://localhost:8000
Run Code Online (Sandbox Code Playgroud)
根据 的文档create-table,我应该能够将计费模式设置为,而PAY_PER_REQUEST不必设置预配置的吞吐量,但每次运行命令时我都会收到以下错误:
An error occurred (ValidationException) when calling the CreateTable operation: No provisioned throughput specified for the table
Run Code Online (Sandbox Code Playgroud)
我awscli昨天升级到
aws-cli/1.16.90 Python/3.7.2 Darwin/18.2.0 botocore/1.12.80
Run Code Online (Sandbox Code Playgroud)
除此之外,我不知道如何解决它。目前我的解决方法是仅创建具有预配置吞吐量的表,然后转到控制台进行更改,但这似乎没有必要。最终,我希望能够在 bash 脚本中运行此命令,而不必稍后修复 AWS 控制台中的表设置。
下面是我在命令中加载的 JSON 文件create-table。"BillingMode": "PAY_PER_REQUEST"属性和值是在之后设置的"AttributeDefinition",我希望它能够正常工作而不会出现任何错误。如果我删除计费模式行,并将以下属性添加到文件中
"ProvisionedThroughput": {
"ReadCapacityUnits": 1,
"WriteCapacityUnits": 1
}
Run Code Online (Sandbox Code Playgroud)
它创建的表没有任何错误。
{
"TableName": "dev.feature_promotions",
"AttributeDefinitions": [
{
"AttributeName": "display_title",
"AttributeType": "S"
},
{
"AttributeName": "end_date",
"AttributeType": …Run Code Online (Sandbox Code Playgroud) 当我在 s3 存储桶中存储的 json 文件的对象 URL中遇到两种不同的行为时,我的问题就出现了。
考虑一个 json 文件:mydata.json
如果我使用 AWS 网站上的 s3 仪表板上传此文件,我可以在浏览器中查看数据://s3-us-west-2.amazonaws.com/bucket/folder/mydata.json。如果我在 s3 存储桶中创建特定配置,我还可以从不同的应用程序读取此数据。
另一方面,如果我使用boto3python 库并在同一个存储桶中上传相同的文件(在此过程中使文件公开),当我单击对象 URL时,它会下载该文件,但不会在浏览器中打开数据。
这是我使用的代码:
# upload json file
bucket.upload_file(path, jsonkey)
object_acl = s3.ObjectAcl('bucket_name', jsonkey)
bucket_response = object_acl.put(ACL='public-read')
Run Code Online (Sandbox Code Playgroud)
我探索了文件属性,例如元数据。当我通过仪表板上传文件时,分配的元数据是Content-Type: application/json,通过boto3是Content-Type: binary/octet-stream。我真的不知道元数据是否会影响对象 URL行为。
在这种情况下,如何正确配置要下载或读取的 json 格式文件?我的意思是,影响对象 URL行为的主要配置是什么?
除了元数据之外,我在属性或权限方面找不到这两种方法(dashboard 和 boto3)之间的显着差异Content-Type。然而,当我试图改变时Content-Type,行为却是一样的。
我可以提供任何其他信息来澄清这个问题,请随时询问。提前致谢。
我应该使用什么查询来获取以特定字符串开头的所有 CloudFormation 堆栈?
我尝试了以下查询,但它总是返回一个空数组:
aws cloudformation describe-stacks --no-paginate --query "Stacks[?StackName!='null']|[?starts_with(StackName,'HD-') == 'true']"
Run Code Online (Sandbox Code Playgroud)
我们帐户中的所有堆栈都以“HD-”开头,因此这应该返回与
aws cloudformation describe-stacks --no-paginate
Run Code Online (Sandbox Code Playgroud)
但它返回
[]
Run Code Online (Sandbox Code Playgroud) 如何使用 AWS CLI 命令添加下面列出的 SQS 权限?
"Statement": [
{
"Sid": "Sid8390000202",
"Effect": "Allow",
"Principal": "*",
"Action": "SQS:*",
"Resource": "arn:aws:sqs:us-east-1:12345678:example-queue",
"Condition": {
"ArnEquals": {
"aws:SourceArn": "arn:aws:sns:us-east-1:73628827939:MySNS"
}
}
}
]
Run Code Online (Sandbox Code Playgroud) 我们在 AWS 帐户之一中创建了 ElasticSearch 域。
我们正在尝试使用AWS cli命令来“描述”这个域。
aws es describe-elasticsearch-domain --domain-name <domain-name>
Run Code Online (Sandbox Code Playgroud)
但接收错误:
调用DescribeElasticsearchDomain操作时发生错误(ResourceNotFoundException):找不到域:
我们然后使用 list-domain 命令:
aws es list-domain-names
Run Code Online (Sandbox Code Playgroud)
但收到空响应:
{ “域名”: [] }
我们仔细检查了帐户信息。和 .aws 文件夹中的凭据,并且我们指向正确的 aws 帐户,还可以查看该帐户中除 ElasticSearch 之外的其他资源。
任何帮助表示赞赏。
我可以通过以下方式查看我的实例:
$ aws ec2 describe-instances --output text
RESERVATIONS 193693970645 r-06e25c9702ca1a586
INSTANCES 0 x86_64 False True xen ami-00c03f7f7f2ec15c3 i-03006b8712ac593f9 t2.micro mdaws 2019-10-11T12:08:56.000Z /dev/xvda ebs User initiated (2019-10-11 12:51:09 GMT) hvm
CAPACITYRESERVATIONSPECIFICATION open
CPUOPTIONS 1 1
HIBERNATIONOPTIONS False
MONITORING disabled
PLACEMENT us-east-2c default
STATE 48 terminated
STATEREASON Client.UserInitiatedShutdown Client.UserInitiatedShutdown: User initiated shutdown
Run Code Online (Sandbox Code Playgroud)
但是当我只想要几个字段时,如何挑选终止代码(48)或描述(终止)?
我尝试过一些事情,包括:
$ aws ec2 describe-instances --query "Reservations[*].Instances[*].[InstanceId, ImageId, State]" --output text
'str' object has no attribute 'items'
$ aws ec2 describe-instances --query "Reservations[*].Instances[*].[InstanceId, ImageId, State[*]]" --output text
i-03006b8712ac593f9 ami-00c03f7f7f2ec15c3 …Run Code Online (Sandbox Code Playgroud) 给定 VPC id;我使用 AWS CLI 和 jq 来派生给定 VPC ID 的 NAT 网关地址。这是我到目前为止所拥有的:
aws ec2 describe-nat-gateways --region='${aws_region}' | jq -r --arg efs_name ${vpcid} '.[] | .[] | select(.VpcId==$vpcid) | {nats: .NatGatewayAddresses}'
Run Code Online (Sandbox Code Playgroud)
输出是:
{
"nats": [
{
"PublicIp": "52.34.207.107",
"NetworkInterfaceId": "eni-0bc0d320",
"AllocationId": "eipalloc-fa7739c0",
"PrivateIp": "172.20.130.224"
}
]
}
Run Code Online (Sandbox Code Playgroud)
有没有办法PublicIp直接使用 AWS CLI 筛选器获取 nat-gateways 资源?
我花了一周的时间尝试使用 Boto3 v1.10.39 删除/更新插入简单的 Route 53 资源记录。
resp=r53_client.change_resource_record_sets(
HostedZoneId=<ZONE_ID>,
ChangeBatch={
'Comment': 'del_ip',
'Changes': [
{
'Action': 'DELETE',
'ResourceRecordSet': {
'Name': <SUBDOMAIN>,
'Type': 'A',
'Region': 'us-east-1',
'TTL': 300,
'ResourceRecords': [{'Value': <OLD_IP>}]
}
}
]
}
)
Run Code Online (Sandbox Code Playgroud)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/botocore/client.py", line 272, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/usr/lib/python2.7/dist-packages/botocore/client.py", line 576, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.errorfactory.InvalidInput: An error occurred (InvalidInput) when calling the ChangeResourceRecordSets operation: Invalid request: Missing field …Run Code Online (Sandbox Code Playgroud) 我一直在使用 AWS Glue 工作流程来编排批处理作业。我们需要传递下推谓词以限制批处理作业的处理。当我们单独运行 Glue 作业时,我们可以在运行时将下推谓词作为命令行参数传递(即 awsgluestart-job-run --job-name foo.scala --arguments --arg1-text ${arg1} ..)。但是当我们使用glue工作流程来执行Glue作业时,就有点不清楚了。
当我们使用 AWS Glue 工作流程编排 Batch 作业时,我们可以在创建工作流程时添加运行属性。
我试过:
awsgluestart-workflow-run --name 工作流程名称 | jq -r '.RunId'
awsglue put-workflow-run-properties --name 工作流名称 --run-id "ID" --run-properties --pushdownpredicate="some value"
我可以使用 put-workflow-run-property 查看已传递的运行属性
awsglue put-workflow-run-properties --name 工作流程名称 --run-id "ID"
但我无法在我的胶水作业中检测到“pushdownpredicate”。知道如何在胶水作业中访问工作流的运行属性吗?
我正在尝试通过 AWS CLI 将 ami 从一个区域复制到另一个区域。
以下命令可以很好地将 ami 复制到同一区域:
aws ec2 copy-image --name ami-copy-test --source-image-id ami-123... --source-region us-east-1
Run Code Online (Sandbox Code Playgroud)
但我试图复制到不同的区域,例如 us-east-2。
好像没有旗帜--destination-region。文档页面:
https://docs.aws.amazon.com/cli/latest/reference/ec2/copy-image.html
指出:
您可以在发出请求时使用其端点来指定目标区域。
但这实际上意味着什么?
aws-cli ×10
amazon-ec2 ×2
boto3 ×2
amazon-ami ×1
amazon-iam ×1
amazon-s3 ×1
amazon-sqs ×1
aws-glue ×1
aws-sdk ×1
cmd ×1
jmespath ×1
jq ×1
json ×1
node.js ×1
python-2.7 ×1