I want to build a codepipeline that will get the code(java) from github build a jar file and deploy it to aws lamda(or store the jar in a specific S3 bucket). I only want to use tools provided by AWS platform only.
If I am using only Codebuild I am able to build jar from the github code and store it to S3(https://docs.aws.amazon.com/codebuild/latest/userguide/getting-started.html) and I am using a deployer lamda function to deploy the code to my service lamda. Whenever there is any change in the S3 bucket deployer lamda gets triggred.
DrawBack: Problem with this is I have to run codebuild manually everytime after commiting changes to github. I want this codebuild to detect changes automatically from github.
To solve the above issue I have made a code pipeline which detect code changes using github webhooks but here it is creating zip file instead of jar
So what I am actually trying is:
GitHub(changes)--->codebuild-->store jar file to specific S3 bucket with specific name or deploy to lambda
buildspec.yml
version: 0.2
phases:
build:
commands:
- echo Build started on `date`
- mvn test
post_build:
commands:
- echo Build completed on `date`
- mvn package
artifacts:
files:
- target/testfunction-1.0.0-jar-with-dependencies.jar
CodePipeline artifact locations are different for each pipeline execution so they're isolated.
I think what you'll want to do is produce a JAR file in CodeBuild, which will end up in a CodePipeline artifact with a ZIP format. You can add a second CodeBuild action that accepts the output of the first CodeBuild action (the CodeBuild action will unzip the input artifact for you) and deploys to S3 (this is pretty trivial to script with the the AWS CLI).
It's entirely possible to combine both CodeBuild actions, but I like to keep the "build" and "deploy" steps separate.