awslabs / awslabs/amazon-app-runner-deploy

ERROR: Failed to build your application source code. Reason: Failed to execute 'pre_build' command.

Open
#57 3 comments 4 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
60
Forks
34
PR merge metrics
No merged PRs in 30d

Description

Hi everyone. I created a service in AWS apprunner and I am trying to deploy a python application using the python311 runtime. Whenever I tried to deploy using the code-based approach I got the error `Failed to build your application source code. Reason: Failed to execute 'pre_build' command.`
When I build as a docker image pulling from ECR the deployment is successful.

This is my GitHub actions pipeline:

```
name: Deploy to App Runner

on:
push:
branches: [ccl-develop] # Trigger workflow on git push to ccl-develop branch
workflow_dispatch: # Allow manual invocation of the workflow

jobs:
deploy:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read

steps:
# OIDC Assume Role
- name: Configure AWS Credentials
id: configure-aws-credentials
uses: aws-actions/configure-aws-credentials@v3
with:
role-to-assume: ${{ vars.OIDC_ROLE }}
aws-region: us-east-1

# Deploy to App Runner
- name: Deploy to App Runner
id: deploy-apprunner
uses: awslabs/amazon-app-runner-deploy@main
with:
service: ${{ vars.SERVICE_NAME }}
source-connection-arn: ${{ vars.SOURCE_CONNECTION_ARN }}
repo: https://github.com/${{ github.repository }}
branch: ${{ github.ref }}
runtime: PYTHON_311
build-command: "yum --version || echo 'yum not found' && yum search gdal || echo 'gdal not found'"
start-command: uvicorn app.main:app --host 0.0.0.0 --port 8000
port: 8000
region: us-east-1
cpu: 1
memory: 2
wait-for-service-stability-seconds: 600
copy-env-vars: |
SERVER_PORT
CITIES_API_AIRTABLE_KEY
AIRTABLE_BASE_ID
copy-secret-env-vars: |
SECRET_ENV
instance-role-arn: ${{ vars.INSTANCE_ROLE_ARN }}
tags: |
{ "env": "test" }
env:
SERVER_PORT: 8000
SECRET_ENV: secret_env
CITIES_API_AIRTABLE_KEY: ${{ secrets.CITIES_API_AIRTABLE_KEY }}
AIRTABLE_BASE_ID: ${{ vars.AIRTABLE_BASE_ID }}

# Log App Runner URL
- name: Log App Runner URL
run: |
echo "App Runner URL: ${{ steps.deploy-apprunner.outputs.service-url }}"
```
This is the apprunner log after its execution:

```
01-08-2025 11:00:29 AM [AppRunner] Deployment with ID : a49e3b46e6a44382959bb20d0cbb15d1 started. Triggering event : SERVICE_CREATE
01-08-2025 11:00:29 AM [AppRunner] Deployment Artifact: [Repo Type: Source], [Repository: MASKED], [Branch: ccl-develop], [SourceDirectory: /]
01-08-2025 11:01:20 AM [AppRunner] Creating pipeline for automatic deployments.
01-08-2025 11:01:20 AM [AppRunner] Successfully created pipeline for automatic deployments.
01-08-2025 11:01:21 AM [AppRunner] Pulling source code from GITHUB Repository ( MASKED).
01-08-2025 11:01:23 AM [AppRunner] Successfully pulled your application source code.
01-08-2025 11:01:24 AM [AppRunner] Successfully validate configuration file.
01-08-2025 11:01:25 AM [AppRunner] Starting source code build.
01-08-2025 11:02:09 AM [AppRunner] Failed to build your application source code. Reason: Failed to execute 'pre_build' command.
01-08-2025 11:02:13 AM [AppRunner] Deployment with ID : a49e3b46e6a44382959bb20d0cbb15d1 failed.
```
Does anyone know what might be the issue?

Contributor guide

Open the contributing guide

Research direction

Start with the GitHub Actions workflow and the App Runner deployment log in the issue, focusing on the PYTHON_311 runtime, the build-command, and the pre_build failure. Compare the code-based deployment configuration with the successful ECR image deployment and reproduce the failure. Done means the cause is explained and a verified configuration or documentation change is identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, github-actions, python
Domain
ci-cd, cloud, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.