Is there a way to force delete branch from aws codecommit - amazon-web-services

When you first create repository on aws codecommit through their API, that repository does not have any branches. Later when you create branch (e.g. master) it is the default one now and there is no way to delete it.
Does anyone know if there is some king of a workaround that will allow deleting of default branch on codecommit through API?

CodeCommit supports updating default branch: https://docs.aws.amazon.com/codecommit/latest/APIReference/API_UpdateDefaultBranch.html, deleting non -default branch: https://docs.aws.amazon.com/codecommit/latest/APIReference/API_DeleteBranch.html. Can you clarify the use case a little bit so that we can understand why you need to delete the default branch directly?

Related

Rename branch in AWS CodeCommit

I remember there was an option in gitlab to rename branch but I don't see such option in AWS CodeCommit.
I also tried to find such command in aws command line itility ('aws codecommit help') but there was no any as well.
The only solution I could find:
Let's say we need to rename A -> B. We create branch B from A and then remove A.
Found on some old gitlab forums, probably gitlab did not had 'rename' feature long time ago.
EDIT: If you want to rename a default branch then default branch must be changed before removal (you may switch it to the newly created branch). Default branch configuration is under the Settings repository menu, which is on the same level as Code, Pull requests, Commits and so on.

An AWS CI/CD Pipeline that allows manual deploy by commit

Background
I want to create the following CI/CD flow in AWS and Github, for a react app using Amplify:
A single main branch, with short-lived feature branches and PRs into main.
Each PR triggers its own test environment in Amplify, with its own temporary subdomain, which gets torn down when the PR is merged, as described here.
Merging into main does not automatically trigger a deploy to production.
Instead, there is a separate mechanism (a web page, or amplify command, or even triggers based on git tags) for manually selecting a commit from main to deploy to production.
Questions
It's not clear to me if...
Support for this flow is already built into Amplify (based on the docs I've read, I think the answer is "no", but I'm not sure).
Support for this flow is already built into AWS CodePipeline, or if it can be configured there.
There is another AWS tool that solves this.
I'm looking for answers to those questions, or specific references in the docs which address them.
The answers for Amplify are Yes, Yes, Yes, Partially.
(1) A single main branch, with short-lived feature branches and PRs into main.
Yes. Feature branch deploys. Can define which branch patterns, such as feature*/, you wish to auto-deploy.
(2) Each PR triggers its own test environment in Amplify, with its own temporary subdomain,
Yes. Web Previews for PRs. "A web preview deploys every pull request made to your GitHub repository to a unique preview URL which is completely different from the URL your main site uses."
(3) Merging into main does not automatically trigger a deploy to production.
Yes. Disable automatic builds on main.
(4) Instead, there is a separate mechanism ... for manually selecting a commit from main to deploy to production.
Partially (HEAD only?). Call the StartJob API to manually trigger a build from, say, Lambda. The job type RELEASE starts a new job with the latest change from the specified branch. I am not sure if jobType: MANUAL with a commitId starts a job from an arbitrary commit hash.
Another workaround for 3+4 is to skip the build for an arbitrary commit. Amplify will skip building if [skip-cd] appears at the end of a commit message.
In my experience, I don't think there is any easy way to meet your requirement.
If you are using Gitlab, you can try Gitlab Review Apps to achieve that (I tried before with some scripts)
Support for this flow is already built into Amplify (based on the docs I've read, I think the answer is "no", but I'm not sure).
Check below links, if this help:
https://www.youtube.com/watch?v=QV2WS535nyI
https://dev.to/rajandmr/deploying-react-app-using-aws-amplify-with-ci-cd-pipeline-setup-3lid
Support for this flow is already built into AWS CodePipeline, or if it can be configured there.
For this, you need to create a full your own pipeline. Yes, you can configure your pipeline.
There is another AWS tool that solves this.
If you are okay with Jenkins, then Jenkins will help you to achieve this.
You can deploy Jenkins docker in AWS EC2 and create your pipeline. You can also use the parameterised option for selecting your environment and git branch.

I am trying to sync two branches in two different repositories in AWS Codecommit. Is there any way to do the sync in an automated way?

Using Codecommit to store the repositories. I have one branches in RepoA and one branch in RepoB. I am trying to sync the changes made in RepoA's branch into RepoB's branch but in an automated way. Is there any way I can use Lambda or codebuild containers to do so?
I don't think so there is any out-of-the-box solution from CodeCommit for this. I also don't think having 2 different repos, one for developer and one for deployment is a good design.
Coming back to answer your question, you can sync the branches in 2 different repos through a script, and call the same from Lambda. However, what you have to take care over here is, are all the parameters to execute this script are well within Lambda's limits?
Assuming the sequence of operation is something like :
Clone repo A.
Checkout branch A.
Add new remote "origin2" as repo B to repo A cloned copy.
Pull from origin2 branch A.
Push to origin2 branch A.
I would say, better to trigger a Container with required script and details/parameters to execute the script.
If you already have any CI setup such as Jenkins/Bamboo, it will be a lot easier.

How to create Auto Pull request trigger in AWS CodeCommit?

I am new to Code Commit and know a little about git.
I have root access to the repo
Basically, I want to maintain code Commit branch (master).
I want to implement trigger, (if possible) such as:
All developers need to create their own branch from "master" and when they want to push to "master" branch, a new Pull request gets created.
Not sure if possible (create gating),
when I approve the pull request, it goes to master branch.
I hope I am clear
A Million thanks
There’s no way to add IAM permissions on branches. It’s one of the BIG pains of CodeCommit that makes it hard to implement - it drastically reduce security compared to all the other solutions on the marker
Edit:
CodeCommit now supports branch level permissions. You can read more about it here
https://aws.amazon.com/about-aws/whats-new/2018/05/aws-codecommit-supports-branch-level-permissions/
or here
https://aws.amazon.com/blogs/devops/refining-access-to-branches-in-aws-codecommit/
There is currently no branch level permissions on a repository that would prevent someone from pushing specifically to master, or any other branch.
A number of customers are interested in this feature, your request will help us prioritize our work.

Can't figure out WSO2-ESB Deployment Synchronizer

I can't figure out idea about svn DepSync: we have default repository inside <PRODUCT_HOME>/repository/deployment/server. Ok. If I want to use this default repo, then I shouldn`t make my own svn repo? So In this case I leave
<DeploymentSynchronizer><Enabled>false</Enabled>
inside carbon.xml? Or I should set up <Enabled>true</Enabled> and also set <SvnUrl> to <SvnUrl><PRODUCT_HOME>/repository/deployment/server</SvnUrl>?
In other case, If I want to set up my own repository, I should disable default repo <PRODUCT_HOME>/repository/deployment/server? So, in this case I should change parameter <RepositoryLocation>${carbon.home}/repository/deployment/server/</RepositoryLocation> to something <RepositoryLocation>url_of_my_own_repo/</RepositoryLocation> inside carbon.xml? Am I right?
Deployment synchronization is used to synchronize artifacts deployed across nodes in a product cluster. When you enable depsync and provide a svn repository location, the artifacts gets committed to that location. The other nodes should be configured to the same svn repository for depsync. This way the they will sync with the first nodes' artifacts and maintain consistency.
In a non-cluster environment, depsync is not needed.