1

I'm trying to deploy Amazon EC2 instance through CloudFormation and I'm trying to clone a repository with a bash script with cfn-init.

"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
                "#! /bin/bash -xe\n",
                "yum install -y aws-cfn-bootstrap\n",
                "/opt/aws/bin/cfn-init -v ",
                "       --stack ", { "Ref" : "AWS::StackName" },
                "       --resource DocumentationInstance ",
                "       --configsets Install ",
                "       --region ", { "Ref" : "AWS::Region" }, "\n",
                "git clone https://", { "Ref": "GitLabUsn" },"@gitlab.com/user/repository.git \n", { "Ref": "GitLabPwd" }  
                ]]}}
        }

However, when I deploy the EC2 instance, I can see from cloud-init-output.log that the git clone fails, and this is the error:

fatal: could not read Password for 'https://[email protected]': No such device or address

How can I input the password with the bash script correctly? I've tried the yes found here

1 Answer 1

1

ADD the password like this(your can also set it as parameter) git clone https://user:[email protected]/....git

In your case, it will be :

"git clone https://", { "Ref": "GitLabUsn" },":", { "Ref": "GitLabPwd" },"@gitlab.com/user/repository.git \n"
Sign up to request clarification or add additional context in comments.

1 Comment

Hi, thanks for your comment! I've tried as well, but I get this error when trying this out. fatal: unable to access https:// username:[email protected]/user/repo.git : Illegal port number

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.