Skip to content

Commit 07eda8c

Browse files
fix: Resolve AWS Region error in GitHub Actions
- Move sam validate after AWS credentials configuration - Add explicit AWS_REGION environment variable to SAM steps - Add AWS identity verification for debugging - Fix 'AWS Region was not found' error in SAM execution - Ensure proper execution order: credentials → validate → deploy
1 parent 17ed06d commit 07eda8c

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,21 @@ jobs:
3232
python -m pip install --upgrade pip
3333
pip install -r requirements.txt
3434
35-
- name: Validate SAM template
36-
run: |
37-
sam validate
38-
3935
- name: Configure AWS credentials
4036
uses: aws-actions/configure-aws-credentials@v4
4137
with:
4238
role-to-assume: ${{ github.ref == 'refs/heads/main' && secrets.AWS_ROLE_ARN_PROD || secrets.AWS_ROLE_ARN_DEV }}
4339
aws-region: ${{ env.AWS_REGION }}
4440

41+
- name: Validate SAM template
42+
run: |
43+
# AWS認証情報の確認
44+
aws sts get-caller-identity
45+
echo "AWS Region: $AWS_REGION"
46+
sam validate
47+
env:
48+
AWS_REGION: ${{ env.AWS_REGION }}
49+
4550
- name: Deploy with SAM
4651
run: |
4752
# ブランチに基づいて環境設定を決定
@@ -55,13 +60,15 @@ jobs:
5560
5661
echo "Deploying to environment: $ENVIRONMENT"
5762
echo "Stack name: $STACK_NAME"
63+
echo "AWS Region: $AWS_REGION"
5864
5965
sam build
6066
sam deploy --no-confirm-changeset --no-fail-on-empty-changeset \
6167
--stack-name $STACK_NAME \
6268
--s3-bucket cn-seba-aws-sam-cli-managed-default-samclisourcebucket \
6369
--parameter-overrides ProjectName=${{ env.PROJECT_NAME }} Environment=$ENVIRONMENT
6470
env:
71+
AWS_REGION: ${{ env.AWS_REGION }}
6572
SAM_CLI_TELEMETRY: 0
6673

6774
- name: Deploy status

0 commit comments

Comments
 (0)