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

devops lab2

Cloud/AWS2017. 8. 31. 10:27

[ec2-user@ip-10-0-10-45 cfnverifierlambda]$ ll

합계 460

-rw-r--r-- 1 ec2-user root   1118  8월 10  2016 _sampleEvent.json

-rw-r--r-- 1 ec2-user root   1885 12월 18  2015 _testdriver.js

-rw-r--r-- 1 ec2-user root   3333  8월 10  2016 cfn-verifier-lambda.js

-rw-r--r-- 1 ec2-user root 434659  8월 11  2016 cfnverifierlambda.zip

-rw-r--r-- 1 ec2-user root    561 12월 18  2015 lab-2-simple-test-cfn-lambda.template

-rw-r--r-- 1 ec2-user root   1308  1월 18  2016 lambda-iam-setup.js

-rw-r--r-- 1 ec2-user root   1068 12월 18  2015 lambda-iam-setup.ps1

-rw-r--r-- 1 ec2-user root    290  8월 30 23:08 lambda-trust-rel.json

drwxr-xr-x 4 ec2-user root   4096  8월 31 00:39 node_modules

[ec2-user@ip-10-0-10-45 cfnverifierlambda]$ aws lambda create-function --function-name "CfnVerifierLambda" --role arn:aws:iam::812140151192:role/LambdaCustomResourceExecutionPolicy --runtime nodejs4.3 --handler cfn-verifier-lambda.handler --zip-file fileb://cfnverifierlambda.zip

{

    "TracingConfig": {

        "Mode": "PassThrough"

    }, 

    "CodeSha256": "Agdpllmb6ykzgeThVcOhVsJsTFW3DdoRE7hhIgM8kk4=", 

    "FunctionName": "CfnVerifierLambda", 

    "CodeSize": 434659, 

    "MemorySize": 128, 

    "FunctionArn": "arn:aws:lambda:us-east-1:812140151192:function:CfnVerifierLambda", 

    "Version": "$LATEST", 

    "Role": "arn:aws:iam::812140151192:role/LambdaCustomResourceExecutionPolicy", 

    "Timeout": 3, 

    "LastModified": "2017-08-31T00:54:04.959+0000", 

    "Handler": "cfn-verifier-lambda.handler", 

    "Runtime": "nodejs4.3", 

    "Description": ""

}

[ec2-user@ip-10-0-10-45 cfnverifierlambda]$ 

  [복원됨]

Last login: Thu Aug 31 09:17:28 on ttys000

Myung-ui-MacBook-Air:Downloads Jay$ 

Myung-ui-MacBook-Air:Downloads Jay$ 

Myung-ui-MacBook-Air:Downloads Jay$ ssh -i qwikLABS-L1416-906673.pem ec2-user@ec2-54-210-200-31.compute-1.amazonaws.com

Last login: Thu Aug 31 00:19:51 2017 from 115.89.233.194


       __|  __|_  )

       _|  (     /   Amazon Linux AMI

      ___|\___|___|


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

[ec2-user@ip-10-0-10-45 ~]$ cd cfnverifierlambda/

[ec2-user@ip-10-0-10-45 cfnverifierlambda]$ sudo python -m SimpleHTTPServer 80

Serving HTTP on 0.0.0.0 port 80 ...


115.89.233.194 - - [31/Aug/2017 01:11:47] "GET / HTTP/1.1" 200 -

115.89.233.194 - - [31/Aug/2017 01:11:48] code 404, message File not found

115.89.233.194 - - [31/Aug/2017 01:11:48] "GET /favicon.ico HTTP/1.1" 404 -

115.89.233.194 - - [31/Aug/2017 01:11:48] "GET / HTTP/1.1" 200 -

115.89.233.194 - - [31/Aug/2017 01:11:53] "GET /_sampleEvent.json HTTP/1.1" 200 -

115.89.233.194 - - [31/Aug/2017 01:11:58] "GET /_testdriver.js HTTP/1.1" 200 -

115.89.233.194 - - [31/Aug/2017 01:12:11] "GET /node_modules/ HTTP/1.1" 200 -

115.89.233.194 - - [31/Aug/2017 01:12:13] "GET /node_modules/async/ HTTP/1.1" 200 -

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

devops lab3  (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

devops lab1

Cloud/AWS2017. 8. 31. 01:10

Myung-ui-Air:~ Jay$ sudo -H pip install awscli --upgrade --ignore-installed six

Password:

Collecting awscli

  Downloading awscli-1.11.142-py2.py3-none-any.whl (1.2MB)

    100% |████████████████████████████████| 1.2MB 422kB/s 

Collecting six

  Downloading six-1.10.0-py2.py3-none-any.whl

Collecting docutils>=0.10 (from awscli)

  Downloading docutils-0.14-py2-none-any.whl (543kB)

    100% |████████████████████████████████| 552kB 832kB/s 

Collecting botocore==1.7.0 (from awscli)

  Downloading botocore-1.7.0-py2.py3-none-any.whl (3.6MB)

    100% |████████████████████████████████| 3.6MB 134kB/s 

Collecting colorama<=0.3.7,>=0.2.5 (from awscli)

  Downloading colorama-0.3.7-py2.py3-none-any.whl

Collecting s3transfer<0.2.0,>=0.1.9 (from awscli)

  Downloading s3transfer-0.1.10-py2.py3-none-any.whl (54kB)

    100% |████████████████████████████████| 61kB 435kB/s 

Collecting rsa<=3.5.0,>=3.1.2 (from awscli)

  Downloading rsa-3.4.2-py2.py3-none-any.whl (46kB)

    100% |████████████████████████████████| 51kB 477kB/s 

Collecting PyYAML<=3.12,>=3.10 (from awscli)

  Downloading PyYAML-3.12.tar.gz (253kB)

    100% |████████████████████████████████| 256kB 494kB/s 

Collecting jmespath<1.0.0,>=0.7.1 (from botocore==1.7.0->awscli)

  Downloading jmespath-0.9.3-py2.py3-none-any.whl

Collecting python-dateutil<3.0.0,>=2.1 (from botocore==1.7.0->awscli)

  Downloading python_dateutil-2.6.1-py2.py3-none-any.whl (194kB)

    100% |████████████████████████████████| 194kB 417kB/s 

Collecting futures<4.0.0,>=2.2.0; python_version == "2.6" or python_version == "2.7" (from s3transfer<0.2.0,>=0.1.9->awscli)

  Downloading futures-3.1.1-py2-none-any.whl

Collecting pyasn1>=0.1.3 (from rsa<=3.5.0,>=3.1.2->awscli)

  Downloading pyasn1-0.3.3-py2.py3-none-any.whl (63kB)

    100% |████████████████████████████████| 71kB 642kB/s 

Installing collected packages: docutils, jmespath, six, python-dateutil, botocore, colorama, futures, s3transfer, pyasn1, rsa, PyYAML, awscli

  Running setup.py install for PyYAML ... done

Successfully installed PyYAML-3.12 awscli-1.11.142 botocore-1.7.0 colorama-0.3.7 docutils-0.14 futures-3.1.1 jmespath-0.9.3 pyasn1-0.3.3 python-dateutil-2.6.1 rsa-3.4.2 s3transfer-0.1.10 six-1.10.0

Myung-ui-Air:~ Jay$ 

Myung-ui-Air:~ Jay$ 

Myung-ui-Air:~ Jay$ 

Myung-ui-Air:~ Jay$ aws

usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]

To see help text, you can run:


  aws help

  aws <command> help

  aws <command> <subcommand> help

aws: error: too few arguments

Myung-ui-Air:~ Jay$ 

Myung-ui-Air:~ Jay$ 

Myung-ui-Air:~ Jay$ 

Myung-ui-Air:~ Jay$ ssh ec2-34-201-105-190.compute-1.amazonaws.com

The authenticity of host 'ec2-34-201-105-190.compute-1.amazonaws.com (34.201.105.190)' can't be established.

RSA key fingerprint is 34:40:59:e9:85:97:b9:2c:8c:0b:2e:38:f7:c5:3c:88.

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

Warning: Permanently added 'ec2-34-201-105-190.compute-1.amazonaws.com,34.201.105.190' (RSA) to the list of known hosts.

Permission denied (publickey).

Myung-ui-Air:~ Jay$ 

Myung-ui-Air:~ Jay$ 

Myung-ui-Air:~ Jay$ 

Myung-ui-Air:~ Jay$ cd ~/Do

Documents/ Downloads/ 

Myung-ui-Air:~ Jay$ cd ~/Do

Documents/ Downloads/ 

Myung-ui-Air:~ Jay$ cd ~/Downloads/

Myung-ui-Air:Downloads Jay$ ssh -i qwikLABS-L1415-905230.pem ec2-34-201-105-190.compute-1.amazonaws.com

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Permissions 0644 for 'qwikLABS-L1415-905230.pem' are too open.

It is required that your private key files are NOT accessible by others.

This private key will be ignored.

bad permissions: ignore key: qwikLABS-L1415-905230.pem

Permission denied (publickey).

Myung-ui-Air:Downloads Jay$ ls -al qwikLABS-L1415-905230.pem 

-rw-r--r--@ 1 Jay  staff  1675  8 31 00:07 qwikLABS-L1415-905230.pem

Myung-ui-Air:Downloads Jay$ chmod 400 qwikLABS-L1415-905230.pem 

Myung-ui-Air:Downloads Jay$ ls -al qwikLABS-L1415-905230.pem 

-r--------@ 1 Jay  staff  1675  8 31 00:07 qwikLABS-L1415-905230.pem

Myung-ui-Air:Downloads Jay$ ssh -i qwikLABS-L1415-905230.pem ec2-34-201-105-190.compute-1.amazonaws.com

Permission denied (publickey).

Myung-ui-Air:Downloads Jay$ ssh -i qwikLABS-L1415-905230.pem ec2user@ec2-34-201-105-190.compute-1.amazonaws.com

Permission denied (publickey).

Myung-ui-Air:Downloads Jay$ 

Myung-ui-Air:Downloads Jay$ 

Myung-ui-Air:Downloads Jay$ ssh -i qwikLABS-L1415-905230.pem ec2-user@ec2-34-201-105-190.compute-1.amazonaws.com


       __|  __|_  )

       _|  (     /   Amazon Linux AMI

      ___|\___|___|


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

[ec2-user@ip-10-0-10-131 ~]$ 

[ec2-user@ip-10-0-10-131 ~]$ 

[ec2-user@ip-10-0-10-131 ~]$ 

[ec2-user@ip-10-0-10-131 ~]$ aws 

usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]

To see help text, you can run:


  aws help

  aws <command> help

  aws <command> <subcommand> help

aws: error: too few arguments

[ec2-user@ip-10-0-10-131 ~]$ which aws

/usr/bin/aws

[ec2-user@ip-10-0-10-131 ~]$ aws configure

AWS Access Key ID [None]: AKIAI7GFF5RXOCTRMTAA

AWS Secret Access Key [None]: 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

Default region name [us-east-1]: 

Default output format [None]: 

[ec2-user@ip-10-0-10-131 ~]$ aws ec2 run-instances --dry-run --instance-type "t2.small" --image-id ami-8fcee4e5 --subnet-id subnet-0ccbdb44


An error occurred (DryRunOperation) when calling the RunInstances operation: Request would have succeeded, but DryRun flag is set.

[ec2-user@ip-10-0-10-131 ~]$ aws ec2 run-instances --dry-run --instance-type "t2.small" --image-id ami-8fcee4e5 --subnet-id subnet-9ff4e4d7


An error occurred (UnauthorizedOperation) when calling the RunInstances operation: You are not authorized to perform this operation. Encoded authorization failure message: mz8AEP4yMniIVDHErv-DFqUmpdaOe_vjsoWEt-_ZBp0Ho-kfkOz-t4KQN6pInXQzc6p7uzMoFCeTQFvtnUDpASymhKEyRX9LpQjnEFhXqBXkWzK_Xmq2x8BFqr0Lc7cgTzspr5hJOt9OX1IQncanLgFQiGuKxUdQj0RUSJ4qLYURpV78z67tTlo_q6IsfyiQGEtazkR65IBE6jmZjtuQc8BmKvD2__B0n7ojriJ20u5RqwSpmac5szABCPMwj23mIUIpX9PPiwrSoYK7pWnf0cGh-9vfPGurHM-NMNboXOK16sUXs4hpvvibnclYKiUl7bchBC2BpLwbWNfk8ftuzQ819JRiThFNPBgwuucBfiGgXV0GDbTrw8v0kAkdpH33o3rmJT1NQJDMBDUr5ZcEpydD4ScHkEVQ7yfvy7YGxpOV53TV1wqHA8BgDBe1n4fRafBk0ITFLivoAjfGo896uBOP8-_HqBNyzqa6znQzJ8ALHrsQhm_mcK-N7F8wKbPCadOj9i37mjyPQaovZBQctmWO0owMyxPObLQw425q-JRS_-8QzoGg0mIntHfVfTVdemUYWuwb6bPaKOuxZAH5S9yyzF-N23bGZROfqY4fB2mFJm2kPDVUwk580xNhxYkK8gqryIqrOhcnEB5XS-fiPS7QYYClQZUZsz6Iln-LSF0lIliAUozsxFRJheLCK7Gka04ip8lcJppd7rSTow9k4DGd5jQpVWY8WfMalqTNOnrWWyexOkIVh4x5r_YUgE6mOVbW-JTihHDEx8QIssAa-rC9v9G1Wi6khL_bXjg_Kx3ERTnQJIbdkp8LbByNJ2zy_49Y0ZHTcN_4N7qvL7ySq9Ra

[ec2-user@ip-10-0-10-131 ~]$ 

[ec2-user@ip-10-0-10-131 ~]$ 

[ec2-user@ip-10-0-10-131 ~]$ aws sts decode-authorization-message --encoded-message mz8AEP4yMniIVDHErv-DFqUmpdaOe_vjsoWEt-_ZBp0Ho-kfkOz-t4KQN6pInXQzc6p7uzMoFCeTQFvtnUDpASymhKEyRX9LpQjnEFhXqBXkWzK_Xmq2x8BFqr0Lc7cgTzspr5hJOt9OX1IQncanLgFQiGuKxUdQj0RUSJ4qLYURpV78z67tTlo_q6IsfyiQGEtazkR65IBE6jmZjtuQc8BmKvD2__B0n7ojriJ20u5RqwSpmac5szABCPMwj23mIUIpX9PPiwrSoYK7pWnf0cGh-9vfPGurHM-NMNboXOK16sUXs4hpvvibnclYKiUl7bchBC2BpLwbWNfk8ftuzQ819JRiThFNPBgwuucBfiGgXV0GDbTrw8v0kAkdpH33o3rmJT1NQJDMBDUr5ZcEpydD4ScHkEVQ7yfvy7YGxpOV53TV1wqHA8BgDBe1n4fRafBk0ITFLivoAjfGo896uBOP8-_HqBNyzqa6znQzJ8ALHrsQhm_mcK-N7F8wKbPCadOj9i37mjyPQaovZBQctmWO0owMyxPObLQw425q-JRS_-8QzoGg0mIntHfVfTVdemUYWuwb6bPaKOuxZAH5S9yyzF-N23bGZROfqY4fB2mFJm2kPDVUwk580xNhxYkK8gqryIqrOhcnEB5XS-fiPS7QYYClQZUZsz6Iln-LSF0lIliAUozsxFRJheLCK7Gka04ip8lcJppd7rSTow9k4DGd5jQpVWY8WfMalqTNOnrWWyexOkIVh4x5r_YUgE6mOVbW-JTihHDEx8QIssAa-rC9v9G1Wi6khL_bXjg_Kx3ERTnQJIbdkp8LbByNJ2zy_49Y0ZHTcN_4N7qvL7ySq9Ra

{

    "DecodedMessage": "{\"allowed\":false,\"explicitDeny\":false,\"matchedStatements\":{\"items\":[]},\"failures\":{\"items\":[]},\"context\":{\"principal\":{\"id\":\"AIDAIQWZTLCLNAA6YDMHE\",\"name\":\"developer1\",\"arn\":\"arn:aws:iam::495672033565:user/developer1\"},\"action\":\"ec2:RunInstances\",\"resource\":\"arn:aws:ec2:us-east-1:495672033565:subnet/subnet-9ff4e4d7\",\"conditions\":{\"items\":[{\"key\":\"495672033565:aws:cloudformation:stack-id\",\"values\":{\"items\":[{\"value\":\"arn:aws:cloudformation:us-east-1:495672033565:stack/qls-905230-dd0d1e81db5f7a63/6a1c9520-8d8e-11e7-8811-500c219a98d2\"}]}},{\"key\":\"ec2:Vpc\",\"values\":{\"items\":[{\"value\":\"arn:aws:ec2:us-east-1:495672033565:vpc/vpc-ae0433d7\"}]}},{\"key\":\"495672033565:CustomerName\",\"values\":{\"items\":[{\"value\":\"aws\"}]}},{\"key\":\"495672033565:Name\",\"values\":{\"items\":[{\"value\":\"Production Private Subnet\"}]}},{\"key\":\"ec2:ResourceTag/aws:cloudformation:stack-id\",\"values\":{\"items\":[{\"value\":\"arn:aws:cloudformation:us-east-1:495672033565:stack/qls-905230-dd0d1e81db5f7a63/6a1c9520-8d8e-11e7-8811-500c219a98d2\"}]}},{\"key\":\"495672033565:aws:cloudformation:stack-name\",\"values\":{\"items\":[{\"value\":\"qls-905230-dd0d1e81db5f7a63\"}]}},{\"key\":\"aws:Resource\",\"values\":{\"items\":[{\"value\":\"subnet/subnet-9ff4e4d7\"}]}},{\"key\":\"495672033565:aws:cloudformation:logical-id\",\"values\":{\"items\":[{\"value\":\"ProdPrivateSubnet\"}]}},{\"key\":\"aws:Account\",\"values\":{\"items\":[{\"value\":\"495672033565\"}]}},{\"key\":\"ec2:ResourceTag/aws:cloudformation:stack-name\",\"values\":{\"items\":[{\"value\":\"qls-905230-dd0d1e81db5f7a63\"}]}},{\"key\":\"ec2:AvailabilityZone\",\"values\":{\"items\":[{\"value\":\"us-east-1a\"}]}},{\"key\":\"ec2:ResourceTag/Name\",\"values\":{\"items\":[{\"value\":\"Production Private Subnet\"}]}},{\"key\":\"ec2:SubnetID\",\"values\":{\"items\":[{\"value\":\"subnet-9ff4e4d7\"}]}},{\"key\":\"495672033565:LabName\",\"values\":{\"items\":[{\"value\":\"1415\"}]}},{\"key\":\"aws:Region\",\"values\":{\"items\":[{\"value\":\"us-east-1\"}]}},{\"key\":\"aws:Service\",\"values\":{\"items\":[{\"value\":\"ec2\"}]}},{\"key\":\"ec2:ResourceTag/LabName\",\"values\":{\"items\":[{\"value\":\"1415\"}]}},{\"key\":\"aws:Type\",\"values\":{\"items\":[{\"value\":\"subnet\"}]}},{\"key\":\"ec2:Region\",\"values\":{\"items\":[{\"value\":\"us-east-1\"}]}},{\"key\":\"ec2:ResourceTag/CustomerName\",\"values\":{\"items\":[{\"value\":\"aws\"}]}},{\"key\":\"aws:ARN\",\"values\":{\"items\":[{\"value\":\"arn:aws:ec2:us-east-1:495672033565:subnet/subnet-9ff4e4d7\"}]}},{\"key\":\"ec2:ResourceTag/aws:cloudformation:logical-id\",\"values\":{\"items\":[{\"value\":\"ProdPrivateSubnet\"}]}}]}}}"

}

[ec2-user@ip-10-0-10-131 ~]$ aws sts decode-authorization-message --encoded-message mz8AEP4yMniIVDHErv-DFqUmpdaOe_vjsoWEt-_ZBp0Ho-kfkOz-t4KQN6pInXQzc6p7uzMoFCeTQFvtnUDpASymhKEyRX9LpQjnEFhXqBXkWzK_Xmq2x8BFqr0Lc7cgTzspr5hJOt9OX1IQncanLgFQiGuKxUdQj0RUSJ4qLYURpV78z67tTlo_q6IsfyiQGEtazkR65IBE6jmZjtuQc8BmKvD2__B0n7ojriJ20u5RqwSpmac5szABCPMwj23mIUIpX9PPiwrSoYK7pWnf0cGh-9vfPGurHM-NMNboXOK16sUXs4hpvvibnclYKiUl7bchBC2BpLwbWNfk8ftuzQ819JRiThFNPBgwuucBfiGgXV0GDbTrw8v0kAkdpH33o3rmJT1NQJDMBDUr5ZcEpydD4ScHkEVQ7yfvy7YGxpOV53TV1wqHA8BgDBe1n4fRafBk0ITFLivoAjfGo896uBOP8-_HqBNyzqa6znQzJ8ALHrsQhm_mcK-N7F8wKbPCadOj9i37mjyPQaovZBQctmWO0owMyxPObLQw425q-JRS_-8QzoGg0mIntHfVfTVdemUYWuwb6bPaKOuxZAH5S9yyzF-N23bGZROfqY4fB2mFJm2kPDVUwk580xNhxYkK8gqryIqrOhcnEB5XS-fiPS7QYYClQZUZsz6Iln-LSF0lIliAUozsxFRJheLCK7Gka04ip8lcJppd7rSTow9k4DGd5jQpVWY8WfMalqTNOnrWWyexOkIVh4x5r_YUgE6mOVbW-JTihHDEx8QIssAa-rC9v9G1Wi6khL_bXjg_Kx3ERTnQJIbdkp8LbByNJ2zy_49Y0ZHTcN_4N7qvL7ySq9Ra --query 'DecodedMessage' | sed -e 's/\\"/"/g' -e 's/"{/{/g' -e 's/}"/}/g' | python -m json.tool

{

    "allowed": false,

    "context": {

        "action": "ec2:RunInstances",

        "conditions": {

            "items": [

                {

                    "key": "495672033565:aws:cloudformation:stack-id",

                    "values": {

                        "items": [

                            {

                                "value": "arn:aws:cloudformation:us-east-1:495672033565:stack/qls-905230-dd0d1e81db5f7a63/6a1c9520-8d8e-11e7-8811-500c219a98d2"

                            }

                        ]

                    }

                },

                {

                    "key": "ec2:Vpc",

                    "values": {

                        "items": [

                            {

                                "value": "arn:aws:ec2:us-east-1:495672033565:vpc/vpc-ae0433d7"

                            }

                        ]

                    }

                },

                {

                    "key": "495672033565:CustomerName",

                    "values": {

                        "items": [

                            {

                                "value": "aws"

                            }

                        ]

                    }

                },

                {

                    "key": "495672033565:Name",

                    "values": {

                        "items": [

                            {

                                "value": "Production Private Subnet"

                            }

                        ]

                    }

                },

                {

                    "key": "ec2:ResourceTag/aws:cloudformation:stack-id",

                    "values": {

                        "items": [

                            {

                                "value": "arn:aws:cloudformation:us-east-1:495672033565:stack/qls-905230-dd0d1e81db5f7a63/6a1c9520-8d8e-11e7-8811-500c219a98d2"

                            }

                        ]

                    }

                },

                {

                    "key": "495672033565:aws:cloudformation:stack-name",

                    "values": {

                        "items": [

                            {

                                "value": "qls-905230-dd0d1e81db5f7a63"

                            }

                        ]

                    }

                },

                {

                    "key": "aws:Resource",

                    "values": {

                        "items": [

                            {

                                "value": "subnet/subnet-9ff4e4d7"

                            }

                        ]

                    }

                },

                {

                    "key": "495672033565:aws:cloudformation:logical-id",

                    "values": {

                        "items": [

                            {

                                "value": "ProdPrivateSubnet"

                            }

                        ]

                    }

                },

                {

                    "key": "aws:Account",

                    "values": {

                        "items": [

                            {

                                "value": "495672033565"

                            }

                        ]

                    }

                },

                {

                    "key": "ec2:ResourceTag/aws:cloudformation:stack-name",

                    "values": {

                        "items": [

                            {

                                "value": "qls-905230-dd0d1e81db5f7a63"

                            }

                        ]

                    }

                },

                {

                    "key": "ec2:AvailabilityZone",

                    "values": {

                        "items": [

                            {

                                "value": "us-east-1a"

                            }

                        ]

                    }

                },

                {

                    "key": "ec2:ResourceTag/Name",

                    "values": {

                        "items": [

                            {

                                "value": "Production Private Subnet"

                            }

                        ]

                    }

                },

                {

                    "key": "ec2:SubnetID",

                    "values": {

                        "items": [

                            {

                                "value": "subnet-9ff4e4d7"

                            }

                        ]

                    }

                },

                {

                    "key": "495672033565:LabName",

                    "values": {

                        "items": [

                            {

                                "value": "1415"

                            }

                        ]

                    }

                },

                {

                    "key": "aws:Region",

                    "values": {

                        "items": [

                            {

                                "value": "us-east-1"

                            }

                        ]

                    }

                },

                {

                    "key": "aws:Service",

                    "values": {

                        "items": [

                            {

                                "value": "ec2"

                            }

                        ]

                    }

                },

                {

                    "key": "ec2:ResourceTag/LabName",

                    "values": {

                        "items": [

                            {

                                "value": "1415"

                            }

                        ]

                    }

                },

                {

                    "key": "aws:Type",

                    "values": {

                        "items": [

                            {

                                "value": "subnet"

                            }

                        ]

                    }

                },

                {

                    "key": "ec2:Region",

                    "values": {

                        "items": [

                            {

                                "value": "us-east-1"

                            }

                        ]

                    }

                },

                {

                    "key": "ec2:ResourceTag/CustomerName",

                    "values": {

                        "items": [

                            {

                                "value": "aws"

                            }

                        ]

                    }

                },

                {

                    "key": "aws:ARN",

                    "values": {

                        "items": [

                            {

                                "value": "arn:aws:ec2:us-east-1:495672033565:subnet/subnet-9ff4e4d7"

                            }

                        ]

                    }

                },

                {

                    "key": "ec2:ResourceTag/aws:cloudformation:logical-id",

                    "values": {

                        "items": [

                            {

                                "value": "ProdPrivateSubnet"

                            }

                        ]

                    }

                }

            ]

        },

        "principal": {

            "arn": "arn:aws:iam::495672033565:user/developer1",

            "id": "AIDAIQWZTLCLNAA6YDMHE",

            "name": "developer1"

        },

        "resource": "arn:aws:ec2:us-east-1:495672033565:subnet/subnet-9ff4e4d7"

    },

    "explicitDeny": false,

    "failures": {

        "items": []

    },

    "matchedStatements": {

        "items": []

    }

}

[ec2-user@ip-10-0-10-131 ~]$ 

[ec2-user@ip-10-0-10-131 ~]$ aws ec2 stop-instances --instance-id i-07ca9c167c7c615c5


An error occurred (UnauthorizedOperation) when calling the StopInstances operation: You are not authorized to perform this operation. Encoded authorization failure message: TO3LFBM3EwFgbbdN08WFtL7MzhIk1m5NZhKzUxqsHMv9-I0jQBZQ_JM2ooXjCClQF1PZT8ygU-WMC6sEgfcC7iq4fkAjacOikrAZOKlgFx9qm_ggejLNY3QE61H587nE5IiqftJ6gPGrvucNsC97pCL715W8UcKOQyGliOhIATjRaVwCc68u9HYre58BIRjkzLHlB3-shhkzUUabf-_vxz24hmu5bdAeXt-fmtGmZo6XCAXCyK3LtrjNKJVoc07UTuBW4CR1gRorAEHqXTramjiSMJIQuOW08fq2l3jHjcKaaDxpfYjNfyZTpUaHwnwvVFRrGt18527IvvsUX1GRmGatFdTn5MokAGmPPuPxwCabnRBltPve3XhJT40Hy7bKjmD87jtKRFcozHhPeAZSzrW_jdk8ZPeJK7IO5s1qu9CTKLnmVi8mlMH4rCUZxbM3Y0LbZrNaf0Z2IEbXjPnnX2BLeAlpPu1cJhkoJnPty2EgLsP4OkWGz_Ex--t8yvLpT1GFtRpnRRy7V5b3cov9f_PhM_his0Dzykl_vvv9a1anv4vVuNWjF7LLgN8AXDdS-7CZGE_Mlfiw3ZK3VL60TnbIT-R-1e-GDfM1fINZkK_N1VkqhJh1jjbfDW4vnWld83ACQFOwC8wz_rh9cX_YWeveZhN4pBJeQASivaPvclztqjXH3JEUBwNtTDdbjOBmOvNwg2IlA3xmemXvuYtZctDwI7jX1neVsZ-f8cKTaObP9OWIfoFY9qlss2YhppjaxsVuJwosMtjKomxJp5kJ3om83BoCdhE7HUlx5E70Dddd6an3gk8PS1cB_T96JViPE654WwHhW4C5e5MnDFKDyg1aQiI6w0q3SKIRwBO-pvFwwsHsSwYfhsDjz452oVchQl94j0G1afTFCKcmFNLl1znNx1gcUZ8ShnNBTf4LgBhA8Gc077pYVZXhT_nuxx4aa1c

[ec2-user@ip-10-0-10-131 ~]$ aws ec2 stop-instances --instance-id i-0843ec9cea883ab24

{

    "StoppingInstances": [

        {

            "InstanceId": "i-0843ec9cea883ab24", 

            "CurrentState": {

                "Code": 64, 

                "Name": "stopping"

            }, 

            "PreviousState": {

                "Code": 16, 

                "Name": "running"

            }

        }

    ]

}

[ec2-user@ip-10-0-10-131 ~]$ 

[ec2-user@ip-10-0-10-131 ~]$ aws ec2 stop-instances --instance-id i-0843ec9cea883ab24

{

    "StoppingInstances": [

        {

            "InstanceId": "i-0843ec9cea883ab24", 

            "CurrentState": {

                "Code": 64, 

                "Name": "stopping"

            }, 

            "PreviousState": {

                "Code": 64, 

                "Name": "stopping"

            }

        }

    ]

}

[ec2-user@ip-10-0-10-131 ~]$ 



---------------------------------------------------------------------------------------------------



참고

Lab1ProdVPC vpc-ae0433d7

Lab1DevSubnetID subnet-0ccbdb44

Lab1Region us-east-1

Lab1DevVPC vpc-921027eb

Lab1AccountID 495672033565

Lab1ProdNATID i-07ca9c167c7c615c5

Lab1ProdSubnetID subnet-9ff4e4d7

Lab1DevNATID i-0843ec9cea883ab24

Lab1AMIID ami-8fcee4e5 and

qwikLAB {"Connection": "ssh ec2-user@34.201.105.190"} Outputs to be used by qwikLAB







evOps Engineering on AWS: Lab 1 - Configuring DevOps Roles on AWS - v1.6 (Linux)

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

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: Restrict Developer Access to Production++++

==================================================================================================================
1.2 Create an Initial IAM Policy
==================================================================================================================

1.2.1 Copy the IAM policy

{
	"Version" : "2012-10-17",
	"Statement" : [{
			"Sid" : "Stmt1425065597000",
			"Effect" : "Allow",
			"Action" : [
				"ec2:RunInstances"
			],
			"Resource" : "arn:aws:ec2:<Lab1Region>:<Lab1AccountID>:subnet/*",
			"Condition" : {
				"StringEquals" : {
					"ec2:Vpc" : "arn:aws:ec2:<Lab1Region>:<Lab1AccountID>:vpc/<Lab1DevVPC>"
				}
			}
		}, {
			"Effect" : "Allow",
			"Action" : "ec2:RunInstances",
			"Resource" : [
				"arn:aws:ec2:<Lab1Region>:<Lab1AccountID>:instance/*",
				"arn:aws:ec2:<Lab1Region>:<Lab1AccountID>:volume/*",
				"arn:aws:ec2:<Lab1Region>:<Lab1AccountID>:network-interface/*",
				"arn:aws:ec2:<Lab1Region>:<Lab1AccountID>:key-pair/*",
				"arn:aws:ec2:<Lab1Region>:<Lab1AccountID>:security-group/*",
				"arn:aws:ec2:<Lab1Region>::image/*"
			]
		}, {
			"Effect" : "Allow",
			"Action" : ["sts:DecodeAuthorizationMessage"],
			"Resource" : "*"
		}
	]
}


==================================================================================================================
1.6 Test Developer Permissions
==================================================================================================================

1.6.9 Test permissions from bastion command line

aws ec2 run-instances --dry-run --instance-type "t2.small" --image-id <Lab1AMIID> --subnet-id <Lab1DevSubnetID>


==================================================================================================================
1.7 Debug IAM Permissions Issues
==================================================================================================================

1.7.1 Attempt to create an instance in the production VPC instead

aws ec2 run-instances --dry-run --instance-type "t2.small" --image-id <Lab1AMIID> --subnet-id <Lab1ProdSubnetID>

1.7.3 Decode the failure message

aws sts decode-authorization-message --encoded-message <FailureMessage>

1.7.4 Pretty-print the decoded authorization message

aws sts decode-authorization-message --encoded-message <FailureMessage> --query 'DecodedMessage' | sed -e 's/\\"/"/g' -e 's/"{/{/g' -e 's/}"/}/g' | python -m json.tool


++++2. Challenge: Deny Permissions to Infrastructure Instances++++

==================================================================================================================
2.1 Grant Additional Permissions on Instances in Developer VPC
==================================================================================================================

2.1.5 Paste Allow statements into existing IAM policy

,
	 {
			"Effect" : "Allow",
			"Action" : [
				"ec2:StartInstances",
				"ec2:StopInstances",
				"ec2:TerminateInstances"
			],
			"Resource" : [
				"arn:aws:ec2:<Lab1Region>:<Lab1AccountID>:instance/*"
			],
			"Condition" : {
				"StringEquals" : {
						"ec2:ResourceTag/DeploymentType" : "Development"
				}
			}
		},
	 {
			"Effect" : "Deny",
			"Action" : [
				"ec2:StartInstances",
				"ec2:StopInstances",
				"ec2:TerminateInstances"
			],
			"Resource" : [
				"arn:aws:ec2:<Lab1Region>:<Lab1AccountID>:instance/*"
			],
			"Condition" : {
				"StringEquals" : {
						"ec2:ResourceTag/InstanceType" : "Infrastructure"
				}
			}
		}

2.1.7 Attempt to stop the NAT instance in Production VPC

aws ec2 stop-instances --instance-id <Lab1ProdNATID>

2.1.8 Attempt to stop the NAT instance in Development VPC

aws ec2 stop-instances --instance-id <Lab1DevNATID>


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




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

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

Devops on AWS

Cloud/AWS2017. 8. 30. 09:30

301 세미나 - 심화학습 및 교육


http://aws-class.com/14245



Devops

- 고객에게 새로운 서비스를 빠르게 딜리버리

- CI, CD

- 자주 릴리즈, SW가 가벼워져야한다

- 클라우드...

모두 한셋트로 움직인다.



CI, CD : 자동화하는데 있어서, 장애가 되는 요소를 하나씩 제거한다 (테스트 -> 패키징...)

릴리즈

넷플릭스 : 카나리아, 배포한 카나리아에서 데이터(메트릭) 수집 (HTTP응답코드 수집...등 1000개)



AWS는 시간당 6000번 릴리즈


모니터링 : 코드파이프라인의 모든 단계에서의 모니터링


코드형 인프라

클라우드의 모든 자원은 temporary : 쓰고 바로 버린다


CodeFormation

: AWS 리소스 뿐만 아니라, 외부 자원(Ansible, chef 쿡북, puppet 매니페스트...)도 다룰수 있다.


[보안]

파이프라인 단계간의 보안

단계내의 권한

우수한 보안사례 참고하라

계정, 접근권한에 대한 보안

AWS Inspector

SecDevOps







IAM policy smulatior


bit.ly/2wn5jiX



cloudping.info









[2일차]

젠킨스

https://wiki.jenkins.io/display/JENKINS/Amazon+EC2+Plugin


CD

- Red/Black : 넷플릭스, 카나리아


Code Deploy

- AS에서 일부만 WAR 교체하여 inplace로 배포, 비용효율적, ELBAS

- Integrating AWS CodeDeploy with GitHub

http://docs.aws.amazon.com/ko_kr/codedeploy/latest/userguide/integrations-partners-github.html


OpsWorks

멀티레이어 로 구성 : Stack -> Layer -> Instance -> ...

반면, beanstalks 은 싱글레이어



--generate-cli-skeleton / --cli-input-json



[3일차]


ECS, Blox

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

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

aws 정기 웨비나

Cloud/AWS2017. 6. 13. 13:20

https://aws.amazon.com/ko/about-aws/events/

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

devops lab1  (0) 2017.08.31
Devops on AWS  (0) 2017.08.30
AWS 배포 3가지  (0) 2017.06.05
EB CLI  (0) 2017.06.05
Using Auto Scaling with AWS Lambda  (0) 2017.06.02

AWS 배포 3가지

Cloud/AWS2017. 6. 5. 18:09

1. Elastic Beanstock



2. 날로 배포 (ubuntu)



3. Docker

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

Devops on AWS  (0) 2017.08.30
aws 정기 웨비나  (0) 2017.06.13
EB CLI  (0) 2017.06.05
Using Auto Scaling with AWS Lambda  (0) 2017.06.02
Making Your Environment Highly Available  (0) 2017.06.02

EB CLI

Cloud/AWS2017. 6. 5. 03:29


https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-install-windows.html


C:\Users\myung>pip --version
pip 9.0.1 from c:\users\myung\appdata\local\programs\python\python36-32\lib\site-packages (python 3.6)

C:\Users\myung>
C:\Users\myung>
C:\Users\myung>
C:\Users\myung>
C:\Users\myung>
C:\Users\myung>pip install --upgrade --user awsebcli
Collecting awsebcli
  Downloading awsebcli-3.10.1.tar.gz (226kB)
    100% |████████████████████████████████| 235kB 679kB/s
Collecting pyyaml>=3.11 (from awsebcli)
  Downloading PyYAML-3.12.tar.gz (253kB)
    100% |████████████████████████████████| 256kB 2.0MB/s
Collecting botocore>=1.0.1 (from awsebcli)
  Downloading botocore-1.5.60-py2.py3-none-any.whl (3.5MB)
    100% |████████████████████████████████| 3.5MB 316kB/s
Collecting cement==2.8.2 (from awsebcli)
  Downloading cement-2.8.2.tar.gz (165kB)
    100% |████████████████████████████████| 174kB 3.4MB/s
Collecting colorama==0.3.7 (from awsebcli)
  Downloading colorama-0.3.7-py2.py3-none-any.whl
Collecting pathspec==0.5.0 (from awsebcli)
  Downloading pathspec-0.5.0.tar.gz
Collecting setuptools>=20.0 (from awsebcli)
  Downloading setuptools-36.0.1-py2.py3-none-any.whl (476kB)
    100% |████████████████████████████████| 481kB 1.9MB/s
Collecting docopt<0.7,>=0.6.1 (from awsebcli)
  Downloading docopt-0.6.2.tar.gz
Collecting requests<=2.9.1,>=2.6.1 (from awsebcli)
  Downloading requests-2.9.1-py2.py3-none-any.whl (501kB)
    100% |████████████████████████████████| 501kB 1.7MB/s
Collecting websocket-client<1.0,>=0.11.0 (from awsebcli)
  Downloading websocket_client-0.40.0.tar.gz (196kB)
    100% |████████████████████████████████| 204kB 2.8MB/s
Collecting docker-py<=1.7.2,>=1.1.0 (from awsebcli)
  Downloading docker-py-1.7.2.tar.gz (68kB)
    100% |████████████████████████████████| 71kB 4.0MB/s
Collecting dockerpty<=0.4.1,>=0.3.2 (from awsebcli)
  Downloading dockerpty-0.4.1.tar.gz
Collecting semantic_version==2.5.0 (from awsebcli)
  Downloading semantic_version-2.5.0-py3-none-any.whl
Collecting tabulate==0.7.5 (from awsebcli)
  Downloading tabulate-0.7.5.tar.gz
Collecting termcolor==1.1.0 (from awsebcli)
  Downloading termcolor-1.1.0.tar.gz
Collecting docutils>=0.10 (from botocore>=1.0.1->awsebcli)
  Downloading docutils-0.13.1-py3-none-any.whl (536kB)
    100% |████████████████████████████████| 542kB 1.7MB/s
Collecting python-dateutil<3.0.0,>=2.1 (from botocore>=1.0.1->awsebcli)
  Downloading python_dateutil-2.6.0-py2.py3-none-any.whl (194kB)
    100% |████████████████████████████████| 194kB 3.1MB/s
Collecting jmespath<1.0.0,>=0.7.1 (from botocore>=1.0.1->awsebcli)
  Downloading jmespath-0.9.3-py2.py3-none-any.whl
Collecting six (from websocket-client<1.0,>=0.11.0->awsebcli)
  Downloading six-1.10.0-py2.py3-none-any.whl
Installing collected packages: pyyaml, docutils, six, python-dateutil, jmespath, botocore, cement, colorama, pathspec, setuptools, docopt, requests, websocket-client, docker-py, dockerpty, semantic-version, tabulate, termcolor, awsebcli
  Running setup.py install for pyyaml ... done
  Running setup.py install for cement ... done
  Running setup.py install for pathspec ... done
  Running setup.py install for docopt ... done
  Running setup.py install for websocket-client ... done
  Running setup.py install for docker-py ... done
  Running setup.py install for dockerpty ... done
  Running setup.py install for tabulate ... done
  Running setup.py install for termcolor ... done
  Running setup.py install for awsebcli ... done
Successfully installed awsebcli-3.10.1 botocore-1.5.60 cement-2.8.2 colorama-0.3.7 docker-py-1.7.2 dockerpty-0.4.1 docopt-0.6.2 docutils-0.13.1 jmespath-0.9.3 pathspec-0.5.0 python-dateutil-2.6.0 pyyaml-3.12 requests-2.9.1 semantic-version-2.5.0 setuptools-36.0.1 six-1.10.0 tabulate-0.7.5 termcolor-1.1.0 websocket-client-0.40.0

C:\Users\myung>eb --version





http://docs.aws.amazon.com/IAM/latest/UserGuide/getting-started_create-admin-group.html
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-configuration.html
http://docs.aws.amazon.com/IAM/latest/UserGuide/getting-started_create-admin-group.html









http://docs.aws.amazon.com/ko_kr/general/latest/gr/managing-aws-access-keys.html








http://docs.aws.amazon.com/ko_kr/AmazonRDS/latest/UserGuide/CHAP_Troubleshooting.html




453166549273

super_myung
1324!

Access key ID    Secret access key
AKIAJMK3OFEHE5YXF2FA    SKI0/0op+cEBUunvQtFQMqGDNOMRZCjiZHbAFxGT

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

aws 정기 웨비나  (0) 2017.06.13
AWS 배포 3가지  (0) 2017.06.05
Using Auto Scaling with AWS Lambda  (0) 2017.06.02
Making Your Environment Highly Available  (0) 2017.06.02
Implementing a Serverless Architecture With Managed Services  (0) 2017.06.02





{
      "Version": "2012-10-17",
      "Statement": [
          {
            "Action": [
              "logs:CreateLogGroup",
              "logs:CreateLogStream",
              "logs:PutLogEvents"
            ],
            "Resource": "arn:aws:logs:*:*:*",
            "Effect": "Allow"
          }
      ]
}







from __future__ import print_function

import json
import boto3

print('Loading function')


def lambda_handler(event, context):
    # print("Received event: " + json.dumps(event, indent=2))
    # Extract the EC2 instance id from the Auto Scaling lifecycle event notification
    message = event['Records'][0]['Sns']['Message']
    autoscalingInfo = json.loads(message)
    ec2InstanceId = autoscalingInfo['EC2InstanceId']

    print ("***Adding tag to EC2 instance with id: " + ec2InstanceId)

    # Add a tag to the EC2 instance: Key = ManualScaling, Value = Yes
    ec2 = boto3.client('ec2')
    response = ec2.create_tags(
        DryRun=False,
        Resources=[
            ec2InstanceId
        ],
        Tags=[
            {
                'Key': 'ManualScaling',
                'Value': 'Yes'
            },
        ]
    )

    ec2 = boto3.resource('ec2')

    print ("***Creating snapshot of volumes attached to EC2 instance with id: " + ec2InstanceId)

    for v in ec2.volumes.filter(Filters=[{'Name': 'attachment.instance-id', 'Values': [ec2InstanceId]}]):
        print(v.volume_id)
        description = 'autosnap-%s-%s' % ( ec2InstanceId, v.volume_id )

        if v.create_snapshot(description):
            print("\t\tSnapshot created with description [%s]" % description)

    return "ec2InstanceId"





v.create_snapshot(Description=description) 으로 변경???





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

AWS 배포 3가지  (0) 2017.06.05
EB CLI  (0) 2017.06.05
Making Your Environment Highly Available  (0) 2017.06.02
Implementing a Serverless Architecture With Managed Services  (0) 2017.06.02
Multi-Region Failover with Route 53  (0) 2017.06.02






























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

EB CLI  (0) 2017.06.05
Using Auto Scaling with AWS Lambda  (0) 2017.06.02
Implementing a Serverless Architecture With Managed Services  (0) 2017.06.02
Multi-Region Failover with Route 53  (0) 2017.06.02
Developing a web app on AWS  (0) 2017.06.02











from __future__ import print_function

import json
import urllib
import boto3
import csv

print('Loading function')

customerTableName = 'Customer'
transactionsTableName = 'Transactions'

s3 = boto3.resource('s3')
dynamodb = boto3.resource('dynamodb')
customerTable = dynamodb.Table(customerTableName);
transactionsTable = dynamodb.Table(transactionsTableName);

def lambda_handler(event, context):
    print("Received event: " + json.dumps(event, indent=2))

    # Get the bucket and object key from the event
    bucket = event['Records'][0]['s3']['bucket']['name']
    key = urllib.unquote_plus(event['Records'][0]['s3']['object']['key']).decode('utf8')
    trnFileName = '/tmp/transactions.txt'
    try:
        s3.meta.client.download_file(bucket, key, trnFileName)
    except Exception as e:
        print(e)
        print('Error getting object {} from bucket {}. Make sure they exist and your bucket is in the same region as this function.'.format(key, bucket))
        raise e

    # Read the Transactions CSV file. Delimiter is the '|' character
    with open(trnFileName) as csvfile:
        reader = csv.DictReader(csvfile, delimiter='|')
        for row in reader:
            print(row['customer_id'], row['customer_address'], row['trn_id'], row['trn_date'], row['trn_amount'])
            # Insert customer id and address in customer DynamoDB table
            try:
                resp = customerTable.put_item(
                    Item={
                        'CustomerId': row['customer_id'],
                        'Address': row['customer_address']})
                resp = transactionsTable.put_item(
                    Item={
                        'CustomerId': row['customer_id'],
                        'TransactionId': row['trn_id'],
                        'TransactionDate': row['trn_date'],
                        'TransactionAmount': int(row['trn_amount'])})
            except Exception as e:
                 print(e)
                 print("Unable to insert data into DynamoDB table".format(e))

    return "done"









from __future__ import print_function

import json
import boto3

print('Loading function')

### STUDENT TODO: Update the value of snsTopicArn ###
snsTopicArn = ''

dynamodb = boto3.resource('dynamodb')
transactionTotalTableName = 'TransactionTotal'
transactionsTotalTable = dynamodb.Table(transactionTotalTableName);

sns = boto3.client('sns')

def lambda_handler(event, context):
    print("Received event: " + json.dumps(event, indent=2))
    for record in event['Records']:
        customerId = record['dynamodb']['NewImage']['CustomerId']['S']
        transactionAmount = int(record['dynamodb']['NewImage']['TransactionAmount']['N'])

        response = transactionsTotalTable.update_item(
            Key={
                'CustomerId': customerId
            },
            UpdateExpression="add accountBalance :val",
            ExpressionAttributeValues={
                ':val': transactionAmount
            },
            ReturnValues="UPDATED_NEW"
        )
        print("Added transaction to account balance in TransactionTotal table")

        latestAccountBalance = response['Attributes']['accountBalance']
        print("Latest account balance: ".format(latestAccountBalance))

        if latestAccountBalance  >= 1500:
            message = '{"customerID": "' + customerId + '", ' + '"accountBalance": "' + str(latestAccountBalance) + '"}'
            print(message)
            print("Account balance is very high: ".format(latestAccountBalance))
            sns.publish(
                TopicArn=snsTopicArn,
                Message=message,
                Subject='Warning! Account balance is very high',
                MessageStructure='raw'
            )


    return 'Successfully processed {} records.'.format(len(event['Records']))







  snsTopicArn = '_<ARN for HighAccountBalanceAlertSNSTopic>_'






https://s3-us-west-2.amazonaws.com/us-west-2-aws-staging/awsu-ilt/academy-cca/v3.0/labs/lab12-serverless/scripts/transactions.txt


customer_id|customer_address|trn_id|trn_date|trn_amount
C1|1 Smith Street, London|T01|03/16/2016|100
C2|2 Smith Street, London|T02|03/16/2016|200
C2|2 Smith Street, London|T03|03/16/2016|50
C2|2 Smith Street, London|T04|03/16/2016|300
C2|2 Smith Street, London|T05|03/16/2016|100
C2|2 Smith Street, London|T06|03/16/2016|150
C2|2 Smith Street, London|T07|03/16/2016|400
C2|2 Smith Street, London|T08|03/16/2016|50
C2|2 Smith Street, London|T09|03/16/2016|50
C2|2 Smith Street, London|T10|03/16/2016|10
C2|2 Smith Street, London|T11|03/16/2016|10
C2|2 Smith Street, London|T12|03/16/2016|10
C2|2 Smith Street, London|T13|03/16/2016|20
C1|1 Smith Street, London|T14|03/16/2016|51
C1|1 Smith Street, London|T15|03/16/2016|25
C1|1 Smith Street, London|T16|03/16/2016|27
C1|1 Smith Street, London|T17|03/16/2016|29
C1|1 Smith Street, London|T18|03/16/2016|19
C1|1 Smith Street, London|T19|03/16/2016|33
C1|1 Smith Street, London|T20|03/16/2016|35
C1|1 Smith Street, London|T21|03/16/2016|39
C1|1 Smith Street, London|T22|03/16/2016|41
C1|1 Smith Street, London|T23|03/16/2016|199
C2|2 Smith Street, London|T24|03/16/2016|400





        {
          "Type" : "Notification",
          "MessageId" : "eb0d030d-5f2d-5695-8f22-4c68d0335c0b",
          "TopicArn" : "arn:aws:sns:us-east-1:123456789:HighAccountBalanceAlertSNSTopic",
          "Subject" : "Warning! Account balance is very high",
          "Message" : "{\"customerID\": \"C2\", \"accountBalance\": \"1750\"}",
        ...
        }





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

Using Auto Scaling with AWS Lambda  (0) 2017.06.02
Making Your Environment Highly Available  (0) 2017.06.02
Multi-Region Failover with Route 53  (0) 2017.06.02
Developing a web app on AWS  (0) 2017.06.02
exercise 1  (0) 2017.06.01