+++ title = "Deploying from AWS Code Commit" chapter = false weight = 4 +++ :imagesdir: /images Applications can be deployed from a variety fo locations. Developer commonly storing application code and configurations within a source code repository such as GIT. With customers adopting more and more AWS native services it is not unusual to see code being stored in AWS code commit. In this module we will explore creating an AWS code commit repo, interacting with it using GIT tools as well as deploying workloads from it to OpenShift Step 1:: Deploy a code commit repo We are going to infrastructure as code to create the code commit repo. The template can be found within the resources folder of the workshop you cloned in the getting started step. We will deploy this CloudFormation stack using the AWS CLI. Please update the --stack-name with your Student or attendee number for the workshop. ---- cd ~/environment/openshift-on-aws/resources/ aws cloudformation create-stack --stack-name studentcodecommit --template-body file://CodeCommitCFN.yaml --capabilities CAPABILITY_NAMED_IAM --parameters ParameterKey=RepositoryName,ParameterValue=studentrepo until [[ `aws cloudformation describe-stacks --stack-name "studentcodecommit" --query "Stacks[0].[StackStatus]" --output text` == "CREATE_COMPLETE" ]]; do echo "The stack is NOT in a state of CREATE_COMPLETE at `date`"; sleep 30; done && echo "The Stack is built at `date` - Please proceed" ---- Step 2:: Get the code repo clone URL We will query the above CloudFormation stack to get the outputs which contain the HTTP and SSH clone URLs which will be used later. ---- aws cloudformation describe-stacks --stack-name studentcodecommit ---- image::codecommitcfnlaunch.gif[project] Step 3:: Clone the repo Use the CloneUrlHttp in the above output to clone your repo. ---- cd ~/environment/ git clone https://git-codecommit.us-west-2.amazonaws.com/v1/repos/student0jun11 ---- The first time you connect, you will be prompted for the username and password for the repository. Enter the username and password generated for git credentials in IAM image::codecommitclone.gif[project] Step 4:: Clone an application to use ---- cd ~/environment/ git clone https://github.com/RedHatGov/openshift-workshops.git ---- Step 5:: copy the code to your local code commit repo ---- cd openshift-workshops mv *.* ../ cd ../. git add . git commit -m "added app" git push origin ---- Step 7:: Log into the OpenShift web console ---- This is the same process covered in the getting started module: ---- Step 8:: Create a project ---- Under the *developer* context expland advanced on the left expand projects click on create project create a project called *myproject* ---- Step 9:: Deploy application from AWS Code commit We are going to deploy an application from GIT and add the details for the AWS code commit repo ---- click on '+Add' in the left menu. Select from GIT Add the CloneUrlHttps address you collected in Step 2 Under **GIT TYPE** select **other** Select Show advanced and enter the subdirectory in the Context dir for your source code to build and deploy Select Create new Secret from the Source Secret drop-down. Enter a name for Secret Name and choose Basic Authentication for Authentication Type from the drop-down. Enter AWS CodeCommit Git credential username and password in the respective fields, choose Create. OCPWORKSHOPCODECOMMITUSER-at-755152575036 wJT4uKR06mzLnrpFJpv/Jyk5W5QBzZDhAwUtosAcq8E= THIS CREDENCIAL MAY NOT BE THE ACTUAL ONE BEING USED PLEASE CONFIRM WITH THE PRESENTER. ---- The following docs dicsuss how to provide HTTP git credentials for IAM users, Should the credentail in Step 9 not exist you can go to the IAM console and create them. https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-gc.html ---- Select node js from the builder options ---- image::addrepo.gif[project] Step 10:: View application deployment ---- Under Resources, select DeploymentConfig, and select Create. This will automatically start building the application. After a successful build, the S2I tool will automatically deploy the container application into the project you selected. Select the application that was just deployed and click on the application to open the details page as shown below. ----