为什么 AWS 访问密钥(访问密钥 ID 和秘密访问密钥)与控制台访问凭证不同,即冗长且不可读?一把钥匙,无论简单还是复杂,一旦被盗都无济于事,那么为什么不保持简单呢?
除了登录 AWS CLI 之外,在哪些情况下只有访问密钥(访问密钥 ID 和秘密访问密钥)可以提供帮助,并且推荐的使用角色的最佳实践不切实际?
在 Powershell 中使用 aws-cli 发送 JSON 结构时出错。具体来说,是调用将项目放入现有 DynamoDB 表中。
问题似乎是我尝试发送的 JSON 对象中的键和值缺少双引号。我读到,Powershell 对输出双引号很挑剔,尤其是在利用外部 API 时。
不幸的是,由于我的组织使用 okta 来验证 AWS 请求,因此我必须使用 Powershell。
我已经尝试了我在这里看到的一切:
...这里:
解析参数“--expression-attribute-values”时出错:无效 JSON:需要用双引号括起来的属性名称:第 1 行第 3 列(字符 2)
...这里:
https://github.com/aws/aws-cli/issues/1326
...和这里:
PowerShell:在传递给外部程序的字符串中转义双引号的最佳方法?例如,一个 JSON 字符串
我尝试过的:
这是基本的第一次尝试:
okta-aws dh dynamodb put-item --table-name AlexaRoomLookup-dev --item '{"deviceId": {"S":"amzn1.ask.device.AEH2LHYGV7GSPP5THMR
5H56AI2OOMAQ7MF54CZ3E6WR433WGS6QAOCYCKJWRJ3TQY5IE76NWR2IKCANB6TJNKLDEZOO2YN6ACUVT33MKSS4CO6R7GJI6GDFLOBOPUA2IXX7RI732UXJ6PDST5KYC7CSQK
634K4APEBRNVOKVZIDECOCBBIFB4"},"roomNumber": {"N":9110}}' --return-consumed-capacity TOTAL
Run Code Online (Sandbox Code Playgroud)
然后我尝试用反斜杠转义:
okta-aws dh dynamodb put-item --table-name AlexaRoomLookup-dev --item {\"deviceId\":{\"S\":\"amzn1.ask.device.AEH2LHYGV7GSPP5THMR5H56AI2OOMAQ7MF54CZ3E6WR433WGS6QAOCYCKJWRJ3TQY5IE76NWR2IKCANB6TJNKLDEZOO2YN6ACUVT33MKSS4CO6R7GJI6GDFLOBOPUA2IXX7RI732UXJ6PDST5KYC7CSQK634K4APEBRNVOKVZIDECOCBBIFB4\"},\"roomNumber\": {\"N\":9110}} --return-consumed-capacity TOTAL
Run Code Online (Sandbox Code Playgroud)
然后用反引号(我在这里用星号替换它,这样就可以将其读取为代码)和反斜杠进行转义:
{*"deviceId*": {*"S*":*"amzn1.ask.device.AEH2LHYGV7GSPP
5THMR5H56AI2OOMAQ7MF54CZ3E6WR433WGS6QAOCYCKJWRJ3TQY5IE76NWR2IKCANB6TJNKLDEZOO2YN6ACUVT33MKSS4CO6R7GJI6GDFLOBOPUA2IXX7RI732UXJ6PDST5KYC
7CSQK634K4APEBRNVOKVZIDECOCBBIFB4*"},*"roomNumber*": {*"N*":9110}}" --return- consumed-capacity TOTAL
Run Code Online (Sandbox Code Playgroud)
然后我尝试了“这里字符串”,但无济于事。
期望和结果:
我希望微软文档中的转义方法能够起作用。
上面的每一个都给出了这个错误,并根据转义方法有问题的“JSON收到”的变体,但它从来没有在键和值周围使用双引号:
Error parsing …Run Code Online (Sandbox Code Playgroud) 我试图按启动时间对实例 ID 列表进行排序(因此较旧的实例位于顶部),但由于“describe-instances”的输出在多个“Reservations”中分隔的方式,我似乎遇到了问题。
当指定单个保留时,以下内容似乎有效:
$ aws ec2 describe-instances --instance-id file://instancelist.json --query "Reservations[0] | sort_by(Instances, &LaunchTime)[].InstanceId"
[
"i-0ea6fe5asda50d5ea"
]
$ aws ec2 describe-instances --instance-id file://instancelist.json --query "Reservations[1] | sort_by(Instances, &LaunchTime)[].InstanceId"
[
"i-027c72g748aae21e2",
"i-086b329e39ee20b86",
"i-0035dd291e67e141c"
]
Run Code Online (Sandbox Code Playgroud)
但如果我尝试对多个预订执行相同的操作,我会看到:
$ aws ec2 describe-instances --instance-id file://instancelist.json --query "Reservations[*] | sort_by(Instances, &LaunchTime)[].InstanceId"
In function sort_by(), invalid type for value: None, expected one of: ['array'], received: "null"
$ aws ec2 describe-instances --instance-id file://instancelist.json --query "Reservations[0:1] | sort_by(Instances, &LaunchTime)[].InstanceId"
In function sort_by(), invalid type for value: None, expected …Run Code Online (Sandbox Code Playgroud) 我正在练习AWS命令。我的客户给了我 AWS IAM 访问密钥和秘密,但没有给我可以登录管理面板的帐户。这些密钥正在与项目本身一起使用。我想做的是尝试列出 S3 存储桶中递归的所有文件。
这就是我到目前为止所做的。
我已使用以下命令配置 CLI 的 AWS 配置文件
aws configure
Run Code Online (Sandbox Code Playgroud)
然后我可以通过运行以下命令列出所有可用的存储桶
aws s3 ls
Run Code Online (Sandbox Code Playgroud)
然后我尝试列出存储桶中的所有文件。我尝试运行以下命令。
aws s3 ls s3://my-bucket-name
Run Code Online (Sandbox Code Playgroud)
但它似乎没有给我正确的内容。另外,我还需要一种在存储桶中导航的方法。我怎样才能做到这一点?
我安装了 iTerm Build 3.3.9。我已经配置了oh-my-zsh以下插件和主题
ZSH_THEME="powerlevel10k/powerlevel10k"
ZSH_DISABLE_COMPFIX="true"
plugins=(aws git colored-man-pages colorize github virtualenv pip python osx zsh-syntax-highlighting zsh-completions zsh-autosuggestions django npm zsh-interactive-cd zsh-navigation-tools)
Run Code Online (Sandbox Code Playgroud)
现在我正在尝试解决两个问题
我需要删除其中包含一些对象的 S3 存储桶:
aws s3 rb --force s3://ansible.prod-us-east
remove_bucket failed: s3://ansible.prod-us-east An error occurred (BucketNotEmpty) when calling the DeleteBucket operation: The bucket you tried to delete is not empty. You must delete all versions in the bucket.
Run Code Online (Sandbox Code Playgroud)
我也尝试过这个:
aws s3api delete-bucket --bucket "ansible.prod-us-east" --region "us-east-1"
An error occurred (BucketNotEmpty) when calling the DeleteBucket operation: The bucket you tried to delete is not empty. You must delete all versions in the bucket.
Run Code Online (Sandbox Code Playgroud)
错误表明存储桶已满。但是当我在命令行上列出它或查看控制台中的存储桶时,存储桶已经是空的。
当我尝试从控制台删除存储桶时,出现同样的错误。存储桶是空的,但错误表明存储桶已满,我无法删除该存储桶。
我怎样才能完成这件事?
登录到 AWS EC2 管理控制台时,实例列表的第一列是“名称”(后面是“实例 ID”等)。
对于通过 AWS CLI(使用aws ec2 run-instances)创建的实例,名称字段为空。如何以编程方式设置名称?
另外,给它命名是否有任何含义(例如,它是否必须是唯一的,该名称是否被某些东西使用?)我希望将其作为有用的信息,用于从控制台管理我的实例。
当我运行时,aws --version我得到以下输出:
File "/usr/local/bin/aws", line 19, in <module>
import awscli.clidriver
File "/usr/local/aws/lib/python2.7/site-packages/awscli/clidriver.py", line 15, in <module>
import logging
ImportError: No module named logging
Run Code Online (Sandbox Code Playgroud)
我更改了 bashprofile 中的路径以反映 python3 更改,这对于其他应用程序来说运行良好,但 AWS 仍在寻找 v2.7。
如何修复此错误 - 是否更新 awscli、卸载/重新安装或其他操作?我对 bash/envs 不太熟悉,不想搞乱任何东西。
我使用安装程序预配置基础设施 (IPI) 在我的 AWS 集群上安装 openshift 4.4.9,但未能成功在 AWS 上启动我的 openshift 集群。由于以下错误。
INFO Creating infrastructure resources...
ERROR
ERROR Error: Error creating IAM instance profile ocp4-925gm-bootstrap-
profile: EntityAlreadyExists:
Instance Profile ocp4-925gm-bootstrap-profile already exists.
ERROR status code: 409, request id: b6918967-774c-44c1-8b92-02ac7388f87c
ERROR
ERROR on ../../../tmp/openshift-install-584826335/bootstrap/main.tf line 46, in resource
"aws_iam_instance_profile" "bootstrap":
ERROR 46: resource "aws_iam_instance_profile" "bootstrap" {
ERROR Error: Error creating IAM instance profile ocp4-925gm-worker-profile: EntityAlreadyExists:
Instance Profile ocp4-925gm-worker-profile already exists.
ERROR status code: 409, request id: 3b5d2b9c-28fe-4c95-b622-7a80af45dfb6
ERROR
ERROR on ../../../tmp/openshift-install-584826335/iam/main.tf line …Run Code Online (Sandbox Code Playgroud) amazon-web-services openshift aws-cli terraform terraform-provider-aws
请帮助我通过 awscli 创建一条记录很少的 NS 记录。它创建了一条记录,但记录很少时出现错误:
#!/bin/bash
function change_batch2() {
jq -c -n "{\"Changes\": [{\"Action\": \"UPSERT\", \"ResourceRecordSet\": {\"Name\": \"cluster.domain_name.\", \"Type\": \"NS\", \"TTL\": 60, \"ResourceRecords\": [{\"Value\": \"record1. record2.\"} ] } } ] }"
}
aws route53 change-resource-record-sets --hosted-zone-id <ZONE_ID> --change-batch $(change_batch2) | jq -r '.ChangeInfo.Id' | cut -d'/' -f3
Run Code Online (Sandbox Code Playgroud)
之后我有一个错误:
A client error (InvalidChangeBatch) occurred when calling the ChangeResourceRecordSets operation: [Invalid Resource Record: FATAL problem: RRDATANotSingleField (Value contains spaces) encountered with 'record1.
record2.']
Run Code Online (Sandbox Code Playgroud) aws-cli ×10
amazon-ec2 ×2
amazon-s3 ×2
json ×2
amazon-iam ×1
bash ×1
dns ×1
iterm2 ×1
macos ×1
openshift ×1
powershell ×1
python ×1
python-3.x ×1
shell ×1
terraform ×1