I am running a SAM template through AWS CodeBuild using a buildspec.yml
file
I believe that this issue is caused by pip installing a default python 2.7 version of the aws-sam-cli
package. I'm not that familiar with how to pip install
the python3
version of a package. Here is a snippet of my buildspec.yml
:
phases:
pre_build:
commands:
- echo "Pre-Build Phase started - SAM Deployment"
- alias python=python3
- pip install --upgrade pip
- pip install aws-sam-cli # install the sam cli
- USER_BASE_PATH=$(python -m site --user-base) # save the path to the user's local packages folder to a variable (as opposed to the global packages folder)
- export PATH=$PATH:$USER_BASE_PATH/bin # add the user's local packages folder to PATH
- sam --version # verify "sam" can now be called
build:
commands:
- sam package --runtime python3 --template-file ${INPUT_FILE} --output-template-file ${OUTPUT_FILE} --s3-bucket ${S3_BUCKET} # package the template to an S3 bucket
...
Has anyone ever run into this issue?