Created
April 30, 2020 20:52
-
-
Save shane-js/6754cf95f9be1d5cc02aca4c573ab4c8 to your computer and use it in GitHub Desktop.
Main Build's buildspec.yml File - Re: Medium Story - Automated Deployment of AWS S3 Static Web App using CloudFormation / SAM and CodePipeline
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: 0.2 | |
phases: | |
install: | |
runtime-versions: | |
python: 3.8 | |
build: | |
commands: | |
- pip install pipenv --user | |
- pipenv run python -m pip install pip==19.2.3 # helped resolve a bug I encountered in deploying by downgrading - can try leaving to most up to date again in the future | |
- pipenv install awscli aws-sam-cli | |
- pipenv run sam build | |
- pipenv run sam package --template-file template.yaml --region YOUR_REGION_NAME --s3-bucket YOUR_S3_STATIC_APPS_BUCKET_NAME --force-upload --output-template-file packaged-template.yaml | |
- pipenv run npm install # start building static React app files needed for BA_staticWebAppBuildDir build artifact | |
- pipenv run npm run build | |
- rm -rf build/precache-manifest* # delete any precache-manifest files from build folder as they are not necessary and will continuously build up in S3 if we don't | |
artifacts: | |
secondary-artifacts: # we are going to have two build artifacts come out of the main build | |
BA_packagedTemplateYaml: # this first one is what we need to deploy CloudFormation / SAM resources (created above in build commands) | |
files: | |
- packaged-template.yaml | |
BA_staticWebAppBuildDir: # this second one is going grab the React app's build directory and save it in the CodePipeline's S3 Artifact bucket which we are going to reference later | |
files: | |
- "**/*" | |
base-directory: build |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment