我创建了 Rundeck 密钥存储并在其中存储了密码
然后在内联脚本中我指定了以下内容(keys/JIRA 是 Rundeck 密码存储)
curl -XN -u user:keys/JIRA
Run Code Online (Sandbox Code Playgroud)
但是密码没有通过,认证失败,我做错了什么?
我正在使用此代码来获取IAM用户:
#!/usr/bin/env python
import boto3
import json
client = boto3.client('iam')
response = client.list_users(
)
print response
Run Code Online (Sandbox Code Playgroud)
得到:
{u'Users': [{u'UserName': 'ja', u'Path': '/', u'CreateDate': datetime.datetime(2018, 4, 6, 12, 41, 18, tzinfo=tzutc()), u'UserId': 'AIDAJXIHXCSI62ZQKLGZM', u'Arn': 'arn:aws:iam::233135199200:user/ja'}, {u'UserName': 'test', u'Path': '/', u'CreateDate': datetime.datetime(2018, 4, 7, 10, 55, 58, tzinfo=tzutc()), u'UserId': 'AIDAIENHQD6YWMX3A45TY', u'Arn': 'arn:aws:iam::233135199200:user/test'}], 'ResponseMetadata': {'RetryAttempts': 0, 'HTTPStatusCode': 200, 'RequestId': 'ebd600f0-3a52-11e8-bc50-d37153ae8ac5', 'HTTPHeaders': {'x-amzn-requestid': 'ebd600f0-3a52-11e8-bc50-d37153ae8ac5', 'date': 'Sat, 07 Apr 2018 11:00:44 GMT', 'content-length': '785', 'content-type': 'text/xml'}}, u'IsTruncated': False}
Run Code Online (Sandbox Code Playgroud)
我保存了对JSON文件的响应
我只需要提取用户名,以便在这种情况下输出应为2行:
ja
test
Run Code Online (Sandbox Code Playgroud)
添加时
print response['Users'][0]['UserName'] …Run Code Online (Sandbox Code Playgroud) 有没有办法使用 boto3 列出所有 AWS 安全组?
使用此代码我只能获得 5 个组(该地区的 25 个组中)
client = boto3.client('ec2')
response=client.describe_security_groups(
)
print response
Run Code Online (Sandbox Code Playgroud)
我有 4 个 VPC,因此我尝试为每个 VPC 获取组,并将其添加为过滤器:
Filters=[
{
'Name': 'vpc-id',
'Values': [
'vpc-d60ee9b1',
]
},
],
Run Code Online (Sandbox Code Playgroud)
但结果我得到了这个:
{u'SecurityGroups': [], 'ResponseMetadata': {'RetryAttempts': 0, 'HTTPStatusCode': 200, 'RequestId': '44f39633-4f21-4c4f-b3f4-82fbce538c5f', 'HTTPHeaders': {'transfer-encoding': 'chunked', 'vary': 'Accept-Encoding', 'server': 'AmazonEC2', 'content-type': 'text/xml;charset=UTF-8', 'date': 'Thu, 03 May 2018 08:25:03 GMT'}}}
Run Code Online (Sandbox Code Playgroud)
尝试按地区过滤并得到:The filter 'region' is invalid
但是,使用 AWS CLI 可以正常工作:
aws ec2 describe-security-groups --region $REGION
Run Code Online (Sandbox Code Playgroud)
这是否意味着我需要坚持使用 AWS CLI 或者 boto3 具有列出 …