Learn and Be Curious

devops lab3

Cloud/AWS2017. 8. 31. 14:09

Myung-ui-MacBook-Air:Downloads Jay$ chmod 400 qwikLABS-L1417-907037.pem 

Myung-ui-MacBook-Air:Downloads Jay$ ssh -i qwikLABS-L1417-907037.pem ec2-user@54.89.184.6

The authenticity of host '54.89.184.6 (54.89.184.6)' can't be established.

RSA key fingerprint is e5:70:6d:17:e1:b0:75:1f:2c:cc:35:85:a5:d6:b7:b8.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '54.89.184.6' (RSA) to the list of known hosts.


       __|  __|_  )

       _|  (     /   Amazon Linux AMI

      ___|\___|___|


https://aws.amazon.com/amazon-linux-ami/2017.03-release-notes/

[ec2-user@ip-10-1-10-250 ~]$ 

[ec2-user@ip-10-1-10-250 ~]$ 

[ec2-user@ip-10-1-10-250 ~]$ 




[ec2-user@ip-10-1-10-250 ~]$ aws codecommit create-repository --repository-name myung --region us-east-1

{

    "repositoryMetadata": {

        "repositoryName": "myung", 

        "cloneUrlSsh": "ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/myung", 

        "lastModifiedDate": 1504152906.66, 

        "repositoryId": "1262ccb8-cf22-4e03-b5fc-a14fd4d65f8e", 

        "cloneUrlHttp": "https://git-codecommit.us-east-1.amazonaws.com/v1/repos/myung", 

        "creationDate": 1504152906.66, 

        "Arn": "arn:aws:codecommit:us-east-1:223206376027:myung", 

        "accountId": "223206376027"

    }

}

[ec2-user@ip-10-1-10-250 ~]$ ll

합계 8

-rwxr-xr-x 1 ec2-user ec2-user 4196  2월 23  2016 setup-codecommit.sh

[ec2-user@ip-10-1-10-250 ~]$ vi setup-codecommit.sh 

[ec2-user@ip-10-1-10-250 ~]$ ./setup-codecommit.sh 


This script will perform the steps necessary to setup AWS CodeCommit;

including provisioning IAM users and uploading SSH keys.











































Lets start with developer1 - creating IAM user and CLI profile...

{

    "User": {

        "UserName": "developer1", 

        "Path": "/", 

        "CreateDate": "2017-08-31T04:17:02.611Z", 

        "UserId": "AIDAJT5XCT4DNVIEEJVTW", 

        "Arn": "arn:aws:iam::223206376027:user/developer1"

    }

}



































developer profile complete.  Time to upload SSH key to IAM and configure local SSH settings.
























































































All finished with developer1.  Lets set up the CI user and EC2 instance now!












































Creating IAM user for the Continuous Integration platform

{

    "User": {

        "UserName": "ci-user", 

        "Path": "/", 

        "CreateDate": "2017-08-31T04:17:22.802Z", 

        "UserId": "AIDAIQYOGRZ53M65UJRHM", 

        "Arn": "arn:aws:iam::223206376027:user/ci-user"

    }

}

Warning: Permanently added '10.1.10.43' (ECDSA) to the list of known hosts.

id_rsa.pub                                                                                             100%  400     0.4KB/s   00:00    

Connecting to 10.1.10.43 to configure the CI Instance with access to AWS CodeCommit
































ci-config                                                                                              100%  137     0.1KB/s   00:00    

Connection to 10.1.10.43 closed.

Connection to 10.1.10.43 closed.










































Configuration for ci-user complete.  The setup script will now exit.












































[ec2-user@ip-10-1-10-250 ~]$ source ~/.bash_profile 

[ec2-user@ip-10-1-10-250 ~]$ cd /opt/git/ci-project/

[ec2-user@ip-10-1-10-250 ci-project]$ ll

합계 8

drwxr-xr-x 2 ec2-user apache 4096  8월 31 02:35 cfn

drwxr-xr-x 2 ec2-user apache 4096  8월 31 02:35 php

[ec2-user@ip-10-1-10-250 ci-project]$ git init

초기화: 빈 깃 저장소, 위치 /opt/git/ci-project/.git/

[ec2-user@ip-10-1-10-250 ci-project]$ wget -O cfn/lab-3-app-test-env.template https://d2lrzjb0vjvpn5.cloudfront.net/devops/v1.5/lab-3-ci/static/lab-3-app-test-env.template

--2017-08-31 04:20:32--  https://d2lrzjb0vjvpn5.cloudfront.net/devops/v1.5/lab-3-ci/static/lab-3-app-test-env.template

Resolving d2lrzjb0vjvpn5.cloudfront.net (d2lrzjb0vjvpn5.cloudfront.net)... 52.84.118.125, 52.84.118.165, 52.84.118.244, ...

Connecting to d2lrzjb0vjvpn5.cloudfront.net (d2lrzjb0vjvpn5.cloudfront.net)|52.84.118.125|:443... connected.

HTTP request sent, awaiting response... 200 OK

Length: 8280 (8.1K) [application/octet-stream]

Saving to: ‘cfn/lab-3-app-test-env.template’


cfn/lab-3-app-test-env.template    100%[=============================================================>]   8.09K  --.-KB/s    in 0s      


2017-08-31 04:20:32 (185 MB/s) - ‘cfn/lab-3-app-test-env.template’ saved [8280/8280]


[ec2-user@ip-10-1-10-250 ci-project]$ ll

합계 8

drwxr-xr-x 2 ec2-user apache 4096  8월 31 04:20 cfn

drwxr-xr-x 2 ec2-user apache 4096  8월 31 02:35 php

[ec2-user@ip-10-1-10-250 ci-project]$ wget -O ~/sample-app.tgz https://d2lrzjb0vjvpn5.cloudfront.net/devops/v1.5/lab-3-ci/static/sample-app.tgz

--2017-08-31 04:20:58--  https://d2lrzjb0vjvpn5.cloudfront.net/devops/v1.5/lab-3-ci/static/sample-app.tgz

Resolving d2lrzjb0vjvpn5.cloudfront.net (d2lrzjb0vjvpn5.cloudfront.net)... 52.84.118.93, 52.84.118.125, 52.84.118.165, ...

Connecting to d2lrzjb0vjvpn5.cloudfront.net (d2lrzjb0vjvpn5.cloudfront.net)|52.84.118.93|:443... connected.

HTTP request sent, awaiting response... 200 OK

Length: 6268 (6.1K) [application/x-tar]

Saving to: ‘/home/ec2-user/sample-app.tgz’


/home/ec2-user/sample-app.tgz      100%[=============================================================>]   6.12K  --.-KB/s    in 0s      


2017-08-31 04:20:58 (1.79 GB/s) - ‘/home/ec2-user/sample-app.tgz’ saved [6268/6268]


[ec2-user@ip-10-1-10-250 ci-project]$ 

[ec2-user@ip-10-1-10-250 ci-project]$ printf "################################\n\nMain branch initialized `date`.\n\n" >> readme.txt

[ec2-user@ip-10-1-10-250 ci-project]$ ll

합계 12

drwxr-xr-x 2 ec2-user apache   4096  8월 31 04:20 cfn

drwxr-xr-x 2 ec2-user apache   4096  8월 31 02:35 php

-rw-rw-r-- 1 ec2-user ec2-user   93  8월 31 04:21 readme.txt

[ec2-user@ip-10-1-10-250 ci-project]$ git add .

[ec2-user@ip-10-1-10-250 ci-project]$ 

[ec2-user@ip-10-1-10-250 ci-project]$ git commit -m "Initializing Git master branch

> "

[master (최상위-커밋) edc87d7] Initializing Git master branch

 Committer: EC2 Default User <ec2-user@ip-10-1-10-250.ec2.internal>

이름과 전자메일 주소를 사용자 이름과 호스트 이름을 이용해서 자동으로

설정했습니다. 이 정보가 맞는지 확인하십시오. 이 메시지를 보지 않으려면 정보를

명시적으로 설정하십시오. 다음 명령어를 실행하고 편집기의 안내에 따라 설정

파일을 편집하십시오:


    git config --global --edit


이렇게 한 다음, 이 커밋에 사용한 신원 정보를 다음과 같이 해서 바꿀 수 있습니다:


    git commit --amend --reset-author


 4 files changed, 343 insertions(+)

 create mode 100644 cfn/lab-3-app-test-env.template

 create mode 100644 php/errorpage.php

 create mode 100644 php/index.php

 create mode 100644 readme.txt

[ec2-user@ip-10-1-10-250 ci-project]$ git remote add origin ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/myung

[ec2-user@ip-10-1-10-250 ci-project]$ git push origin master

Warning: Permanently added 'git-codecommit.us-east-1.amazonaws.com,72.21.203.185' (RSA) to the list of known hosts.

오브젝트 개수 세는 중: 7, 완료.

오브젝트 압축하는 중: 100% (6/6), 완료.

오브젝트 쓰는 중: 100% (7/7), 2.23 KiB | 0 bytes/s, 완료.

Total 7 (delta 0), reused 0 (delta 0)

To ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/myung

 * [new branch]      master -> master

[ec2-user@ip-10-1-10-250 ci-project]$ 

[ec2-user@ip-10-1-10-250 ci-project]$ 

[ec2-user@ip-10-1-10-250 ci-project]$ git remote -v

origin ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/myung (fetch)

origin ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/myung (push)

[ec2-user@ip-10-1-10-250 ci-project]$ 

[ec2-user@ip-10-1-10-250 ci-project]$ 

[ec2-user@ip-10-1-10-250 ci-project]$ 

[ec2-user@ip-10-1-10-250 ci-project]$ sudo ln -s /opt/git/ci-project/php/ /var/www/html/php

[ec2-user@ip-10-1-10-250 ci-project]$ git checkout -b new

새로 만든 'new' 브랜치로 전환합니다

[ec2-user@ip-10-1-10-250 ci-project]$ git branch

  master

* new

[ec2-user@ip-10-1-10-250 ci-project]$ 

[ec2-user@ip-10-1-10-250 ci-project]$ 

[ec2-user@ip-10-1-10-250 ci-project]$ 

[ec2-user@ip-10-1-10-250 ci-project]$ printf "################################\n\nInitialized new branch `date`.\n\n" >> readme.txt

[ec2-user@ip-10-1-10-250 ci-project]$ ll

합계 12

drwxr-xr-x 2 ec2-user apache   4096  8월 31 04:20 cfn

drwxr-xr-x 2 ec2-user apache   4096  8월 31 02:35 php

-rw-rw-r-- 1 ec2-user ec2-user  185  8월 31 04:30 readme.txt

[ec2-user@ip-10-1-10-250 ci-project]$ vi readme.txt 

[ec2-user@ip-10-1-10-250 ci-project]$ git add readme.txt 

[ec2-user@ip-10-1-10-250 ci-project]$ git commit -m "Recorded creation of new branch in readme.txt"

[new 72e61d7] Recorded creation of new branch in readme.txt

 Committer: EC2 Default User <ec2-user@ip-10-1-10-250.ec2.internal>

이름과 전자메일 주소를 사용자 이름과 호스트 이름을 이용해서 자동으로

설정했습니다. 이 정보가 맞는지 확인하십시오. 이 메시지를 보지 않으려면 정보를

명시적으로 설정하십시오. 다음 명령어를 실행하고 편집기의 안내에 따라 설정

파일을 편집하십시오:


    git config --global --edit


이렇게 한 다음, 이 커밋에 사용한 신원 정보를 다음과 같이 해서 바꿀 수 있습니다:


    git commit --amend --reset-author


 1 file changed, 4 insertions(+)

[ec2-user@ip-10-1-10-250 ci-project]$ git push origin new

Warning: Permanently added the RSA host key for IP address '54.239.20.180' to the list of known hosts.

오브젝트 개수 세는 중: 3, 완료.

오브젝트 압축하는 중: 100% (3/3), 완료.

오브젝트 쓰는 중: 100% (3/3), 381 bytes | 0 bytes/s, 완료.

Total 3 (delta 1), reused 0 (delta 0)

To ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/myung

 * [new branch]      new -> new

[ec2-user@ip-10-1-10-250 ci-project]$ git show :readme.txt

################################


Main branch initialized 2017. 08. 31. (목) 04:21:11 UTC.


################################


Initialized new branch 2017. 08. 31. (목) 04:30:22 UTC.


[ec2-user@ip-10-1-10-250 ci-project]$ git checkout master

'master' 브랜치로 전환합니다

[ec2-user@ip-10-1-10-250 ci-project]$ git show :readme.txt

################################


Main branch initialized 2017. 08. 31. (목) 04:21:11 UTC.


[ec2-user@ip-10-1-10-250 ci-project]$ git checkout new

'new' 브랜치로 전환합니다

[ec2-user@ip-10-1-10-250 ci-project]$ ll

합계 12

drwxr-xr-x 2 ec2-user apache   4096  8월 31 04:20 cfn

drwxr-xr-x 2 ec2-user apache   4096  8월 31 02:35 php

-rw-rw-r-- 1 ec2-user ec2-user  185  8월 31 04:32 readme.txt

[ec2-user@ip-10-1-10-250 ci-project]$ tar -xvf ~/sample-app.tgz -C /opt/git/ci-project/.

./

./php/

./php/errorpage.php

./php/index.php

./php/img/

./php/img/AWS_Logo_Web_200px.png

[ec2-user@ip-10-1-10-250 ci-project]$ ll

합계 12

drwxr-xr-x 2 ec2-user apache   4096  8월 31 04:20 cfn

drwxrwxr-x 3 ec2-user apache   4096  3월 27  2015 php

-rw-rw-r-- 1 ec2-user ec2-user  185  8월 31 04:32 readme.txt

[ec2-user@ip-10-1-10-250 ci-project]$ ll

합계 12

drwxr-xr-x 2 ec2-user apache   4096  8월 31 04:20 cfn

drwxrwxr-x 3 ec2-user apache   4096  3월 27  2015 php

-rw-rw-r-- 1 ec2-user ec2-user  185  8월 31 04:32 readme.txt

[ec2-user@ip-10-1-10-250 ci-project]$ 

[ec2-user@ip-10-1-10-250 ci-project]$ 

[ec2-user@ip-10-1-10-250 ci-project]$ vi cfn/lab-3-app-test-env.template 

[ec2-user@ip-10-1-10-250 ci-project]$ git add cfn/lab-3-app-test-env.template

[ec2-user@ip-10-1-10-250 ci-project]$ git commit -m "Corrected an issue with the test environment template"

[new eab0970] Corrected an issue with the test environment template

 Committer: EC2 Default User <ec2-user@ip-10-1-10-250.ec2.internal>

이름과 전자메일 주소를 사용자 이름과 호스트 이름을 이용해서 자동으로

설정했습니다. 이 정보가 맞는지 확인하십시오. 이 메시지를 보지 않으려면 정보를

명시적으로 설정하십시오. 다음 명령어를 실행하고 편집기의 안내에 따라 설정

파일을 편집하십시오:


    git config --global --edit


이렇게 한 다음, 이 커밋에 사용한 신원 정보를 다음과 같이 해서 바꿀 수 있습니다:


    git commit --amend --reset-author


 1 file changed, 1 insertion(+), 1 deletion(-)

[ec2-user@ip-10-1-10-250 ci-project]$ git push origin new

오브젝트 개수 세는 중: 4, 완료.

오브젝트 압축하는 중: 100% (4/4), 완료.

오브젝트 쓰는 중: 100% (4/4), 454 bytes | 0 bytes/s, 완료.

Total 4 (delta 1), reused 0 (delta 0)

To ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/myung

   72e61d7..eab0970  new -> new

[ec2-user@ip-10-1-10-250 ci-project]$ git branch

  master

* new

[ec2-user@ip-10-1-10-250 ci-project]$ git add .

[ec2-user@ip-10-1-10-250 ci-project]$ git commit -m "Completed v1.0 of sample app"

[new 93ea0f2] Completed v1.0 of sample app

 Committer: EC2 Default User <ec2-user@ip-10-1-10-250.ec2.internal>

이름과 전자메일 주소를 사용자 이름과 호스트 이름을 이용해서 자동으로

설정했습니다. 이 정보가 맞는지 확인하십시오. 이 메시지를 보지 않으려면 정보를

명시적으로 설정하십시오. 다음 명령어를 실행하고 편집기의 안내에 따라 설정

파일을 편집하십시오:


    git config --global --edit


이렇게 한 다음, 이 커밋에 사용한 신원 정보를 다음과 같이 해서 바꿀 수 있습니다:


    git commit --amend --reset-author


 3 files changed, 78 insertions(+)

 create mode 100644 php/img/AWS_Logo_Web_200px.png

[ec2-user@ip-10-1-10-250 ci-project]$ git push origin new

오브젝트 개수 세는 중: 7, 완료.

오브젝트 압축하는 중: 100% (7/7), 완료.

오브젝트 쓰는 중: 100% (7/7), 6.23 KiB | 0 bytes/s, 완료.

Total 7 (delta 0), reused 0 (delta 0)

To ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/myung

   eab0970..93ea0f2  new -> new

[ec2-user@ip-10-1-10-250 ci-project]$ git checkout master

'master' 브랜치로 전환합니다

[ec2-user@ip-10-1-10-250 ci-project]$ git merge new

업데이트 중 edc87d7..93ea0f2

Fast-forward

 cfn/lab-3-app-test-env.template |   2 +-

 php/errorpage.php               |  15 +++++++++++++++

 php/img/AWS_Logo_Web_200px.png  | Bin 0 -> 5243 bytes

 php/index.php                   |  63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 readme.txt                      |   4 ++++

 5 files changed, 83 insertions(+), 1 deletion(-)

 create mode 100644 php/img/AWS_Logo_Web_200px.png

[ec2-user@ip-10-1-10-250 ci-project]$ git push origin master

Total 0 (delta 0), reused 0 (delta 0)

To ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/myung

   edc87d7..93ea0f2  master -> master

[ec2-user@ip-10-1-10-250 ci-project]$ 



DevOps Engineering on AWS: Lab 3 - Continuous Integration - v1.5

==================================================================================================================

Using this command reference.

==================================================================================================================


1. Locate the section you need. Each section in this file matches a section in the lab instructions.

2. Replace items in angle brackets - < > - with appropriate values. For example, in this command you would replace the value - <JobFlowID> - (including the angle brackets) with the parameter indicated in the lab instructions:

elastic-mapreduce --list <JobFlowID>. You can also use find and replace to change bracketed parameters in bulk.

3. Do NOT enable the Word Wrap feature in Windows Notepad or the text editor you use to view this file.


++++1. Task: Initialize Continuous Integrations Framework

==================================================================================================================
1.2 Prepare the Git repository
==================================================================================================================

1.2.2 Create a new AWS CodeCommit Repository

aws codecommit create-repository --repository-name <repo name> --region us-east-1

1.2.3 View the contents of the setup script and run the setup script to configure permissions for CodeCommit

cat ./setup-codecommit.sh

./setup-codecommit.sh

1.2.4 Reload the bash_profile to enable profile:developer1

source ~/.bash_profile

1.2.5 Navigate to the local CI directory

cd /opt/git/ci-project

1.2.6 Initialize local Git repository

git init

1.2.7 Retrieve sample content

wget -O cfn/lab-3-app-test-env.template https://d2lrzjb0vjvpn5.cloudfront.net/devops/v1.5/lab-3-ci/static/lab-3-app-test-env.template

wget -O ~/sample-app.tgz https://d2lrzjb0vjvpn5.cloudfront.net/devops/v1.5/lab-3-ci/static/sample-app.tgz

1.2.8 Create simple text file

printf "################################\n\nMain branch initialized `date`.\n\n" >> readme.txt

1.2.9 Add files to Git repository

git add .

1.2.10 Commit files to Git repository

git commit -m "Initializing Git master branch"

1.2.11 Configure remote for CodeCommit repository

git remote add origin <cloneUrlSsh>

1.2.12 Push your commits to the origin

git push origin master

==================================================================================================================
1.3 Fork Branches
==================================================================================================================

1.3.1 Create symbolic link for unit testing

sudo ln -s /opt/git/ci-project/php /var/www/html/php

1.3.2 Create a new branch in your local Git repository

git checkout -b newWidget

1.3.3 Verify working branch

git branch

1.3.4 Update readme.txt

printf "################################\n\nInitialized newWidget branch `date`.\n\n" >> readme.txt

1.3.5 Add the readme file to a checkin

git add readme.txt

1.3.6 Commit the change

git commit -m "Recorded creation of new branch in readme.txt"

1.3.7 Push the commit to AWS CodeCommit

git push origin newWidget

1.3.8 Display current content of the readme.txt file

git show :readme.txt

1.3.9 Switch branches

git checkout master

1.3.10 View readme.txt in the master branch

git show :readme.txt

1.3.11 Switch back to the newWidget branch

git checkout newWidget

1.3.12 Extract the contents of the sample app

tar -xvf ~/sample-app.tgz -C /opt/git/ci-project/.

1.3.13 Browse to the custom app

http://<CommandHostPublicIp>/php/

==================================================================================================================
1.4 Create Automated Validation Jobs
==================================================================================================================

1.4.7 Add the branch to build

*/newWidget

1.4.9 Copy into the Schedule field

* * * * *

1.4.12 Add validation script

#!/bin/bash
/var/lib/jenkins/script/simple-test.sh

==================================================================================================================
1.5 Validate and Repair
==================================================================================================================

1.5.5 Ensure correct working directory

cd /opt/git/ci-project

1.5.6 Open up file for editing

vi cfn/lab-3-app-test-env.template

1.5.9 Add the change to the newWidget branch

git add cfn/lab-3-app-test-env.template

1.5.10 Commit changes

git commit -m "Corrected an issue with the test environment template"

1.5.11 Push changes to Git

git push origin newWidget

==================================================================================================================
1.6 Merge, Validate, and Deploy
==================================================================================================================

1.6.8 Jenkins shell command

#!/bin/bash
/var/lib/jenkins/script/test-build-deploy.sh

1.6.10 Confirm the current branch

git branch

If the result is master, switch back to newWidget:

git checkout newWidget

1.6.11 Add the changes

git add .

1.6.12 Commit the changes

git commit -m "Completed v1.0 of sample app"

1.6.13 Push the changes to the Git server

git push origin newWidget

1.6.16 Check out the master branch

git checkout master

1.6.17 Merge the newWidget branch into the master branch

git merge newWidget

1.6.18 Push the merged changes into the master branch

git push origin master


© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.


'Cloud > AWS' 카테고리의 다른 글

devops lab2  (0) 2017.08.31
devops lab1  (0) 2017.08.31
Devops on AWS  (0) 2017.08.30
aws 정기 웨비나  (0) 2017.06.13
AWS 배포 3가지  (0) 2017.06.05