Skip to content

Commit 3e9e529

Browse files
fix: Add AWS account ID validation and debug info for GitHub Secrets
- Add validation to ensure AWS account ID is properly retrieved - Add debug information showing the exact ARN being registered - Improve error handling for AWS account ID retrieval - Add manual setup instructions when GitHub Secrets registration fails - Fix potential issue where account ID might be missing from ARN
1 parent 0306442 commit 3e9e529

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

create_role.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,12 @@ if (-not $GITHUB_CLI_WORKING) {
917917
# 6. AWSアカウントIDの取得
918918
Write-Info "AWSアカウントIDの取得中..."
919919
$AWS_ACCOUNT_ID = aws sts get-caller-identity --query Account --output text 2>$null
920+
if (-not $AWS_ACCOUNT_ID -or $AWS_ACCOUNT_ID -eq "None") {
921+
Write-Error "AWSアカウントIDの取得に失敗しました"
922+
Write-Info "AWS認証情報を確認してください"
923+
aws sts get-caller-identity
924+
exit 1
925+
}
920926
Write-Success "AWSアカウントID: $AWS_ACCOUNT_ID"
921927

922928
# AWSリージョンの確認

create_role.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,12 @@ fi
941941
# 6. AWSアカウントIDの取得
942942
print_info "AWSアカウントIDの取得中..."
943943
AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
944+
if [ -z "$AWS_ACCOUNT_ID" ] || [ "$AWS_ACCOUNT_ID" = "None" ]; then
945+
print_error "AWSアカウントIDの取得に失敗しました"
946+
print_info "AWS認証情報を確認してください"
947+
aws sts get-caller-identity
948+
exit 1
949+
fi
944950
print_success "AWSアカウントID: $AWS_ACCOUNT_ID"
945951

946952
# AWSリージョンの確認
@@ -1148,10 +1154,14 @@ if [ "$GITHUB_CLI_AVAILABLE" = true ]; then
11481154

11491155
# 環境別AWS_ROLE_ARNの登録
11501156
AWS_ROLE_ARN="arn:aws:iam::$AWS_ACCOUNT_ID:role/$ROLE_NAME"
1157+
print_info "登録するARN: $AWS_ROLE_ARN"
11511158
if gh secret set "$SECRET_NAME" --body "$AWS_ROLE_ARN" &> /dev/null; then
11521159
print_success "$SECRET_NAMEがRepository Secretsに登録されました"
11531160
else
11541161
print_warning "$SECRET_NAMEの登録に失敗しました"
1162+
print_info "手動でGitHub Secretsに設定してください:"
1163+
print_info "Name: $SECRET_NAME"
1164+
print_info "Value: $AWS_ROLE_ARN"
11551165
fi
11561166

11571167
# S3_BUCKETの登録

0 commit comments

Comments
 (0)