tl;dr
MY_TEAM_AWS_${ACCOUNT_NAME}_${IAM}_AKIAXXXXXXXX
ã¿ãããªã·ã¼ã¯ã¬ããåã«ãã¾ãããã¨ãã話ã§ã
æ¬ç·¨
èªåã®ãã¼ã ã§ã¯JenkinsããGitHub Actions(GHA)ã¸ã®è±åºãç¶ç¶çã«ãã£ã¦ããããããã¯ãã«æ´å²ãããããJenkinsããããããªæã§ä½¿ããã¦ãã¦ããªããªãè±åºã§ããªãã
ãã®ä¸ç°ã¨ãã¦ãcredentialã使ã£ã¦AWSã«ã¢ã¯ã»ã¹ããã¨ããworkflowãæ¸ãæ©ä¼ããã£ãã®ã§ã¡ã¢ã
(PrivateãªGitHubãªãã¸ããªãéç¨ãã¦ããã¨ããåæã®è©±ã§ã)
åæ
å¤é¨ããå¼ã³ãããã°IAMã§credentialçºè¡ããå¿ è¦ããã
GHAã®ãããªå¤é¨ãµã¼ãã¹ããAWSã®ãµã¼ãã¹ã«ã¢ã¯ã»ã¹ããã¨ãã«ã¯ãIAMã§credentialãçºè¡ãã¦ããã使ã£ã¦ããã
IAMã¯ä»¥ä¸ã®ãããªå½¢å¼ã§ãã¢ã¯ã»ã¹ãã¼IDã¨ã·ã¼ã¯ã¬ããã¢ã¯ã»ã¹ãã¼ã¨ãçºè¡ããã
- ã¢ã¯ã»ã¹ãã¼ID
AKIAXXXXXXXXXXXX
ã¿ãããªå½¢å¼
- ã·ã¼ã¯ã¬ããã¢ã¯ã»ã¹ãã¼
- ã©ã³ãã ãªè±å
GitHubã«Secretã¨ãã¦ä¿åãã
è¨ãã¾ã§ããªããIAMã®credentialããã®ã¾ã¾workflowã«ãã¿æ¸ããã¦ã¯ãªããªãã®ã§ãGitHubã«ã¯Secretsæ©è½ããããCredentialãOrganization SecretsãRepository Secretsã¨ãã¦ç»é²ãã¦ãããã«ç»é²ããã·ã¼ã¯ã¬ããåã§workflowããã¢ã¯ã»ã¹ã§ããããã«ããã¨ããææ³ã使ãã
... env: SECRET_ENV: ${{ secrets.ããã«secretã®ååãæ¸ãè¾¼ãã¨ããæãã«ç½®æããã }} ...
ã¢ã¯ã»ã¹ãã¼IDã¯é ããªãã¦ãã
ã¨ããã§ãèªåã®ãã¼ã ã®å¾æ¥ã®éç¨ã¯ããã ã£ããããªãã¡ãã¢ã¯ã»ã¹ãã¼IDã¨ã·ã¼ã¯ã¬ããã¢ã¯ã»ã¹ãã¼ã¨ã®ä¸¡æ¹ãRepository/Organization Secretsã¨ãã¦ç»é²ããã
- ã·ã¼ã¯ã¬ãã
MY_TEAM_AWS_ACCESS_KEY_ID
- IAMã®ã¢ã¯ã»ã¹ãã¼IDãæ ¼ç´ãã
- ã·ã¼ã¯ã¬ãã
MY_TEAM_AWS_SECRET_ACCESS_KEY
- IAMã®ã·ã¼ã¯ã¬ããã¢ã¯ã»ã¹ãã¼ãæ ¼ç´ãã
ãã ããã®ææ³ã«ã¯æ¬ ç¹ããã£ã¦ããã®ãã¼ãã©ãã§çæãããã®ãåãããªãã®ã§ããã¼ã交æãããã¨ãçã«å°ã£ã¦ãã¾ãã¨ããåé¡ããã£ããããã¦ãé ç®ã2ã¤ãããã¨å®éé¢åèãã
ããã§ãä»åããã¯æ¬¡ã®ãããªéç¨ã«åãæ¿ãã¦ã¿ããããªãã¡ãã·ã¼ã¯ã¬ããã¢ã¯ã»ã¹ãã¼ã®ã¿ãRepository/Organization Secretsã¨ãã¦ç»é²ãããã®ååã«ã¢ã¯ã»ã¹ãã¼IDãå«ããã
- ã·ã¼ã¯ã¬ãã
MY_TEAM_AWS_${ACCOUNT_NAME}_${IAM}_AKIAXXXXXXXX
- ã·ã¼ã¯ã¬ããå称ã«AWSã¢ã«ã¦ã³ãåãIAMã¦ã¼ã¶åãããã¦
AKIA...
ã§å§ã¾ãã¢ã¯ã»ã¹ãã¼IDãå«ãã¦ãã
- ã·ã¼ã¯ã¬ããå称ã«AWSã¢ã«ã¦ã³ãåãIAMã¦ã¼ã¶åãããã¦
ãã®ææ³ã®è¯ãã¨ããã¯ãã©ãã®ã¢ã«ã¦ã³ããªã®ã(ã¢ã«ã¦ã³ãåé¢ãã¦ããã¨ãã«å½¹ç«ã¤)ãIAMã®èª°ã®credentialãªã®ããããã¦ã©ã®credentialãªã®ãä¸æã«ç¹å®ã§ããã¨ããã éç¨ãããªããããããªããããåããªãã¨æã£ãããã£ããå¥ã¢ã«ã¦ã³ãã®credentialãã²ãã¥ãã¦ãã!!ãã¿ãããªãããããæ¸ãããã
ã¨ããã§ãã¢ã¯ã»ã¹ãã¼IDãè¦ããç¶æ ã«ãªããè¯ãã®ãã¨ããåããçãããããããã社å ã®GitHubãªãã¸ããªã«ã¢ã¯ã»ã¹ã§ããã¦ã¼ã¶ã¯IAMãè¦ãããã¯ãã ãã¨ããä»®å®ã«ç«ã£ã¦ãè¦ããã¦ãåé¡ãªãããã¨èãã¦ãããã ããããããããIDã¨ã·ã¼ã¯ã¬ãããåãã¦ããã®ã ããããåé¡ãªãã¯ãã