# Do not change version. This is the version of aws buildspec, not the version of your buldspec file. version: 0.2 phases: install: runtime-versions: nodejs: 8 commands: - echo pre Installing ... pre_build: commands: - echo Installing source NPM dependencies... - npm install build: commands: - echo Build started on `date` - echo Compiling the Node.js code - sls invoke test - sls invoke test --reporter mocha-simple-html-reporter --reporter-options output=report.html - aws s3 cp report.html s3://techsummit2019/review/report.html - mkdir build # - zip -r ./build/lambda.zip ./ - CurrentVersion=$(echo $(aws lambda get-alias --function-name cicd-tdd-dev-cicd1 --name live --region us-west-2 | grep FunctionVersion | tail -1 |tr -cd "[0-9]")) post_build: commands: - serverless deploy - TargetVersion=$(echo $(aws lambda list-versions-by-function --function-name cicd-tdd-dev-cicd1 --region us-west-2 | grep Version | tail -1 | tr -cd "[0-9]")) - echo $CurrentVersion - echo $TargetVersion - sed -e 's/{{CurrentVersion}}/'$CurrentVersion'/g' -e 's/{{TargetVersion}}/'$TargetVersion'/g' appspec.template.yaml > appspec.yaml - aws s3 cp appspec.yaml s3://techsummit2019/codedeploy/appspec.yaml - wget -O foo.html https://xzqxf0jy5f.execute-api.us-west-2.amazonaws.com/dev/ping - aws s3 cp foo.html s3://techsummit2019/review/apigateway.html artifacts: type: yaml files: - appspec.yaml cache: paths: - node_modules/*