概要
- 自分のPCでデプロイすると、スペックが低いためかビルド/デプロイにめちゃくちゃ時間がかかる
- ワンちゃんGitHubActionsのほうが性能が高い説があるので試してみる
方法
ひとまずこれを参考にしてやってみる
なるべく元サイトと同じような形でやろうと思います
ID プロバイダの作成
公式にもこう書いてありますね
1.以下のURLの場所に遷移します。
3.次のように入力します
- プロバイダの URL:https://token.actions.githubusercontent.com
- 対象者:sts.amazonaws.com
5.IAMロールを作ります
以下は公式サイトをそのまま持ってきました。
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
- "Federated": "arn:aws:iam::123456123456:oidc-provider/token.actions.githubusercontent.com"
+ "Federated": "arn:aws:iam::自分のやつ:oidc-provider/token.actions.githubusercontent.com"
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringLike": {
- "token.actions.githubusercontent.com:sub": "repo:octo-org/octo-repo:*"
+ "token.actions.githubusercontent.com:sub": "repo:アカウント名/対象レポジトリ:*"
},
"StringEquals": {
"token.actions.githubusercontent.com:aud": "sts.amazonaws.com"
}
}
}
]
}
下に、組織等を入れる場所がある感じです。
今回はひとまずこんな感じにしました。
IAMがフルなのは怖いので後で直す予定です
このあと、CloudFrontなどほかに必要な奴めちゃ追加しました。
後からインラインポリシー等で調整できるので、最初は動かない前提でやるのがよさそう
ワークフローを設定する
ひとまずお試しなので、参考サイトまんまです。
.github/workflows/deploy.yaml
name: Deploy-AWS-SAM-Application
on:
push:
branches:
- 'develop'
env:
TEMPLATE_FILE: template.yaml
SAM_CLI_TELEMETRY: 0
permissions:
id-token: write
contents: read
jobs:
deploy:
runs-on: ubuntu-22.04
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: aws-actions/setup-sam@v2
with:
use-installer: true
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::194722430871:role/github-actions-role
aws-region: ap-northeast-1
role-session-name: SamDeploy
- run: sam build
- run: sam deploy --no-confirm-changeset --no-fail-on-empty-changeset
NextJs on lambda 試行錯誤
独自にカスタマイズする中で苦労した部分について
Nextのほうは記載次第つい