Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example for buildspec file for Amazon CodeBuild and Amazon CodePipeline to achieve Continuous Integration and Continuous Delivery for a ServerLess project
version: 0.1
phases:
install:
commands:
- printenv
- npm install
build:
commands:
- npm run build
post_build:
commands:
- mkdir -p build
- tar jcf build/myApp-$(date +%Y%m%d%H%m%S).tar.bz2 .eslintrc.js .gitignore README.md buildspec.yml package.json serverless.yml src test
- npm install -g serverless
- serverless -v -s $(echo ${CODEBUILD_INITIATOR} | cut -d'/' -f2 | cut -d'_' -f3) deploy
artifacts:
files:
- build*/**
discard-paths: yes
@martinmicunda

This comment has been minimized.

Copy link

martinmicunda commented Jun 5, 2017

Hi.

Do you deploy to different AWS accounts? I am looking for an examples how to deploy to different AWS accounts through codebuild.

Thanks

@katp4

This comment has been minimized.

Copy link

katp4 commented Jul 4, 2017

@martinmicunda My team had a look into it recently, I don't believe that's currently possible.

@jamesrenaud

This comment has been minimized.

Copy link

jamesrenaud commented Jul 19, 2017

@martinmicunda you can use Lambda to do cross account deployments via assume role. The IAM role you're running codebuild has to have permissions to assume role, and then the role on the other account must have appropriate permissions for the resources you're trying to access

@donaldev

This comment has been minimized.

Copy link

donaldev commented Jul 2, 2018

I am using similar post-build commands however when using it with CodePipeline it fails on deployment as it cannot find the appspec.yml file. I understand that this is because it is in compressed format - how do I unzip a file inside an EC2 instance - should it be done in the buildspec.yml file?

@Amanfavas

This comment has been minimized.

Copy link

Amanfavas commented May 24, 2019

Hi,
I have five lambda,In the five lambda function inside , I need to install node-modules, With the help of codebuild, buildspec file.
How to do that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.