Manoj Dhake
Manoj Dhake

Reputation: 297

How to copy github code to s3 bucket using only aws codebuild service?

I want to copy a latest code of gitHub into amazon s3 bucket with the help of only code build service.

I know it's pretty much straight forward to do using codepipeline and codedeploy service. But I am more interested to see how its doable only with the codebuild service.

At the moment, I do not have any kind of java/scala/node js code in githib repository and also do not want to execute compile,run or test the code. I just simply looking to copy files from github to s3 bucket when there is PUSH event occured.

Please guide me ,how to configure codebuild service for this use case.

Please share your thoughts and links with respect to this problem.

Thanks in advance.

Upvotes: 3

Views: 5423

Answers (2)

Manoj Dhake
Manoj Dhake

Reputation: 297

I have followed below links to achieve this task.

https://docs.aws.amazon.com/codebuild/latest/userguide/getting-started-create-build-project-console.html

I managed to copy the github latest code to s3 bucket by specifying below command to the buildspec file.

Note: Initially, I was under impression that I will need to configure aws cli but that's not the case here. It's already been configured within codebuild environment.

buildpsec file enter image description here

Note: Make sure you have added enough permission(i.e. s3 read and write) to the codebuild default service role as below. enter image description here

Upvotes: 5

Saggi Bashari
Saggi Bashari

Reputation: 436

Please take a look on this docs:

CodeBuild - GitHub webhooks

CodeBuild Artifacts

The main idea:

You can create webhook from GitHub to CodeBuild. Every PUSH in GitHub it will start a CodeBuild container. This container get the artifacts (repository).

In the CodeBuild itself you already have access to the artifacts so for example you can use boto3 (Python)/aws-cli to interact with s3 bucket and upload the artifacts.

Upvotes: 3

Related Questions