How can i clone aws codecommit repo with chef recipe?
I tried installing AWS CLI and added credentials with codecommit access, then use chef’s git resource to clone the repo. but it fails with could not read Username for ‘https://git-codecommit.us-east-1.amazonaws.com’ .
git "/home/ubuntu/lead_intake" do
repository node[:app_name][:git_repository]
action :sync
end
When tried to clone from the command line it works.
helps would be appreciated
First, make sure you have correct Access key ID and Secret access key in IAM -> users -> Security Credentials.
Second, put [credential] helper = !aws codecommit credential-helper $# UseHttpPath = true into .gitconfig file.
Third, Both .gitconfig file and .aws directory should in the /root/ . Maybe this is the problem that you have. You put the .gitconfig in the /root/.aws/, which will make credential helper useless. Thus it is asking your Username/Password.
If you have done all the things above, it also fails, I suggest you to use ssh to clone the repository. Follow this documentation http://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-ssh-unixes.html
Related
I am following https://aws.amazon.com/getting-started/hands-on/build-serverless-web-app-lambda-apigateway-s3-dynamodb-cognito/module-1/
and facing an issue when trying to clone the repo "wildrydes-site" I just created in CodeCommit.
git clone https://git-codecommit.us-east-1.amazonaws.com/v1/repos/wildrydes-site
Cloning into 'wildrydes-site_new'...
fatal: unable to access 'https://git-codecommit.us-east-1.amazonaws.com/v1/repos/wildrydes-site/': The requested URL returned error: 403"
Make sure your IAM user or role being used has codecommit:GitPull permissions or you can attach the managed policy AWSCodeCommitPowerUser to provide more wider codecommit access.
Approach 1 for IAM Users using Git Credentials
You need to setup IAM credentials like they mentioned in point 'e'. Follow the instructions here to generate codecommit credentials for your IAM User.
The generated credentials will have a username and password with the username in the format <your-iam-username>-at-<account id>. Make sure to copy the password or download the credentials file. Use these username and password values when you run git clone command.
Approach 2 for IAM roles or users.
You need to configure your IAM user aws credentials locally using aws configure or If you are using roles, you need to run aws sts assume-role --role-arn <role-arn> to assume the role after aws configure and generate the temporary credentials which you can export to your environment.
Once the aws credentials configuration is done, you can run below commands to use AWS CLI as your credential helper.
git config --global credential.helper '!aws codecommit credential-helper $#'
git config --global credential.UseHttpPath true
Run your git clone after running above commands. That should fix your issue too.
I have the following repo structure in AWS code commit.
I have MainRepo folder and inside it has 2 sub-folder inside which respective solution and buildspec.yml file present.
I am trying to build proj1.sln using aws codebuild service.
In Source section of aws codebuild, it allows to select MainRepo only.
How can i select sub-folder Repo1 in aws codebuild?
You should create a new CodeCommit Repository first and create the CodeBuild Project from there.
You can follow the steps as below :
Create a new CodeCommit Repository and copy the repository URL from the CodeCommit console.
Clone the CodeCommit Repository from inside your <MainRepo> directory in the local computer (here I am guessing you have the MainRepo directory in your local machine, if not then you can clone it to your local machine)
You will have a new repo directory (eg. <Repo3>) on your local system inside <MainRepo> directory.
Copy the .git folder from <Repo3\.git> to <Repo1\.git> and you can git push your files from <Repo1> to the CodeCommit Repository.
Then you can build your Artifacts/CodeBuild Projects from the newly created CodeCommit Repository.
Can we upload a folder containing various code files from our local system to AWS CodeCommit.? If yes, then what are the steps to follow.?
I don't think it is possible to upload an entire folder through the UI. I think this the easiest way with an existing git repository, is as follows:
SCHEME="codecommit::${REGION}"
aws sts get-caller-identity # requires AWS credentials, with authorization
pip install git-remote-codecommit # using HTTPS GRC
git push -u ${SCHEME}://${TARGET_REPO} HEAD:refs/heads/master
I have EC2 instance, up and running good. Now I want a copy of the source code to be moved to AWS Code commit for further development and deployment.
Basically souce code should be moved from AWS EC2 to AWS Codecommit.
You need to either SSH (if Linux), or RDP (if windows), into the machine. Turn your source directories into a git repository, and then git push it to your remote (code commit) repository.
You basically do it the exact same way you would do it from any other machine - the fact that it is an EC2 instance really doesn't matter in this case.
First of all you have to create a git credential from AWS IAM. You need these credential whenever you pushed your code into codecommit. Alternatively, you can also upload your SSH public key into fAWS codecommit so that you don't need to enter your credentials every time whenever you push your code.
then follow the steps mentioned bellow:
Type git init while you are on your project folder in EC2
Then git add .
Then type git commit -m 'your custom commit message here'
Create a repo in CodeCommit from AWS Management Console.
Add then from your project folder, type remote origin by typing git remote add origin https://git-codecommit.us-east-1.amazonaws.com/v1/repos/testrepo (if you using HTTPS protocol) or git remote add origin ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/testrepo (if you are using SSH protocol)
Then push your code by typing git push origin master. in this stage, you have to enter your credentials such as AWS username and password or don't need them if you already uploaded your SSH public key into AWS code commit.
I am new to Amazon Web Services world, and I am implementing Continuous Delivery to the company I work for.
I followed AWS's [instructions to configure CodeCommit Service] (http://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-https-windows.html#setting-up-https-windows-account)
Step 1: Initial Configuration for AWS CodeCommit
To create and configure an IAM user for accessing AWS CodeCommit:
I created a new IAM user and gave him AWSCodeCommitFullAccess
To install and configure the AWS CLI :
I installed and configured the credentials doing aws configure.
Setting AWS Access Key ID, AWS Secret Access Key, Default region name to us-east-1 and de
Step 2: Install Git
I installed Git For Windows making sure the Enable Git Credential Manager option was cleared.
Step 3: Set Up the Credential Helper
git config --global credential.helper "!aws codecommit credential-helper $#"
git config --global credential.UseHttpPath true
Executing:
git config --global --edit
My Configuration is:
[http]
sslVerify = false
[credential]<br>
helper = "aws codecommit list-repositories codecommit credential-helper "
UseHttpPath = true
Step 4: Connect to the AWS CodeCommit Console and Clone the Repository
$ git clone https://git-codecommit.us-east-1.amazonaws.com/v1/repos/teste-git-to-s3<br>
Cloning into 'teste-git-to-s3'...<br>
git: 'credential-aws' is not a git command. See 'git --help'.<br>
Username for 'https://git-codecommit.us-east-1.amazonaws.com/v1/repos/teste-git-to-s3': Lucas<br>
fatal: unable to access 'https://git-codecommit.us-east-1.amazonaws.com/v1/repos/teste-git-to-s3/': The requested URL returned error: 403
Looking for AWS troubleshooting, I found: Troubleshooting AWS CodeCommit but I couldn't solve it.
How can this be solved?
I think the issue is in your .gitconfig file. Change it to below and it should work.
[credential]
helper = !aws codecommit credential-helper $#
UseHttpPath = true
By the way, if you are using a Bash emulator instead of the Windows command line, you must use single quotes instead of double quotes.
Let me know if this doesn't work.
If you are using cygwin, after you created the repository, click the connect info button, select linux instead of windows, it works on mine.
I experienced this problem with Python 3.8.x - make sure you are using Python 3.7.x instead, as shown in the docs