在“世界妇女论坛”中,无论是通过文字还是网吧,都能够找到哪些现行政策含有某种行动?
例如,我要允许<条码>米罗莱条码>>进入对我所有的EC2事例采取行动。 我知道,我可以以适当的规则制定我自己的政策,但如果存在这样的情况,我想采用现有的亚马孙政策。
在“世界妇女论坛”中,无论是通过文字还是网吧,都能够找到哪些现行政策含有某种行动?
例如,我要允许<条码>米罗莱条码>>进入对我所有的EC2事例采取行动。 我知道,我可以以适当的规则制定我自己的政策,但如果存在这样的情况,我想采用现有的亚马孙政策。
这是一个老的职位,但可以帮助某人...... 尽管其他人已经说过的话,你可以这样做。 这只是需要说明。
你可以与世界妇女联盟一道做以下工作。
• 政策分析,储存在<条码>中。
www.un.org/Depts/DGACM/index_french.htm
在每个政策中使用版本,并在<代码>policies_ver阵列中储存。
mapfile -t policies_ver < <(aws iam list-policies --query Policies[*].[DefaultVersionId] --output text)
每一政策中的休息时间,并在<条码>中储存政策文件。
for (i=0; i<${#policies_arn[@]}; i++ ); do re${policies_arn[i]} >> policies. txt && aws iam Rec-policy-version -policy-arn${policies_arn[i]} —————————————————— - 产出;
开放式<代码>policies.txt, 文本编辑,请你采取行动。
注:根据您的CLI配置,您可能或不一定需要<代码>-产出文本参数。 然而,产出必须是案文(而不是JSON),才能工作。
从那以后,你可以很容易地将这段文字变为<条码>。
产出:
arn:aws:iam::123456789012:policy/DenyAllAccess
{
"PolicyVersion": {
"CreateDate": "2016-12-06T18:40:51Z",
"VersionId": "v1",
"Document": {
"Statement": [
{
"Action": "*",
"Effect": "Deny",
"Resource": "*"
}
],
"Version": "2012-10-17"
},
"IsDefaultVersion": true
}
}
Cheers!
To elaborate on my understanding of https://stackoverflow.com/a/43128660/447862 the important thing is to get the JSON from the default version of each policy. Since my machine does not have mapfile
I opted to use Python.
import boto3, json, sys
iam = boto3.client( iam )
policy_arn = sys.argv[1]
policy_name = policy_arn.split( / )[-1]
version = iam.get_policy(PolicyArn=policy_arn)[ Policy ][ DefaultVersionId ]
policy_version = iam.get_policy_version(PolicyArn=policy_arn, VersionId=version)
policy_document = policy_version[ PolicyVersion ][ Document ]
with open(f"{policy_name}.json", w ) as outfile:
outfile.write(json.dumps(policy_document, indent=2))
outfile.write(
)
现在,作为<条码>ws-iam-policy-dump.py,我现在可以按照我的愿望,将每份政策文件写到自己的档案中,进行搜查。
aws iam list-policies --query Policies[*].Arn --output text > policy-arns.txt
for arn in $(cat policy-arns.txt); do
python aws-iam-policy-dump.py $arn
done
也许可以通过在沙尔做所有事来加快,但这种混合办法对我来说是充分的。
aws iam list-policies --query Policies[*].[Arn, DefaultVersionId] | jq -rc .[] | join(" ") | xargs -l bash -c aws iam get-policy-version --policy-arn=$0 --version-id=$1 --query="{"$0": PolicyVersion.Document.Statement[*].[Action, NotAction][][]}" | jq -c | grep YOUR_POLICY_ACTION_HERE
xargs
where the ARN and VersionId are passed in as separate parameters to get-policy-version
我在谈到这一问题时,寻求找到可能包含具体行动的现有政策的途径。 指挥部将根据政策数目在奥(n)时间进行,因为对你们的每一项政策分别发出呼吁。
我无法说明如何获得<代码>.contains()>,在最后的-query
中适当开展工作,以便一夫能够过滤而不是灰色。
纯一流的@amacleod反应:
# based on https://stackoverflow.com/questions/38270609/can-i-search-existing-iam-policies-for-a-specific-action
# https://www.learnaws.org/2021/05/12/aws-iam-boto3-guide/
import boto3, json, sys
iam = boto3.client( iam )
def write_policy(policy_arn):
# policy_arn = sys.argv[1]
policy_name = policy_arn.split( / )[-1]
version = iam.get_policy(PolicyArn=policy_arn)[ Policy ][ DefaultVersionId ]
policy_version = iam.get_policy_version(PolicyArn=policy_arn, VersionId=version)
policy_document = policy_version[ PolicyVersion ][ Document ]
with open(f"{policy_name}.json", w ) as outfile:
outfile.write(json.dumps(policy_document, indent=2))
outfile.write(
)
def list_policies():
paginator = iam.get_paginator( list_policies )
for response in paginator.paginate(Scope="Local"):
for policy in response["Policies"]:
print(f"Policy Name: {policy[ PolicyName ]} ARN: {policy[ Arn ]}")
write_policy(policy[ Arn ])
if __name__ == __main__ :
list_policies()
由于我多年来一直在探寻并发现这一问题和一套答案,这里有“平原编码”
$ aws iam list-policies --query Policies[*].[PolicyName, Arn, DefaultVersionId] --output text |
while read NAME ARN VER; do
echo "$NAME $(aws iam get-policy-version --policy-arn=$ARN --version-id=$VER --query PolicyVersion.Document.Statement[*].Action[] --output text | tr )"
done > policies.txt
这样做需要时间,但我可以很快地抓住产出,找到我可以再利用的现有政策。
In MWAA startup script sudo yum install samba-client cifs-utils -y sudo mount.cifs //dev/test/drop /mnt/dev/test-o username=testuser,password= pwd ,domain=XX Executing above commonds giving error - ...
How can I deploy a Django project that uses MongoDB to AWS? I have a project made using Django and have been using MongoDB and its Compass app and was wondering if you could deploy said project and ...
I ve looked through the documentation, I ve tried downloading various example code, and I ve tried hacking various permutations. After a full day s worth of work, I m spent, and throwing in the towel. ...
We have been manually been keying Amazon orders into our system and would like to automate it. However, I can t seem to figure out how to go about it. Their documentation is barely there. There is: ...
I want to use Amazon S3/CloudFront to store flash files. These files must be private as they will be accessed by members. This will be done by storing each file with a link to Amazon using a mysql ...
actually I have my website build with Joomla hosted on hostmonster but all Joomla website need a database support to run this database is on AWS configuration files need to be updated for that I ...
I currently have a virtual dedicated server through Media Temple that I use to run several high traffic Wordpress blogs. Both tend to receive sudden StumbleUpon traffic surges that (I m assuming) ...
We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...