I have a repository in bitbucket. now I want to deploy it to my aws EC2 instance using amazon code-deploy.how can I do that? what steps should I follow?
Use AWS code-pipeline to take source code from the bitbucket and If you want build it, you can build using the code-build and then deploy it using the code-deploy.
Follow this link for more details:
https://docs.aws.amazon.com/codepipeline/latest/userguide/tutorials-simple-codecommit.html
Related
I have my source code in code commit and my new client is with GCP. They wanted to connect code-commit from google cloud-build, is there any option for that ?
Given the fact that GCP and AWS are competitor cloud providers I would say that you will not find a way to trigger Google Cloud Build from AWS CodeCommit, which is what I believe you mean with "integrate" both products.
What I would do in your scenario is replicate you CodeCommit repository in it's equivalent in GCP, which is Google Cloud Source Repositories. You can find a tutorial for how to setup
Build Triggers from Cloud Source Repositories in this documentation. Another option is pushing a container ready to be deployed into Cloud Registry and deploying that instead, you can follow these steps for that.
I am looking to integrate enterprise bitbucket server with aws ci/cd pipeline features.
I have tried creating a project within aws codebuild but do not see any option for bitbucket enterprise .
If this is not possible then what is the long route using api gateway / webhooks etc ?
AWS Codebuild only supports the Bitbucket cloud. To integrate with Bitbucket self hosted solution, you will need to create a API gateway + Lambda. And then add this gateway address as a webhook in the bitbucket repo. The Lambda will then be responsible to process the incoming events from Bitbucket server. There could be 2 routes from here.
One way could be to download the zip for the particular commit and upload it on a S3 bucket. Add S3 as a source trigger for the build project. You lose the ability to run any git specific commands in such a case though as it's just a zip file containing the specific version of files.
Second option could be to pass on the relevant info to codebuild by directly invoking it from Lambda. Passing off details like commit_id, event (pr or push), branch etc as environment variables. Based on this info, run a git clone in codebuild before running other build steps. This way you would have access to git specific commands.
Here is an example workflow from AWS (it is for codepipeline, but you can modify it suitably for codebuild)
With AWS CodeBuild you define GitHub as the source. If your repo is private, you can pass a personal token. I've built a CodeBuild process and confirmed this worked.
What I'd like to do is not use a personal token, instead use a GitHub Deploy Key to authenticate to the private repo. I've setup the Deploy Key in GitHub. How do I configure this either in the AWS CodeBuild Console or in the YAML script?
CodeBuild doesn't natively support deploy keys. It is on our product backlog and is a feature that we will likely support in a future release.
In order to use your existing deploy key in CodeBuild, please follow the instruction that Adrian has highlighted in https://adrianhesketh.com/2018/05/02/go-private-repositories-and-aws-codebuild/. You will need to setup the key in parameter-store and use that in your buildspec.
You can use the source type as "no_source", since you would be doing the source cloning with the deploy key in this case.
For those struggling using your SSH Keys in CodeBuild, you can use AWS' System Manager Service.
Simply put, can store your key in the Parameter Store and use that in your buildspec.yml
You can refer to this tutorial for a detailed implementation: https://medium.com/#cristiano.ventura/working-with-git-submodules-in-codepipeline-83e843e5d0a
It works for my case. Bitbucket webhook integration with private repo deps in the package.json
Best of luck y'all!
How can I setup aws codepipeline with aws code commit + aws code build + elastic beanstalk without using jenkins, teamcity or any other 3rd party tool?
If you take parts of two solutions I put together, you should be able to come up with a comprehensive solution for Elastic Beanstalk, CodePipeline, CodeCommit, and CodeBuild.
I wrote a post on using CodeCommit and CodePipeline with Elastic Beanstalk here: Create a Pipeline for Elastic Beanstalk in CodePipeline using CloudFormation and CodeCommit. In it, I'm using the example Node.js app from AWS. The associated launch stack and code is here.
I wrote about CodeBuild, CodePipeline, CodeCommit, and CodeDeploy integration at Deploy to Production using AWS CodeBuild and the AWS Developer Tools Suite. The code for the post is described at CodeBuild and AWS Developer Tools Suite Lab.
Depending on which programming language you're using to configure and deploy your application, you'll use a different CodeBuild curated environment. To see a list of CodeBuild examples, go to CodeBuild samples. There's a specific one for Elastic Beanstalk for Java here.
Ultimately, you'll need to use CodeBuild to generate the ZIP file that Elastic Beanstalk uses. You orchestrate this CodeBuild action in CodePipeline and use the OutputArtifacts generated in your CodeBuild stage/action as an InputArtifacts to your ElasticBeastalk deploy action. As you see from the examples, everything can be defined in AWS CloudFormation. Hope this helps.
I am novice at Jenkins. My demo project built in github and with AWS codedeploy I can run my project succesfully. If I use AWS codepipeline without Jenkins, whatever changed in github its automatically integrated and run the project. So I want to use Jenkins, if codes have successfully built then it should run. So when I add jenkins in AWS codepipeline and integrated with my jenkins server this process has not run and it just processing in build section. What is the error or it's not integrated with jenkins? So what should I do? Kindly help me.
If your project is simple single html page then no need of using build provider.
If your project is based on maven or gradle then Jenkins will build the job and generate the output artifact file as zip and stored in jenkins workplace. Then these output artifact file is taken as input artifact file for next stage mostly for deployment purpose.
For using jenkins as Build Provider in AWS CodePipeline you should use IAM role for accessing between Jenkins server and AWS CodePipeline.
Purpose of IAM role:
Jenkins server will get input artifact files from the source provider such as AWS S3 bucket, GitHub.
Jenkins server will poll SCM based on Build trigger in your job.
After build successful, Jenkins server will store the output artifact file as zip in jenkins workplace as I mentioned earlier.
These output artifact file is taken as input for next stage. For example, Artefact file should be deployed on AWS CodeDeploy.
Thanks