テストで使用するのでサクッと作りたいというご要望
方法
作成
bash
POLICY_NAME="szk302-iam-policy"
aws iam create-policy --policy-name "${POLICY_NAME}" --policy-document file://./policy.json
表示
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:Describe*",
"iam:ListRoles",
"sts:AssumeRole"
],
"Resource": "*"
}
]
}
jsonファイル使わない版
bash
POLICY_NAME="szk302-iam-policy"
aws iam create-policy --policy-name "${POLICY_NAME}" --policy-document '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":["ec2:Describe*","iam:ListRoles","sts:AssumeRole"],"Resource":"*"}]}'
削除
bash
ACCOUNT_ID=123456789012
POLICY_NAME="szk302-iam-policy"
POLICY_ARN="arn:aws:iam::${ACCOUNT_ID}:policy/${POLICY_NAME}"
aws iam delete-policy --policy-arn "${POLICY_ARN}"