Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ここが好きだよAWS管理ポリシー_devio2022/i_am_iam_lover

 ここが好きだよAWS管理ポリシー_devio2022/i_am_iam_lover

YukihiroChiba

August 01, 2022
Tweet

More Decks by YukihiroChiba

Other Decks in Technology

Transcript

  1.  ϙ˓ϞϯΑΓଟ͍"84؅ཧϙϦγʔ   "84؅ཧ ϙϦγʔͷ਺ ˞ +5$ ࣌఺ ͰΞΫςΟϒͳ΋ͷ

    ϙ˓Ϟϯͷछྨ ˞8JLJQFEJBΑΓɻୈੈ୅͸আ͘ɻ IUUQTKBXJLJQFEJBPSHXJLJશࠃϙέϞϯਤؑॱͷϙέϞϯҰཡ
  2.  ϙϦγʔ ΠϯϥΠϯϙϦγʔ ؅ཧϙϦγʔ ΧελϚʔ ؅ཧϙϦγʔ "84 ؅ཧϙϦγʔ όʔδϣϯ؅ཧɺελϯυΞϩϯɺ ෳ਺Ϧιʔε΁ͷΞλον͕Մೳ

    *".Ϧιʔε΁ͷຒΊࠐΈ "84ʹΑΓ؅ཧ͞ΕΔ ΧελϚʔ͕؅ཧ ࠓճऔΓ্͛Δͷ͸͜Ε ϙϦγʔΛΠϯϥΠϯ͔؅ཧ͔ͷ੾ΓޱͰݟ͍ͯ͘
  3.  ϙϦγʔ ΠϯϥΠϯϙϦγʔ ؅ཧϙϦγʔ ΧελϚʔ ؅ཧϙϦγʔ όʔδϣϯ؅ཧɺελϯυΞϩϯɺ ෳ਺Ϧιʔε΁ͷΞλον͕Մೳ *".Ϧιʔε΁ͷຒΊࠐΈ "84ʹΑΓ؅ཧ͞ΕΔ

    ৬຿ػೳ༻ αʔϏε ϩʔϧ༻ αʔϏεϦϯΫ ϩʔϧ 4-3 ༻ ্هҎ֎ ΧελϚʔ͕؅ཧ ϙϦγʔͷύε͔Β൑ผ ϙϦγʔΛΠϯϥΠϯ͔؅ཧ͔ͷ੾ΓޱͰݟ͍ͯ͘ "84 ؅ཧϙϦγʔ
  4. ͨͷ͍͠ʂ  ϙϦγʔ ΠϯϥΠϯϙϦγʔ ؅ཧϙϦγʔ ΧελϚʔ ؅ཧϙϦγʔ ৬຿ػೳ༻ αʔϏε ϩʔϧ༻

    αʔϏεϦϯΫ ϩʔϧ 4-3 ༻ ্هҎ֎ ͨͷ͍͠ʂ "84 ؅ཧϙϦγʔ ৽αʔϏεɺ৽ػೳͷൃදʹઌߦͯ͠ ࡞੒ɾߋ৽͞Ε͍ͯΔ͜ͱ͕ଟ͍
  5. BXTJBNMJTUQPMJDJFT  aws iam list-policies\ --scope AWS\ --max-items 1000\ |

    jq -r ' ["ϙϦγʔ໊","ύε","σϑΥϧτόʔδϣϯ","࡞੒೔࣌","ߋ৽೔࣌","ΞλονՄ൱"], (.Policies[] | [.PolicyName,.Path,.DefaultVersionId,.CreateDate,.UpdateDate,.IsAttachable]) | @csv' | pbcopy είʔϓͱͯ͠ʮ"84ʯΛࢦఆ͠ɺ KRͰඞཁͳՕॴͷΈϑΟϧλϦϯά $47Խ͠ɺ ΫϦοϓϘʔυʹίϐʔʢ.BDͷ৔߹ʣ Ұ౓ͷ࣮ߦͰશྔΛ औಘͰ͖ͳ͘ͳΔ೔΋ۙͦ͏
  6. ʮઆ໌ʯ΋ཉ͚͠Ε͹BXTJBNHFUQPMJDZ  aws iam list-policies --max-items 1000 --scope AWS |

    jq -r '.Policies[].Arn' \ | while read policy; do aws iam get-policy --policy-arn $policy \ | jq -r '.Policy | [.PolicyName,.Description] | @csv' >> policies.csv done MJTUQPMJDJFTͷ݁ՌΛͻͱͭͣͭ৯Θͤͯ HFUQPMJDZͰϙϦγʔ໊ɺઆ໌Λग़ྗ ͋ͱ͸7-00,61ؔ਺ͰؤுΔ ෼͘Β͍͔͔ͬͨ ؾ͕͠·͢
  7. આ໌ͷ௕͞ͷ্ݶ͸  ͍ͪ͹Μ௕͍ จࣈ 5IJTQPMJDZJTBUUBDIFEUPUIF&MBTUJD%JTBTUFS3FDPWFSZ3FQMJDBUJPOTFSWFSTJOTUBODF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