<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Young Woo Jung on Medium]]></title>
        <description><![CDATA[Stories by Young Woo Jung on Medium]]></description>
        <link>https://medium.com/@youngwoojung?source=rss-95bc8e3af337------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*Ti3SpifXJCcZlj6qnbhVHQ.png</url>
            <title>Stories by Young Woo Jung on Medium</title>
            <link>https://medium.com/@youngwoojung?source=rss-95bc8e3af337------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 07:29:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@youngwoojung/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[AWS Case Study — 리파인]]></title>
            <link>https://medium.com/saltware/aws-case-study-%EB%A6%AC%ED%8C%8C%EC%9D%B8-ac6761e6c119?source=rss-95bc8e3af337------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac6761e6c119</guid>
            <dc:creator><![CDATA[Young Woo Jung]]></dc:creator>
            <pubDate>Mon, 14 Apr 2025 05:16:05 GMT</pubDate>
            <atom:updated>2025-04-14T05:16:05.822Z</atom:updated>
            <content:encoded><![CDATA[<h3>AWS Case Study — 리파인</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yyH8p_HPoVlw8b20" /><figcaption>Photo by <a href="https://unsplash.com/@growtika?utm_source=medium&amp;utm_medium=referral">Growtika</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>고객사 소개</h4><figure><img alt="http://www.refine.co.kr/" src="https://cdn-images-1.medium.com/max/400/0*0OpFInG0rVL4i3gg.png" /><figcaption><a href="http://www.refine.co.kr/">http://www.refine.co.kr</a></figcaption></figure><p><a href="http://www.refine.co.kr/main.php">리파인</a>은 금융환경 변화에 따른 부동산, 금융, 리스크 관리 서비스를 제공하기 위해 2000년도에 한국 감정원에서 부동산벤처로 기획 및 설립된 기업입니다. 금융기관 및 공공기관 등에서 부동산 거래, 담보 대출, 전월세 대출 등을 진행하기 전에 권리를 조사하고, 하자 여부를 밝혀내는 사업을 하고 있습니다. 당사는 부동산과 금융 시장에 IT 기술을 접목한 프롭테크로써 부동산 분야의 혁신을 도모하고 있으며, 최근 네이버파이낸셜과 협업하여 주택도시보증공사(HUG)의 ‘임대보증금보증보험 가입 서비스’를 비대면으로 출시했습니다.</p><p>이에 리파인이 당면한 과제는 무엇이고 솔트웨어를 통해 어떤 솔루션을 검토 및 도입하였는지 알아보겠습니다.</p><h4>당면 과제</h4><ul><li>기존 서비스 수요 증가와 신규 서비스 개발로 인한 서버 분리 및 이전 필요</li><li>코드화된 인프라 구축으로 인한 이력 및 이슈 관리 필요</li><li>모니터링, 부하 테스트, 비용 측정 등 매니지먼트 툴 부재</li><li>완전히 자동화된 빌드 및 배포(CI/CD) 시스템 부재</li><li>오토 스케일링 및 롤링 업데이트 등 유연하고 중단 없는 서비스로의 개선 필요</li></ul><p>이에 솔트웨어는 AWS EKS 컨설팅과 기술지원으로 표준화된(정형화된 블럭 방식) 인프라 구축을 통해서 모듈화(세분화) 기반으로 고객사의 당면 과제를 해결했습니다.</p><h4>세부 구성 내역</h4><ol><li>특정 클라우드 벤더에 귀속되지 않으면서 멀티(또는 하이브리드) 클라우드 구축이 가능한 Terraform을 통해서 코드형 인프라 구축</li><li>Terraform을 통해서 생성되는 리소스들을 비슷한 유형 혹은 패턴끼리 묶어서 Module을 생성하고, 해당 Module을 재사용함으로써 표준화된 인프라 구축</li><li>AWS 리소스 뿐만 아니라 오픈소스 솔루션 설치 및 구성, 애플리케이션 배포 파이프라인까지 모두 코드형 인프라에 포함</li><li>수동으로 생성된 리소스들을 코드형 인프라로 재구축</li><li>수동으로 실행되던 배포 프로세스를 자동화로 변경</li><li>각각의 마이크로 서비스별로 생성된 애플리케이션 구동 파일을 템플릿 형식으로 표준화</li><li>내부 인력을 통해서 구축 및 운영되면 데이터베이스 서버를 SaaS 방식으로 이전</li><li>애플리케이션 코드 및 설정파일에 하드코딩 되어 있던 암호 정보를 오픈소스 암호 관리 서비스인 Vault로 이전</li><li>오픈소스 모니터링 스택인 Prometheus, Alertmanager, Grafana, Thanos를 통해 인프라 성능 분석 및 장애대응에 필요한 지표 수집</li><li>수집된 자료 기반 반영구 저장소에 보관하고 대시보드 및 알람 구성</li><li>애플리케이션 오류를 감지해 실시간으로 알람을 보내주는 오픈소스 솔루션 Sentry 구축</li></ol><h4>AWS 아키텍처</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wgrpT4mT3zdpB5lDi5PqzQ.png" /><figcaption>AWS 아키텍처</figcaption></figure><h4>실제 사용한 주요 AWS 서비스</h4><ul><li>Amazon VPC</li><li>Amazon Elastic Compute Cloud (EC2)</li><li>Amazon Elastic Kubernetes Service(EKS)</li><li>Amazon Elastic Container Registry(ECR)</li><li>Application Load Balancer</li><li>Network Load Balancer</li><li>Auto Scaling</li><li>Amazon CloudWatch</li></ul><h4>오픈소스 솔루션</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VNWx_w7YXdU_f_FQCJGYxg.png" /><figcaption>솔트웨어를 통해서 구축된 오픈소스 솔루션</figcaption></figure><h4>성과</h4><ul><li>각 서비스별 표준화된 방식의 클러스터 구성으로 과부하 최소화</li><li>범용 코드형 인프라 도구를 통한 리소스 생성 및 GitLab으로 버전 관리</li><li>각각의 글로벌 범용 오픈소스의 선도적 도입</li><li>클릭 한 번으로 실시간 운영 중인 서비스에 반영되도록 구성</li><li>고가용성, 확장성, 내결함성을 모두 충족하는 인프라 구축</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Xm_Uw4wd-1BgczYS.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac6761e6c119" width="1" height="1" alt=""><hr><p><a href="https://medium.com/saltware/aws-case-study-%EB%A6%AC%ED%8C%8C%EC%9D%B8-ac6761e6c119">AWS Case Study — 리파인</a> was originally published in <a href="https://medium.com/saltware">Saltware</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Case Study — 라온시큐어]]></title>
            <link>https://medium.com/saltware/aws-case-study-%EB%9D%BC%EC%98%A8%EC%8B%9C%ED%81%90%EC%96%B4-187764649ab4?source=rss-95bc8e3af337------2</link>
            <guid isPermaLink="false">https://medium.com/p/187764649ab4</guid>
            <dc:creator><![CDATA[Young Woo Jung]]></dc:creator>
            <pubDate>Mon, 25 Mar 2024 01:47:22 GMT</pubDate>
            <atom:updated>2024-03-25T01:48:03.828Z</atom:updated>
            <content:encoded><![CDATA[<h3>AWS Case Study — 라온시큐어</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_XbDO71d2glls4xJ" /><figcaption>Photo by <a href="https://unsplash.com/@flyd2069?utm_source=medium&amp;utm_medium=referral">FlyD</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>고객사 소개</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sQu1Oi8C1Jlvhypnu8TWVw.png" /><figcaption><a href="https://www.raonsecure.com/">https://www.raonsecure.com/</a></figcaption></figure><p>라온시큐어는 모바일 보안∙인증 분야 선도기업으로 금융, 공공, 국방 등 다양한 분야에서 쌓아온 노하우와 레퍼런스를 바탕으로 고객에게 안전하고 편리한 디지털 환경을 제공하고 있습니다.</p><p>솔트웨어를 통해 블록체인 기반 DID 플랫폼 서비스인 “Omnione”서비스 워크로드를 운영 &amp; 관리 할 수 있도록 AWS EKS를 도입했고, 효율적인 신원 &amp; 자격 인증 서비스 플랫폼 개발을 목표로 하고 있습니다.</p><p>이에 라온시큐어가 당면한 과제는 무엇이고 솔트웨어를 통해 어떤 솔루션을 검토 &amp; 도입하였는지 알아보겠습니다.</p><h4>당면 과제</h4><ul><li>MSA 아키텍처의 운영 &amp; 디버깅(옴니원 서비스는 여러 서비스가 접목된 Enterprise급 서비스)</li><li>효율적인 개발,디버깅 &amp; 운영을 위한 Devops문화 도입</li><li>트래픽 증가에 따른 탄력적인 소스 확장 및 축소 필요</li><li>클라우드 인프라 전담 인력 부족으로 인한 기술 내재화 필요</li></ul><h4>AWS EKS 서비스를 활용한 솔루션 예시</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MLzwz02kijJQvWDVu3EiYg.png" /></figure><h4>실제 사용한 주요 AWS 서비스</h4><ul><li><strong>Amazon Elastic Kubernetes Service</strong></li><li>Amazon Elastic Compute Cloud (EC2)</li><li>Application Load Balancer</li><li>Network Load Balancer</li><li>Auto Scaling</li><li>Amazon Managed Blockchain</li><li>Amazon Opensearch</li><li>Amazon Relational Database Service</li></ul><h4>오픈소스 솔루션</h4><ul><li>Terraform</li><li>Gitlab</li><li>Jenkins</li><li>Argocd</li><li>Prometheus</li><li>Thanos</li><li>Fluentbit</li></ul><h4>성과</h4><ul><li>애플리케이션 현대화를 위한 고가용성, 확장성, 내결함성을 보장하는 아키텍처 설계</li><li>코드형 인프라 도입으로 신규 서비스를 위한 인프라 구축 시간 절감</li><li>원클릭 배포 시스템 구축으로 빠르고 안전하게 서비스 개선</li><li>애플리케이션 모니터링 및 로깅 시스템 도입으로 장애해결 시간 단축</li><li>트래픽 증가에 따른 탄력적인 리소스 확장 및 축소를 통해서 비용 절감</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*PGasTV-xSwAwPejv.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=187764649ab4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/saltware/aws-case-study-%EB%9D%BC%EC%98%A8%EC%8B%9C%ED%81%90%EC%96%B4-187764649ab4">AWS Case Study — 라온시큐어</a> was originally published in <a href="https://medium.com/saltware">Saltware</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Case Study — 리파인]]></title>
            <link>https://medium.com/@youngwoojung/aws-case-study-%EB%A6%AC%ED%8C%8C%EC%9D%B8-d4f16a9818b6?source=rss-95bc8e3af337------2</link>
            <guid isPermaLink="false">https://medium.com/p/d4f16a9818b6</guid>
            <dc:creator><![CDATA[Young Woo Jung]]></dc:creator>
            <pubDate>Sun, 17 Mar 2024 15:31:40 GMT</pubDate>
            <atom:updated>2025-04-14T05:07:22.873Z</atom:updated>
            <content:encoded><![CDATA[<h3>AWS Case Study — 리파인</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yyH8p_HPoVlw8b20" /><figcaption>Photo by <a href="https://unsplash.com/@growtika?utm_source=medium&amp;utm_medium=referral">Growtika</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4><em>고객사 소개</em></h4><figure><img alt="http://www.refine.co.kr/" src="https://cdn-images-1.medium.com/max/400/0*0OpFInG0rVL4i3gg.png" /><figcaption><a href="http://www.refine.co.kr/">http://www.refine.co.kr</a></figcaption></figure><p><a href="http://www.refine.co.kr/main.php">리파인</a>은 금융환경 변화에 따른 부동산, 금융, 리스크 관리 서비스를 제공하기 위해 2000년도에 한국 감정원에서 부동산벤처로 기획 및 설립된 기업입니다. 금융기관 및 공공기관 등에서 부동산 거래, 담보 대출, 전월세 대출 등을 진행하기 전에 권리를 조사하고, 하자 여부를 밝혀내는 사업을 하고 있습니다. 당사는 부동산과 금융 시장에 IT 기술을 접목한 프롭테크로써 부동산 분야의 혁신을 도모하고 있으며, 최근 네이버파이낸셜과 협업하여 주택도시보증공사(HUG)의 ‘임대보증금보증보험 가입 서비스’를 비대면으로 출시했습니다.</p><p>이에 리파인이 당면한 과제는 무엇이고 솔트웨어를 통해 어떤 솔루션을 검토 및 도입하였는지 알아보겠습니다.</p><h4>당면 과제</h4><ul><li>기존 서비스 수요 증가와 신규 서비스 개발로 인한 서버 분리 및 이전 필요</li><li>코드화된 인프라 구축으로 인한 이력 및 이슈 관리 필요</li><li>모니터링, 부하 테스트, 비용 측정 등 매니지먼트 툴 부재</li><li>완전히 자동화된 빌드 및 배포(CI/CD) 시스템 부재</li><li>오토 스케일링 및 롤링 업데이트 등 유연하고 중단 없는 서비스로의 개선 필요</li></ul><p>이에 솔트웨어는 AWS EKS 컨설팅과 기술지원으로 표준화된(정형화된 블럭 방식) 인프라 구축을 통해서 모듈화(세분화) 기반으로 고객사의 당면 과제를 해결했습니다.</p><h4>세부 구성 내역</h4><ol><li>특정 클라우드 벤더에 귀속되지 않으면서 멀티(또는 하이브리드) 클라우드 구축이 가능한 Terraform을 통해서 코드형 인프라 구축</li><li>Terraform을 통해서 생성되는 리소스들을 비슷한 유형 혹은 패턴끼리 묶어서 Module을 생성하고, 해당 Module을 재사용함으로써 표준화된 인프라 구축</li><li>AWS 리소스 뿐만 아니라 오픈소스 솔루션 설치 및 구성, 애플리케이션 배포 파이프라인까지 모두 코드형 인프라에 포함</li><li>수동으로 생성된 리소스들을 코드형 인프라로 재구축</li><li>수동으로 실행되던 배포 프로세스를 자동화로 변경</li><li>각각의 마이크로 서비스별로 생성된 애플리케이션 구동 파일을 템플릿 형식으로 표준화</li><li>내부 인력을 통해서 구축 및 운영되면 데이터베이스 서버를 SaaS 방식으로 이전</li><li>애플리케이션 코드 및 설정파일에 하드코딩 되어 있던 암호 정보를 오픈소스 암호 관리 서비스인 Vault로 이전</li><li>오픈소스 모니터링 스택인 Prometheus, Alertmanager, Grafana, Thanos를 통해 인프라 성능 분석 및 장애대응에 필요한 지표 수집</li><li>수집된 자료 기반 반영구 저장소에 보관하고 대시보드 및 알람 구성</li><li>애플리케이션 오류를 감지해 실시간으로 알람을 보내주는 오픈소스 솔루션 Sentry 구축</li></ol><h4>AWS 아키텍처</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wgrpT4mT3zdpB5lDi5PqzQ.png" /><figcaption>AWS 아키텍처</figcaption></figure><h4>실제 사용한 주요 AWS 서비스</h4><ul><li>Amazon VPC</li><li>Amazon Elastic Compute Cloud (EC2)</li><li>Amazon Elastic Kubernetes Service(EKS)</li><li>Amazon Elastic Container Registry(ECR)</li><li>Application Load Balancer</li><li>Network Load Balancer</li><li>Auto Scaling</li><li>Amazon CloudWatch</li></ul><h4>오픈소스 솔루션</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VNWx_w7YXdU_f_FQCJGYxg.png" /><figcaption>솔트웨어를 통해서 구축된 오픈소스 솔루션</figcaption></figure><h4>성과</h4><ul><li>각 서비스별 표준화된 방식의 클러스터 구성으로 과부하 최소화</li><li>범용 코드형 인프라 도구를 통한 리소스 생성 및 GitLab으로 버전 관리</li><li>각각의 글로벌 범용 오픈소스의 선도적 도입</li><li>클릭 한 번으로 실시간 운영 중인 서비스에 반영되도록 구성</li><li>고가용성, 확장성, 내결함성을 모두 충족하는 인프라 구축</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Xm_Uw4wd-1BgczYS.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d4f16a9818b6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Amazon Forecast로 코로나 바이러스 동향 예측하기]]></title>
            <link>https://medium.com/@youngwoojung/amazon-forecast%EB%A1%9C-%EC%BD%94%EB%A1%9C%EB%82%98-%EB%B0%94%EC%9D%B4%EB%9F%AC%EC%8A%A4-%EB%8F%99%ED%96%A5-%EC%98%88%EC%B8%A1%ED%95%98%EA%B8%B0-ddcf0c6de86b?source=rss-95bc8e3af337------2</link>
            <guid isPermaLink="false">https://medium.com/p/ddcf0c6de86b</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[covid19]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[forecasting]]></category>
            <dc:creator><![CDATA[Young Woo Jung]]></dc:creator>
            <pubDate>Sun, 12 Apr 2020 09:27:24 GMT</pubDate>
            <atom:updated>2020-04-12T11:27:01.950Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vTB_oNmBRHn3DzGq" /><figcaption>Photo by <a href="https://unsplash.com/@markusspiske?utm_source=medium&amp;utm_medium=referral">Markus Spiske</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>우선 지금 이 시간에도 코로나 바이러스와 치열한 사투를 벌이고 계신 의료진, 구급대원, 자원봉사자, 공무원분들 및 사회적 거리두기로 코로나 극복에 일조를 하고 계시는 모든분들 응원합니다!</p><p>지난 re:Invent 2018 에서 Amazon Web Services(AWS)는 Amazon.com에 사용되는 기계학습 기술을 기반으로 한 시계열 예측 서비스인 Amazon Forecast를 발표했고, 작년 8월부터 정식서비스를 시작했습니다.</p><p>여기서 시계열 예측이란 (Time Series Forecasting) “과거의 데이터와 현재의 값을 기반으로 미래의 값”을 예측하는 것입니다. 예를 들자면 쿠팡 같은 이커머스(E-Commerce) 업체들은 물류 효율성을 극대화 하기 위해서 판매하는 <strong>상품</strong>들에 대한 미래 수요 예측을 해서 적당량의 <strong>재고</strong>를 물류창고에 확보를 하고 상품을 배송할 <strong>직원</strong>을 채용해야 할것입니다.</p><p>이 뿐만 아니라 저희들도 일상생활에서 시계열 예측을 하고 있습니다. 뇌라는 슈퍼컴퓨터가 기억속에 저장되어 있는 과거의 경험들을 기반으로 미래의 사건을 예측하곤 합니다. 예를 들자면 영수라는 친구를 10년동안 알고 지냈는데 이 친구가 항상 약속시간보다 10분 늦게 왔다면 저희는 이 친구가 다음 약속에서도 10분 늦게 올거라고 높은 <strong>확률</strong>로<strong> </strong>예측할수 있을 것 입니다. 또는 새로 사귄 친구가 이 친구랑 비슷한 <strong>성격</strong>을 가지고 있다면 이 친구 역시 약속에 늦을 확률이 높다고 볼수 있을 겁니다.</p><p>이번 포스팅에서는 전국 지역별(특별시, 광역시, 도)로 앞으로의 코로나 발생 동향을 예측해보겠습니다</p><h3>Dataset</h3><p>미래를 예측하려면 과거 데이터가 필요합니다. Kaggle에 올라와 있는 국내 코로나 발생 현황 데이터를 이용하도록 하겠습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*iHB19pYaS-mjK3uHpag0hA.png" /><figcaption><a href="https://www.kaggle.com/kimjihoo/coronavirusdataset">https://www.kaggle.com/kimjihoo/coronavirusdataset</a></figcaption></figure><p>TimeProvince.csv 파일에서 2020년 1월 20일 부터 2020년 4월 7일까지 전국 지역별 누적 확진자, 완치자, 사망자 수치에 대한 일별 데이터를 확인할수 있습니다. 신규 확진자에 대한 예측 모델을 생성할 예정이라서 데이터 전처리 과정을 통해서 데이터를 누적 확진자 수치가 아닌 신규 확진자 수치로 변경하였습니다. 또한 해당 데이터에는 입국<strong>검역</strong>을 통한 확진자 수치를 포함하고 있지 않습니다. 2020년 4월 7일 기준 누적확진자 총합은 10,331명이지만 검역을 통한 확진자 324명에 대한 데이터를 제외한 총 10,007명의 확진자 데이터만 해당 데이터셋에 포함하고 있습니다. 실제 Training에 사용된 데이터는 해당 <a href="https://github.com/youngwjung/covid-forecast/blob/master/TimeProvince.csv">Git Repository</a>에서 확인 가능합니다.</p><h3>예측 모델 생성하기</h3><p>우선 Dataset group를 생성해야 하는데요. Dataset group이란 예측 모델 학습에 필요한 Datasets, 학습된 예측 모델인 Preditors, 예측 모델이 배포되어 예측 Query를 실행하는 Forecasts가 구성되는 하나의 논리적 그룹이라고 생각하시면 될거 같습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/761/1*rsnv6wGC0kFxJdyy_LG6_Q.png" /></figure><p>Dataset group를 생성할때 Forecasting domain을 지정해주어야 합니다. Forecasting domain에는 예측 모델의 주요 사용 사례들인 <strong>소매 수요</strong>, <strong>재고</strong>, <strong>EC2 사용량</strong>, <strong>인력</strong>, <strong>웹 트래픽</strong>, <strong>지표</strong>(수익, 판매, 현금흐름)과 <strong>사용자 지정</strong> 도메인이 있습니다. 각 도메인별로 요구되는 Dataset 필드가 다르기 때문에 AWS <a href="https://docs.aws.amazon.com/ko_kr/forecast/latest/dg/howitworks-domains-ds-types.html">공식문서</a>에 명시된 각 도메인별 Dataset 필드를 확인하시고 도메인을 지정하셔야 합니다. 코로나 예측 같은 경우에는 미리 정의된 도메인들과 성격이 다르므로 사용자 지정 도메인으로 선택하겠습니다.</p><p>다음으로는 시계열 Dataset을 생성합니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*Ylop4HFCBwYz8HiMRKd6yw.png" /></figure><p>일일 코로나 현황 데이터이므로 Time Interval은 1 day로 지정하겠습니다. Data schema에는 앞에서 지정한 도메인에서 요구되는 Dataset 필드가 자동으로 들어가 있습니다. 여기서 <strong>주의</strong>하실 부분은 CSV 파일에 저장된 데이터 필드들의 순서와 Data schema에 정의된 Attribute 순서가 동일해야 합니다. 위의 예로 들자면 CSV 파일이 아래와 같아야 합니다</p><pre>timestamps,item_id,target_value<br>2020-01-20,Seoul,0<br>...<br>...<br>2002-04-07,Seoul,</pre><p>다음으로는 학습에 사용할 테이터를 Dataset으로 불러오는 작업입니다</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/1*KG2Z8ufs4f3aYb7DGinfpQ.png" /></figure><p>Timestamp format에 불러올 데이터의 <strong>timestamp </strong>필드에 정의된 포맷을 넣어줍니다. S3 버킷을 생성하거나 기존의 생성된 버킷에 CSV 파일을 업로드하고 Data Location에 경로를 넣어줍니다. S3에서 파일을 읽어올수 있는 권한이 필요하므로 IAM Role 필드에서 Create a new role를 선택하고 CSV 파일이 저장된 버킷에 대한 권한을 부여합니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/831/1*noe4p5FlFKbTAH2WqnjGgA.png" /></figure><p>자 이제 데이터 불러오는 작업이 진행중이구요.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/845/1*1AO6QReF1ei3ERg9LETSVg.png" /></figure><p>잠시만 기다리면 작업이 완료됩니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9vZdYVQ5WLHppChyvLvkuw.png" /></figure><p>예측 모델을 생성하기 앞서 Dataset Type에 대해서 간략히 알아보겠습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*X6-1Qd_NFbsSJAssFtdR6w.png" /></figure><p>TARGET_TIME_SERIES는 예측 모델 생성에 필수적인 Dataset으로서 처음에 Dataset group을 생성할때 만든 Dataset이 바로 TARGET_TIME_SERIES Dataset입니다. 이 Dataset에서는 예측할 아이템 값의 시계열 데이터가 포함되어야 합니다. 예로 스타벅스 각 지점별 일일 커피 판매량 또는 일일 특정 커피 판매량를 예측 한다고 하면 아래와 같은 데이터가 TARGET_TIME_SERIES로 필요할 것입니다.</p><pre>timestamp, branch_id, item_id, amount_sold</pre><p>ITEM_METADATA에는 예측할 아이템의 특성에 대한 정보가 포함되어야 합니다. 위의 스타벅스의 예로 말한다면 특정 커피의 카페인 함유 유/무, 우유 함유 유/무, 원두 원산지, 핫/아이스 등이 될수 있을거 같습니다. 여기서 유의할 점은 ITEM_METADATA의 필드 값은 문자열만 허용하고, Deep AR+ 알고리즘으로 예측 모델을 생성할때면 ITEM_METADATA Dataset이 모델 학습에 이용됩니다. 이 부분에 대한 자세한 내용을 알고리즘 소개할때 알아보겠습니다.</p><p>RELATED_TIME_SERIES에는 TARGET_TIME_SERIES에서 명시한 아이템에 관련된 다른 시계열 데이터가 포함되어야 합니다. 위의 스타벅스의 예로 말한다면 아래의 데이터와 같은 각 아이템별 가격이나 프로모션 유/무가 될수 있겠네요.</p><pre>timestamp, item_id, price, promotion</pre><p>자 이제 불러온 Dataset으로 예측 모델을 만들어 보도록 하겠습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/1*PevDg_ImwYGEwRwgVMyRPQ.png" /></figure><p>Forecast horizon에는 Dataset에 있는 가장 최근 날짜를 기준으로 얼마나 먼 미래의 값을 예측하고 싶은지를 정합니다. 저는 7일로 설정했는데요. 이말인 즉슨 현재 불러온 Dataset에 2020년 4월 7일까지의 데이터가 있으니 생성된 예측 모델로 4월 8일부터 4월 14일까지의 값을 예측할수 있습니다.</p><p>Forecast frequency에는 얼마 주기로 예측을 할건지를 정합니다. 저는 일별 코로나 확진자수를 예측할거니까 1 day로 설정했습니다. 만약 주별 확진자수를 예측하려고 한다면 week으로 지정하면 됩니다. Forecast frequency 값은 Dataset에 있는 timestamp 간격보다 크게 설정할수는 있지만 더 작게 설정할수는 없습니다. 예를 들자면 Dataset의 timestamp 간격이 1 hour라면 Forecast frequency 값을 day, week, month로 지정할수 있지만, timestamp 간격이 1 week이라면 Forecast frequency 값을 hour, day로 지정할수 없습니다.</p><p>Algorithm selection에서는 Training에 사용할 알고리즘을 정할수 있습니다. 해당 <a href="https://docs.aws.amazon.com/forecast/latest/dg/aws-forecast-choosing-recipes.html">문서</a>를 참고해서 특정 알고리즘을 선택하거나 AutoML 옵션을 이용해서 모든 알고리즘을 사용해서 Training하고 그중에서 가장 높은 정확도를 가진 모델을 선택하는 방법도 있습니다. AutoML을 사용할 경우에는 더 많은 Training이 필요하므로 시간이 더 걸리고 과금도 더 되는데요. 맨 처음에 어떤 알골리즘을 사용해야 할지 모를때는 유용하게 쓰일수 있을거 같습니다.</p><p>Forecast dimension에는 item_id별 예측 이외에 다른 필드별 예측을 하고 싶다면 Dataset에 명시된 필드값을 지정할수 있습니다. 예를 들어서 아래와 같은 TARGET_TIME_SERIES 데이터가 있다고 가정할때, 기본적으로 각 item_id별 수요가 예측될거고, Forecast dimension에 bracnh_id를 추가한다면 각 브랜치별 수요도 같이 예측할수 있습니다</p><pre>timestamp, branch_id, item_id, amount_sold</pre><p>Country for holidays에는 특정 국가의 공휴일에 대한 데이터를 예측 모델에 적용할지를 묻고 있는데요. 코로나는 공휴일도 피해가지 않으니 저는 추가하지 않겠습니다.</p><p>Backest windows offset은..말로 설명하기 쉽지 않네요. 우선 아래 그림을 보시죠</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/0*SaQ-rUbEL99MvjDk.png" /></figure><p>1월 1일부터 1월 31일 까지의 데이터가 있다고 가정하겠습니다. Backtest windows offset은 얼마 만큼의 데이터를 Evaluation set으로 가져갈건지를 정합니다. Backtest windows offset 값을 7이라고 한다면 1월 1일부터 1월 24일까지의 데이터를 Training set으로 하고 1월 25일부터 1월 31일까지의 데이터를 Evaluation set으로 나눠서 예측 모델에 대한 정확도를 측정합니다. Backtes windows offset값은 Forecast horizon 값보다 작을수 없습니다.</p><p>Number of backtest windows도.. 아래 그림을 보시죠</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/761/0*VmzLrf3613MOy8rh.png" /></figure><p>다시 1월 1일부터 1월 31일 까지의 데이터가 있다고 가정하고, Number of backtest windows를 4로, Backtest windows offset를 5로 하고 예측 모델을 생성한다면 아래와 같이 Dataset를 총 4개로 나눠서 예측 모델을 Training 합니다.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d1a433f6f380db9b6b852083ed6c488a/href">https://medium.com/media/d1a433f6f380db9b6b852083ed6c488a/href</a></iframe><p>그럼 예측 모델을 생성하겠습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kgDZh4YC_QqZ3Y1O2oxwjQ.png" /></figure><p>생성이 완료 됐습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UaIZE8z0EmdcWAY7gHgibQ.png" /></figure><p>이제 생성된 예측 모델을 배포하겠습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/727/1*mQPK-8Q0lmcwEBgcoPhEIA.png" /></figure><p>Predictor에 배포할 예측 모델을 지정합니다. Forecast types은 우선 비워두고 Default 값인 .10, .50, .90 quantiles로 예측결과를 받아보겠습니다. 이 부분도.. 설명하기 힘들네요. 나중에 Query 결과를 통해서 알아보겠습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DfAhhi7x8k6g_vnVqx9vVQ.png" /></figure><p>배포가 완료되고 Query를 실행해 보겠습니다</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GYTmv6znSwFNf_pxIj2toQ.png" /></figure><p>2020년 4월 8일부터 4월 12일까지 서울의 확진자 수를 예측해보겠습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5lpdHauindLHxqG_3sH5Xw.png" /></figure><p>Forecast 결과 값은 Probability Distribution를 기반으로 확율 예측 값입니다. 우선 P10, P50, P90 값들에 대해서 설명드리자면, P10는 10%의 확율로 실제값이 P10값 보다 작을수 있음을 의미하고, P50는 50%의 확율로 실제값이 P50값 보다 크거나 작을수 있음을 의미하고, P90는 90%의 확률로 실제값이 P90값 크지 않다는 것을 의미합니다.</p><p>그럼 여기서 P50에 의문이 들수도 있는데요. 왜냐하면 얼핏 보기에는 50/50 이기 때문에 무작위 예측과 무엇이 다를수 있냐라고 보일수도 있지만 실제는 다릅니다. 예측할수 있는 값이 True/False 처럼 딱 2개라면 50%의 확률은 크게 의미가 없지만 예측 가능한 값이 무한대에 가깝다면 50%의 확률로 예측하는것이 결코 나쁜 수치는 아닙니다.</p><p>그럼 이 P50값과 실제 확진자수를 비교해 보겠습니다.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/84380dafbc5e7ffbbf55f36c5d2fcde2/href">https://medium.com/media/84380dafbc5e7ffbbf55f36c5d2fcde2/href</a></iframe><p>실제값 괄호안에 첫번째 값은 지역발생이고 두번째 값은 해외유입입니다. 지역발생만 기준으로 본다면 나쁘지 않은 예측이 되었다고 볼수도 있겠네요. 사실 과거 확진자 발생 현황만으로 앞으로 발생할 확진자를 예측하는게 쉽지는 않습니다. 왜냐하면 수많은 변수들이 있을수 있고 아직 코로나 바이러스 감염에 끼치는 영향도 명확히 밝혀지지 않았으니까요. 이번 예측은 그냥 재미로 한번 해봤다고 생각해 주시면 될거 같습니다</p><h3><strong>Conclusion</strong></h3><p>이번 포스팅에 주된 목적은 Amazon Forecast에 대한 기본적인 사용법에 대해서 안내하는거였습니다. 다른 편에서는 Amazon Forecast에서 지원하는 알고리즘, 생성된 예측 모델의 지표값들 그리고 Probability Distribution에 대해서 알아보겠습니다.</p><p>참고로 저는 데이터 사이언티스트도 머신러닝 전문가도 아닌 그냥 평범한 개발자입니다. 혹시 이번 포스팅에서 잘못된 정보를 있으면 <strong>꼭</strong> 댓글 부탁드립니다.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ddcf0c6de86b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Lambda에 X-Ray 적용하기]]></title>
            <link>https://medium.com/saltware/aws-lambda%EC%97%90-x-ray-%EC%A0%81%EC%9A%A9%ED%95%98%EA%B8%B0-450251b8497c?source=rss-95bc8e3af337------2</link>
            <guid isPermaLink="false">https://medium.com/p/450251b8497c</guid>
            <category><![CDATA[amazon-web-services]]></category>
            <category><![CDATA[tracing]]></category>
            <category><![CDATA[aws-x-ray]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Young Woo Jung]]></dc:creator>
            <pubDate>Wed, 25 Mar 2020 12:01:31 GMT</pubDate>
            <atom:updated>2020-03-25T12:01:31.441Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kLZH-kwmwp4NLxkQ" /><figcaption>Photo by <a href="https://unsplash.com/@socalcaral?utm_source=medium&amp;utm_medium=referral">Cara Shelton</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>AWS Lambda는 서버없이(Serverless) 어플리케이션 코드를 실행할수 있어서 Microservice Architecture을 구성하거나, AWS의 여러 서비스들과 연계해서 Event-driven Architecture를 구현할때 많이 사용되는데요.</p><p>아주 간단한 코드라면 Lambda 로그를 통해서 에러를 디버깅하거나 Performance를 확인할수 있지만 코드가 복잡해 지거나 Step Fuction을 통해서 여러개의 Lambda function이 동시다발적으로 실행된다면 디버깅이 쉽지 않을수도 있습니다. 이때 AWS X-Ray를 활용하면 좀 더 쉽게 Lambda에서 실행되는 코드를 Tracing 할수 있습니다.</p><p>API Gateway + Lambda + DynamoDB로 DynamoDB 테이블을 스캔하는 API를 만들고 각 구간별 실행시간을 X-Ray로 확인하는 방법에 대해서 알아보겠습니다.</p><p>우선 DynamoDB 테이블을 생성합니다</p><ol><li>AWS Management Console에서 좌측 상단에 있는 [<strong>Services</strong>] 를 선택하고 검색창에서 DynamoDB를 검색하거나 [<strong>Database</strong>] 밑에 있는 [<strong>DynamoDB</strong>] 를 선택</li><li>DynamoDB Dashboard에서 [<strong>Create table</strong>] 클릭 → <strong>Table name</strong> = x-ray-demo, <strong>Primary key</strong> = id, <strong>Use default settings</strong> = ✅ → [<strong>Create</strong>]</li><li>[<strong>Create item</strong>]으로 몇개의 아이템을 생성합니다.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/326/1*LWeMHqQ19jNsDztE95k_sg.png" /></figure><p>다음으로는 Lambda function을 생성하겠습니다.</p><ol><li>AWS Management Console에서 좌측 상단에 있는 [<strong>Services</strong>] 를 선택하고 검색창에서 Lambda를 검색하거나 [<strong>Compute</strong>] 밑에 있는 [<strong>Lambda</strong>를] 를 선택</li><li>Lambda Dashboard에서 [<strong>Create function</strong>] 클릭 → <strong>Function name</strong> = x-ray-demo, <strong>Runtime</strong> = Node.js 12.x → [<strong>Create function</strong>]</li><li>좌측 하단에 있는 [<strong>Execution role</strong>] 에서 <strong>View the x-ray-demo-role-xxxx on the IAM console</strong> 를 선택하고 위에서 생성한 DynamoDB에 대한 읽기 권한을 부여</li><li>아래 코드블록을 Fuction Code에 복사 후 [<strong>Save</strong>] 클릭</li></ol><pre>const AWS = require(&#39;aws-sdk&#39;)</pre><pre>exports.handler =  function(event, context, callback) {</pre><pre>const dynamodb = new AWS.DynamoDB()<br>    var params = {<br>        TableName: &#39;x-ray-demo&#39;<br>    }    <br>    var body<br>    dynamodb.scan(params, function(err, data) {<br>        <br>        if (err) {<br>            console.log(&quot;error&quot;)<br>            console.log(err, err.stack)<br>            callback(err)<br>        } else {<br>            const response = {<br>                statusCode: 200,<br>                body: JSON.stringify(data.Items)<br>            }<br>            callback(null, response)<br>        }<br>    })<br>}</pre><p>생성된 Lambda Function을 API Gateway와 연동하겠습니다.</p><p>[<strong>Designer</strong>] 탭에서 [➕ <strong>Add Trigger</strong>] 클릭 → <strong>Select a trigger</strong> = API Gateway, <strong>API</strong> = Create an API, <strong>API type</strong> = REST API, <strong>Security</strong> = Open → [<strong>Add</strong>]</p><p>생성된 API endpoint를 클릭하면 아래와 같이 DynamoDB 테이블의 레코드가 표시됩니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*ETrls6CdbCFg5Or7d5XWew.png" /></figure><p>이제 X-Ray tracing을 켜보겠습니다. Lambda 설정창에서 Active tracing을 활성화하고 [<strong>Save</strong>]</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/541/1*tYvfiJeYNNbQ2e8bRIGgoQ.png" /></figure><p>API Endpoint로 여러번 접속한 다음에 [<strong>View traces in X-Ray</strong>]를 통해서 X-Ray Dashboard로 이동해서 Service Map하고 Traces를 확인합니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*3QISXLA8zjiNjd0ei74ZBQ.png" /><figcaption>Service map</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9TYNDFJ-cNSY-35iwFNs8Q.png" /><figcaption>Trace</figcaption></figure><p>음.. DynamoDB에 대한 정보는 따로 보여지지 않습니다. Lambda에서 기본적으로 제공하는 X-Ray Tracing은 해당 Lambda에 대한 정보만 보여지므로 소스코드에 X-Ray Tracing 부분을 설정해줘야 합니다.</p><p>AWS X-Ray SDK for Node.js가 필요한데요. Lambda Layer를 통해서 구현하겠습니다.</p><ol><li>Lambda Dashboard에서 <strong>Layers</strong> 클릭 → [<strong>Create layer</strong>] → <strong>Name</strong> = nodejs-xray-sdk, 🔘 <strong>Upload a file from Amazon S3</strong>, <strong>Amazon S3 link URL</strong> = https://saltware-aws-lab.s3.ap-northeast-2.amazonaws.com/msa/node-xray-sdk.zip <strong>Compatible runtimes</strong> = Node.js 10.x, Node.js 12.x → [<strong>Create</strong>]</li><li>위에서 생성한 Lambda function으로 가서 <strong>Layers</strong> 선택 → [<strong>Add a layer</strong>] → <strong>Name</strong> = nodejs-xray-sdk, Version =1 → [<strong>Add</strong>]</li><li>Lambda 소스 코드를 아래와 같이 수정하고 [<strong>Save</strong>]</li></ol><pre>const AWSXRay = require(&#39;aws-xray-sdk&#39;);<br>const AWS = AWSXRay.captureAWS(require(&#39;aws-sdk&#39;));<br><br>exports.handler = function(event, context, callback) {<br>...<br>...</pre><p>node-xray-sdk.zip 파일은 아래와 같은 방식으로 생성할수 있습니다.</p><pre>mkdir nodejs<br>cd nodejs<br>npm install aws-xray-sdk<br>zip node-xray-sdk.zip ../nodejs -r</pre><p>이제 API Endpoint를 몇번 호출하고 X-Ray Dashboard로 가서 변경된 사항을 확인해봅니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WfuQrf3QN3oWw1Kd5DLkdQ.png" /></figure><p>이번에는 DynamoDB 부분에 대한 내용도 상세하게 확인할수 있습니다. 만약에 MySQL 데이터베이스를 사용한다면 아래와 같이 mysql 클라이언트를 정의하고 DB에 연결할경우에 Query에 대한 Tracing도 가능합니다.</p><pre>const mysql = AWSXRay.captureMySQL(require(&#39;mysql&#39;))</pre><p>해당 포스팅은 Node.js 기준으로 생성됬지만 AWS X-Ray는 Java, Python등 다른 언어도 지원합니다. Lambda 뿐만 아니라 일반적인 어플리케이션에서 적용 가능하니 AWS를 이용해서 개발하신다면 한번씩 사용해 보세요.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=450251b8497c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/saltware/aws-lambda%EC%97%90-x-ray-%EC%A0%81%EC%9A%A9%ED%95%98%EA%B8%B0-450251b8497c">AWS Lambda에 X-Ray 적용하기</a> was originally published in <a href="https://medium.com/saltware">Saltware</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CloudWatch Events로 특정 AWS API 모니터링하기]]></title>
            <link>https://medium.com/saltware/cloudwatch-events%EB%A1%9C-%ED%8A%B9%EC%A0%95-aws-api-%EB%AA%A8%EB%8B%88%ED%84%B0%EB%A7%81%ED%95%98%EA%B8%B0-e660212e8ca5?source=rss-95bc8e3af337------2</link>
            <guid isPermaLink="false">https://medium.com/p/e660212e8ca5</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloudwatch]]></category>
            <category><![CDATA[cloudtrail]]></category>
            <category><![CDATA[amazon-web-services]]></category>
            <category><![CDATA[event-driven-systems]]></category>
            <dc:creator><![CDATA[Young Woo Jung]]></dc:creator>
            <pubDate>Wed, 25 Mar 2020 05:53:43 GMT</pubDate>
            <atom:updated>2020-03-25T05:53:43.096Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*T21002_Bqb4P5wy2" /><figcaption>Photo by <a href="https://unsplash.com/@markusspiske?utm_source=medium&amp;utm_medium=referral">Markus Spiske</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>AWS CloudTrail는 AWS 계정 내에서 수행된 작업들의 API 로그를 기록하고 저장해서 “누가”, “언제&quot;, “어떤&quot; 작업을 했는지 확인하고 수집된 로그들을 토대로 보안 분석, 운영 감사, 규정 위반 감사, 비정상적 활동 탐지등을 손쉽게 할수 있는 서비스입니다.</p><p>뿐만 아니라 CloudWatch Events와의 연동을 통해서 Trail에 저장되는 API 이벤트 로그를 실시간으로 탐지후 특정 API가 호출될 경우에 AWS SNS를 통해서 알람을 보낸다거나 AWS Lambda를 통해서 미리 짜여진 작업을 실행시킬수도 있습니다.</p><p>이번 포스팅에서는 몇가지 사례를 통해서 AWS API를 실시간으로 모니터링 하는 방법에 대해서 알아보겠습니다.</p><p>우선 CloudTrail을 생성합니다</p><ol><li>AWS Management Console에서 좌측 상단에 있는 [<strong>Services</strong>] 를 선택하고 검색창에서 CloudTrail를 검색하거나 [<strong>Management &amp; Governance</strong>] 밑에 있는 [<strong>CloudTrail</strong>] 를 선택</li><li>[<strong>Create trail</strong>] → <strong>Trail name</strong> = 지정할 이름 입력, <strong>S3 Bucket</strong> = Trail를 저정한 S3 Bucket 지정→ [<strong>Create</strong>]</li></ol><p>첫번째로 적용할 내용은 CloudTrail Logging이 정지될 경우 다시 자동으로 Logging 활성화하는 로직입니다. Logging이 비활성화될 경우 Trail이 S3로 저장되지 않습니다. 제가 해커라면 우선 Trail Logging을 끄겠죠? 흔적을 남기지 않기 위해서..</p><p>Lambda Function 생성</p><ol><li>AWS Management Console에서 좌측 상단에 있는 [<strong>Services</strong>] 를 선택하고 검색창에서 Lambda를 검색하거나 [<strong>Compute</strong>] 밑에 있는 [<strong>Lambda</strong>] 를 선택</li><li>Lambda Dashboard에서 [<strong>Create function</strong>] 클릭후, <strong>Function name</strong> = enable_trail, <strong>Runtime</strong> = Python 3.8, [<strong>Create function</strong>] 클릭</li><li>좌측 하단에 있는 [Execution role] 에서 <strong>View the enable_trail-role-xxxx</strong> on the IAM console 를 선택</li><li>[<strong>Permissions</strong>] 섹션 오른쪽에 있는 [➕ <strong>Add inline policy</strong>] 클릭후, <strong>Service</strong> = CloudTrail, <strong>Actions</strong> = StartLogging, Resources 탭에 있는 [<strong>Add ARN</strong>] 클릭 → <strong>Region</strong> = ap-northeast-2, <strong>Trail name</strong> = 위에서 생성한 Trail 이름 입력 → [<strong>Add</strong>]</li><li>[<strong>Review Policy</strong>] → <strong>Name</strong> = allow-lambda-start-trail-logging → [<strong>Create Policy</strong>]</li><li>아래 코드블록을 Lambda에 복사 후, [<strong>Save</strong>] 클릭</li></ol><pre>import json<br>import boto3</pre><pre>def lambda_handler(event, context):<br>    trail_name = event[&#39;detail&#39;][&#39;requestParameters&#39;][&#39;name&#39;]<br>    <br>    client = boto3.client(&#39;cloudtrail&#39;)<br>    <br>    response = client.start_logging(<br>        Name=trail_name<br>    )</pre><p>CloudWatch Events Rule 생성</p><ol><li>AWS Management Console에서 좌측 상단에 있는 [<strong>Services</strong>] 를 선택하고 검색창에서 CloudWatch를 검색하거나 [<strong>Management &amp; Governance</strong>] 밑에 있는 [<strong>CloudWatch</strong>] 를 선택</li><li>CloudWatch Dashboard에서 [<strong>Events</strong>] 섹션 아래에 있는 [<strong>Rules</strong>] → [<strong>Create rule</strong>]</li><li>왼쪽 Event Source에서 🔘 Event Pattern 선택 , <strong>Service Name</strong> = CloudTrail, <strong>Event Type</strong> = AWS API Call via CloudTrail, 🔘 <strong>Specific operation(s)</strong>= StopLogging</li><li>오른쪽 Targets에서 [➕ <strong>Add target</strong>] → <strong>Lambda function</strong> → <strong>Function</strong> = enable_trail → [<strong>Configure details</strong>]</li><li><strong>Name</strong> = enable_trail, <strong>State</strong> = ✅ Enabled → [<strong>Create rule</strong>]</li></ol><p>CloudTrail dashboard로 이동해서 Trail Logging은 비활성화 합니다. 몇초후에 페이지를 다시 불러오면 Trail Logging이 활성화 되 있는것을 확인할수 있습니다.</p><p>다음으로는 EC2 인스턴스가 시작, 정지, 종료될때 SNS를 통해서 알림을 받아보겠습니다. AWS를 사용하다 보면 종종 갑자기 못 보던 인스턴스가 생성되어 있거나 실행중이던 인스턴스가 정지되어 있어서 흠칫할때가 있는데요. 실시간으로 알림을 받아보면 좋겠죠?</p><p>SNS 토픽생성</p><ol><li>AWS Management Console에서 좌측 상단에 있는 [<strong>Services</strong>] 를 선택하고 검색창에서 SNS를 검색하거나 [<strong>Application Integration</strong>] 밑에 있는 [<strong>Simple Notification Service</strong>] 를 선택</li><li>왼쪽 패널에서 <strong>Topics</strong> 선택 → [<strong>Create topic</strong>] → <strong>Name</strong> = 토픽 이름 입력 → [<strong>Create topic</strong>]</li><li>[<strong>Create subscription</strong>] → <strong>Protocol</strong> = Email, <strong>Endpoint</strong> = 알림 받을 이메일 주소 입력 → [<strong>Create subscription</strong>]</li><li>위에서 입력한 이메일로 전송된 인증메일에서 <strong>Confirm subscription</strong> 클릭</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*d_i_cJEuAcY0mGv_RNL8fA.png" /></figure><p>CloudWatch Events Rule 생성</p><ol><li><strong>Service Name</strong> = EC2, <strong>Event Type</strong> = EC2 Instance State-change Notification, 🔘 <strong>Specific state(s)</strong>= running, stopped, terminated</li><li>오른쪽 Targets에서 [➕ <strong>Add target</strong>] → <strong>SNS topic </strong>→ <strong>Topic</strong> = 위에서 생성한 토픽 이름 → [<strong>Configure details</strong>]</li><li><strong>Name</strong> = ec2_state_change, <strong>State</strong> = ✅ Enabled → [<strong>Create rule</strong>]</li></ol><p>이제 EC2 인스턴스를 한개 생성해보겠습니다. 생성 완료후에 SNS topic에 등록한 이메일로 아래와 같은 내용의 알림이 수신됬음을 확인할수 있습니다.</p><pre>{<br>   &quot;version&quot;:&quot;0&quot;,<br>   &quot;id&quot;:&quot;6da1e8c2-bbae-8877-f185-6c7bc6d9dcad&quot;,<br>   &quot;detail-type&quot;:&quot;EC2 Instance State-change Notification&quot;,<br>   &quot;source&quot;:&quot;aws.ec2&quot;,<br>   &quot;account&quot;:&quot;1234567890&quot;,<br>   &quot;time&quot;:&quot;2020-03-25T05:42:48Z&quot;,<br>   &quot;region&quot;:&quot;ap-northeast-2&quot;,<br>   &quot;resources&quot;:[<br>      &quot;arn:aws:ec2:ap-northeast-2:1234567890:instance/i-05e8fb4ee552d3511&quot;<br>   ],<br>   &quot;detail&quot;:{<br>      &quot;instance-id&quot;:&quot;i-05e8fb4ee552d3511&quot;,<br>      &quot;state&quot;:&quot;running&quot;<br>   }<br>}</pre><p>이메일 말고도 Slack과 연동해서 특정 이벤트에 대한 내용을 실시간으로 받아 볼수도 있습니다. 관련 내용은 해당 <a href="https://github.com/fitcloud/aws-root-account-best-practice#root-%EC%9C%A0%EC%A0%80-%EB%A1%9C%EA%B7%B8%EC%9D%B8-slack-%EC%95%8C%EB%9E%8C-%EC%84%A4%EC%A0%95">링크</a>에서 확인할수 있습니다.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e660212e8ca5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/saltware/cloudwatch-events%EB%A1%9C-%ED%8A%B9%EC%A0%95-aws-api-%EB%AA%A8%EB%8B%88%ED%84%B0%EB%A7%81%ED%95%98%EA%B8%B0-e660212e8ca5">CloudWatch Events로 특정 AWS API 모니터링하기</a> was originally published in <a href="https://medium.com/saltware">Saltware</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Openswan으로 AWS Site-to-Site VPN 구축하기]]></title>
            <link>https://medium.com/saltware/openswan%EC%9C%BC%EB%A1%9C-aws-site-to-site-vpn-%EA%B5%AC%EC%B6%95%ED%95%98%EA%B8%B0-9220a506acb3?source=rss-95bc8e3af337------2</link>
            <guid isPermaLink="false">https://medium.com/p/9220a506acb3</guid>
            <category><![CDATA[vpn]]></category>
            <category><![CDATA[amazon-web-services]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[networking]]></category>
            <dc:creator><![CDATA[Young Woo Jung]]></dc:creator>
            <pubDate>Sun, 15 Mar 2020 05:46:05 GMT</pubDate>
            <atom:updated>2020-03-15T05:46:05.409Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PA3dwHqIOh-brJi9" /><figcaption>Photo by <a href="https://unsplash.com/@danieljerez?utm_source=medium&amp;utm_medium=referral">Daniel Jerez</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>VPN(Virtual Private Network)은 인터넷으로 연결된 두개의 다른 네트워크에 있는 호스트들 간의 통신을 암호화된 연결방식으로 전송해서 마치 동일한 네크워크에 있는것처럼 안전한 통신을 할수있게 해줍니다.</p><p>일반적으로 AWS 환경에 있는 VPC와 On-premise 데이터센터간의 통신이 필요할때 AWS Site-to-Site VPN을 이용해서 쉽고 안전하게 연결할수 있습니다. AWS Direct Connect를 이용해서 AWS Network와 On-premise 데이터센터를 물리적으로 연결하는 방법도 있지만 비용이..</p><p>이번 포스팅에서는 아래와 같은 환경을 구축해서 AWS Site-to-Site VPN 구축을 실습해 보겠습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*8c1S_o6ND0Q2_CMI7txXGw.png" /></figure><ol><li>AWS에 172.16.0.0/16 IP 대역의 VPC를 생성합니다</li><li>AWS에 10.0.0.0/16 IP 대역의 VPC를 생성하고 On-Premise 네트워크라고 가정합니다</li><li>AWS VPC에 VGW(Virtual Private Gateway)를 생성합니다</li><li>On-Premise VPC에 EC2를 생성하고 Openswan을 설치해서 Customer Gateway로 가정합니다</li><li>AWS VPC의 VGW와 On-Premise VPC의 Customer Gateway간의 Site-to-Site VPN 연결을 생성합니다</li><li>AWS Instance와 On-Premise Instance간의 Private 통신을 테스트합니다</li></ol><p>실습에 필요한 기본적인 VPC 구성과 EC2 인스턴스들은 해당 <a href="https://ap-northeast-2.console.aws.amazon.com/cloudformation/home?region=ap-northeast-2#/stacks/quickcreate?templateUrl=https%3A%2F%2Fsaltware-aws-lab.s3.ap-northeast-2.amazonaws.com%2Fvpn%2Fvpn-demo.yaml&amp;stackName=vpn-demo">링크</a>를 클릭하면 CloudFormation 스택으로 통해서 구축됩니다</p><p>우선 AWS VPC에서 VPN 구성을 해보겠습니다.</p><ol><li>AWS Management Console 에서 좌측 상단에 있는 <strong>[Services]</strong> 를 선택하고 검색창에서 VPC를 검색하거나 <strong>[Networking &amp; Content Delivery]</strong> 밑에 있는 <strong>[VPC] </strong>를 선택</li><li>좌측 패널 <em>Virtual Private Network (VPN)</em> 탭 아래 <strong>Virtual Private Gateways</strong> 클릭 → [<strong>Create Virtual Private Gateway</strong>] → <strong>Name tag</strong> = aws-vpc-vgw → <strong>ASN</strong> = Amazon default ASN → [<strong>Create Virtual Private Gateway</strong>]</li><li>생성된 Virtual Private Gateway를 선택 → <strong>Actions</strong> → <strong>Attach to VPC</strong> → <strong>VPC</strong> = aws-vpc → [<strong>Yes, Attach</strong>]</li><li>좌측 패널에서 <strong>Customer Gateways</strong> 클릭 → [<strong>Create Customer Gateway</strong>] → <strong>Name</strong> = onprem-cgw, <strong>Routing</strong> = Static, <strong>IP address</strong> = OnpremVPN 인스턴스의 Public IP 주소 입력 → [<strong>Create Customer Gateway</strong>]</li><li>좌측 패널에서 <strong>Site-to-Site VPN Connections</strong> 클릭 → [<strong>Create VPN Connection</strong>] → <strong>Name</strong> = onprem-vpn, <strong>Target Gateway Type</strong> = Virtual Private Gateway, <strong>Virtual Private Gateway</strong> = Step 2에서 생성한 VGW, <strong>Customer Gateway</strong> = Existing, <strong>Customer Gateway ID</strong> = Step 4에서 생성한 CGW, <strong>Routing Options</strong> = Static, <strong>IP Prefixes</strong> = 10.0.0.0/16 → [<strong>Create VPN Connection</strong>]</li><li>생성된 VPN Connection를 선택 → <strong>Download Configuration</strong> → <strong>Vendor</strong> = Generic, <strong>Platform</strong> = Generic, <strong>Software</strong> = Vendor Agnostic → [<strong>Download</strong>]</li></ol><p>On-Premise 환경의 Customer Gateway에 VPN 설정을 하겠습니다</p><ol><li>EC2 Dashboard에서 <em>OnpremVPN</em> 인스턴스를 선택 → <strong>Connect</strong> → <strong>Connection Method</strong> = Session Manager → [<strong>Connect</strong>]</li><li>Openswan 설치: sudo yum install openswan -y</li><li>Openswan 설정파일을 생성하고 sudo vi /etc/ipsec.d/aws.conf 아래의 내용을 넣어줍니다. <em>&lt;CUSTOMER_GATEWAY_IP_ADDRESS&gt;</em>는 OnpremVPN 인스턴스의 IP주소를 넣어줍니다. <em>&lt;TUNNEL1_IP_ADDRESS&gt;</em>와 <em>&lt;TUNNEL2_IP_ADDRESS&gt;</em>에는 위에서 다운받은 VPN Configuration 파일을 열어보면 각각의 IPSec Tunnel #1, IPSec Tunnel #2 아래 <strong>#3: Tunner Interface Configuration</strong>에 있는 <strong>Virtual Private Gateway</strong> 주소 넣어줍니다</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8b03992bf1482e03e817e2de2cb4e2a8/href">https://medium.com/media/8b03992bf1482e03e817e2de2cb4e2a8/href</a></iframe><p>4. Pre-Shared Key 설정파일을 생성하고 sudo vi /etc/ipsec.d/aws.secrets 아래의 내용을 넣어줍니다. 각각 Tunnel에 대한 Pre-Shared Key 정보는 위에서 다운받은 VPN Configuration 파일안에 <strong>#1: Internet Key Exchange Configuration </strong>에서 확인할수 있습니다.</p><pre>&lt;CUSTOMER_GATEWAY_IP&gt; &lt;TUNNEL1_IP&gt;: PSK &quot;&lt;TUNNEL1 PSK&gt;&quot;<br>&lt;CUSTOMER_GATEWAY_IP&gt; &lt;TUNNEL2_IP&gt;: PSK &quot;&lt;TUNNEL2 PSK&gt;&quot;</pre><p>예를 들어서, OnpremVPN 인스턴스의 Public IP 주소가 123.123.123.123, Tunnel 1 IP 주소가 124.124.124.124, Tunnel 1 PSK가 asdf124, Tunnel 2 IP 주소가 125.125.125.125, Tunnel 2PSK가 asdf125 라고 한다면</p><pre>123.123.123.123 124.124.124.124: PSK &quot;asdf123&quot;<br>123.123.123.123 125.125.125.125: PSK &quot;asdf125&quot;</pre><p>5. 다음과 같은 내용을 /etc/sysctl.conf에 추가해서 OnpremVPN 인스턴스의 IP Forwarding option을 활성화합니다.</p><pre>net.ipv4.ip_forward = 1</pre><p>6. EC2 Dashboard에서 OnpremVPN 인스턴스를 선택 → <strong>Actions</strong> → <strong>Networking</strong> → <strong>Change Source/Dest. Check</strong> → [<strong>Yes, Disable</strong>]</p><p>7. 변경된 사항을 적용하기 위해서 Network 서비스와 Openswan을 재시작합니다</p><pre>sudo service network restart<br>sudo service ipsec restart</pre><p>8. VPC Dashboard에서 위에서 생성한 VPN Connection을 선택하고 <strong>Tunnel Details</strong> 에서 두개의 Tunnel에 대한 <strong>Status</strong>가 UP이 되었는지 확인합니다.</p><p>이제 VPN 연결은 완료되었습니다. 하지만 Routing 설정을 해줘야 정상적인 통신이 가능합니다.</p><p>우선 On-Premise VPC에서 AWS VPC로 가는 Route를 설정합니다. 10.0.0.0/16에서 172.16.0.0/16으로 가는 트래픽을 Customer Gateway (OnpremVPN)으로 보냅니다.</p><ol><li>VPC Dashoard에서 <strong>Route Tables</strong> 클릭 → onprem-public-rt 선택 → <strong>Route</strong> → <strong>Edit routes</strong> →<strong> Add routes</strong> → <strong>Destination</strong> = 172.16.0.0/16, <strong>Target</strong> = OnpremVPN 인스턴스 ID → [<strong>Save routes</strong>]</li></ol><p>AWS VPC에서 On-Premise VPC로 가는 트래픽을 Site-to-Site VPN이 연결된 VGW로 보냅니다</p><ol><li>VPC Dashoard에서 <strong>Route Tables</strong> 클릭 → aws-public-rt 선택 → <strong>Route</strong> <strong>Propagation</strong>→ <strong>Edit route propagation</strong>→<strong> </strong>aws-vpc-vgw에 대한 Propagate 체크→ [<strong>Save</strong>]</li><li><strong>Routes</strong>에서 <strong>Destination</strong> = 10.0.0.0/16, <strong>Target</strong> = aws-vpc-vgw ID 된 Route가 자동으로 추가된걸 확인할수 있습니다.</li></ol><p>마지막으로 방화벽 설정만 해주면 되는데요.</p><p>OnpremVPN 인스턴스 Security Group에 10.0.0.0/16 (내부 네트워크) 와 172.16.0.0/16 (AWS VPC) 에서 오는 트래픽에 대한 Inbound 룰을 추가합니다.</p><p>OnpremInstance 인스턴스 Security Group에 172.16.0.0/16 (AWS VPC) 에서 오는 트래픽에 대한 Inbound 룰을 추가합니다.</p><p>AWSInstance 인스턴스 Security Group에 10.0.0.0/16(AWS VPC) 에서 오는 트래픽에 대한 Inbound 룰을 추가합니다.</p><p>이제 AWSInstance에 접속해서 OnpremInstance의 Private IP 주소 Ping을 날려봅니다. 다시 OnpremInstance에 접속해서 AWSInstance의 Private IP 주소 Ping을 날려봅니다</p><p>정상적으로 작동되는 것이 확인되면 VPN Connection, VGW, CGW를 삭제하고 실습 초기에 생성한 CloudFormation 스택을 삭제합니다.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9220a506acb3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/saltware/openswan%EC%9C%BC%EB%A1%9C-aws-site-to-site-vpn-%EA%B5%AC%EC%B6%95%ED%95%98%EA%B8%B0-9220a506acb3">Openswan으로 AWS Site-to-Site VPN 구축하기</a> was originally published in <a href="https://medium.com/saltware">Saltware</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Systems Manager와 KMS로 쉽고 안전하게 환경변수 관리하기]]></title>
            <link>https://medium.com/saltware/aws-systems-manager%EC%99%80-kms%EB%A1%9C-%EC%89%BD%EA%B3%A0-%EC%95%88%EC%A0%84%ED%95%98%EA%B2%8C-%ED%99%98%EA%B2%BD%EB%B3%80%EC%88%98-%EA%B4%80%EB%A6%AC%ED%95%98%EA%B8%B0-209047d5ab54?source=rss-95bc8e3af337------2</link>
            <guid isPermaLink="false">https://medium.com/p/209047d5ab54</guid>
            <category><![CDATA[key-management-service]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[systems-manager]]></category>
            <category><![CDATA[amazon-web-services]]></category>
            <dc:creator><![CDATA[Young Woo Jung]]></dc:creator>
            <pubDate>Thu, 12 Mar 2020 13:48:29 GMT</pubDate>
            <atom:updated>2020-03-12T14:04:05.713Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5JlYfCpTVyCzHoJY.jpeg" /></figure><p>개발을 하다 보면 Database credentails, API Key, Secret Key 같이 외부에 노출될 경우 보안적 문제가 발생할수 있는 요소들을 다루게 되는 경우가 다반사입니다.</p><p>Private Git Repository를 사용하니까 평문으로 소스코드 안에 저장해도 괜찮지 않냐라고 생각할수도 있지만, 요즘처럼 다수의 개발자들이 Shared Repository에서 작업하는 환경에서는 꼭 그렇다고 볼수는 없습니다. 통계적으로 보안사고의 90% 이상이 Human error에서 시작되기 때문에 개발자 컴퓨터에 저장된 Local Repository가 유출될 경우를 배재할수 없습니다</p><p>이 문제를 해결하기 위해서 어떤 방법들이 있을까요? 비밀정보를 암호화해서 소스코드안에 저장하고 불러올때 복호화해서 사용하는 방법이나 Secrets Management System을 구축해서 중요 정보들을 불러오게 할수 있습니다. 하지만 이 역시 암호화 키 관리 및 Secrets Management System으로 접속을 위한 정보에 대한 보안이 필요하므로 보안시스템 이용을 위한 보안이, 또 그 보안을 위한 보안.. 끝이없네요</p><p>이번 포스팅에서는 AWS System Manager Parameter Store에 MySQL 접속정보를 AWS Key Management Service (KMS)에서 생성한 Key로 암호화 해서 저장하고 애플리케이션에서 환경변수로 불러오는 방법에 대해서 알아보겠습니다. 접속 테스트할 MySQL 서버가 없으실 경우에는 RDS를 통해서 MySQL 서버를 생성해주세요.</p><p>우선 암호화에 사용할 Key를 생성하겠습니다</p><ol><li>AWS Management Console 에서 좌측 상단에 있는 <strong>[Services]</strong> 를 선택하고 검색창에서 KMS를 검색하거나 <strong>[Security, Identity, &amp; Compliance]</strong> 밑에 있는 <strong>[Key Management Service] </strong>를 선택</li><li><strong>Custom managed kyes → [Create key]</strong></li><li><strong>Key type</strong>에는 <em>Symmetric</em> (암호화와 복호화에 동일한 Key를 이용)과 <em>Asymmetric</em> (저희가 흔히 알고 있는 RSA Public/Private key pair) 있는데요. <strong>Symmetric</strong> 으로 선택하고 <strong>[Next]</strong></li><li><strong>Alias</strong>에 Key 이름을, <strong>Description</strong>에 키에 대한 정보를 입력하고 [<strong>Next</strong>]</li><li><strong>Key administrators</strong>에 해당 Key의 관리자 권한을 부여할 IAM User나 IAM Role을 지정할수 있습니다. 만약 현재 IAM User로 로그인되어 있을 경우에는 해당 IAM User를 선택하고 [<strong>Next</strong>]</li><li>해당 Key의 사용 권한을 부여할 IAM User나 IAM Role을 지정하거나 만약 다른 AWS 계정에 해당 Key의 사용권한을 부여할 경우에는 타 계정 정보를 입력할수 있습니다. 여기서는 아무것도 선택하지 않고 [<strong>Next</strong>]</li><li>리뷰화면에서 아래와 같은 Key Policy를 확인할수 있습니다.</li></ol><pre>{<br>    &quot;Id&quot;: &quot;key-consolepolicy-3&quot;,<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Sid&quot;: &quot;Enable IAM User Permissions&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Principal&quot;: {<br>                &quot;AWS&quot;: &quot;arn:aws:iam::<em>ACCOUNT_ID</em>:root&quot;<br>            },<br>            &quot;Action&quot;: &quot;kms:*&quot;,<br>            &quot;Resource&quot;: &quot;*&quot;<br>        },<br>        {<br>            &quot;Sid&quot;: &quot;Allow access for Key Administrators&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Principal&quot;: {<br>                &quot;AWS&quot;: &quot;arn:aws:iam::<em>ACCOUNT_ID</em>:user/<em>John</em>&quot;<br>            },<br>            &quot;Action&quot;: [<br>                &quot;kms:Create*&quot;,<br>                &quot;kms:Describe*&quot;,<br>                &quot;kms:Enable*&quot;,<br>                &quot;kms:List*&quot;,<br>                &quot;kms:Put*&quot;,<br>                &quot;kms:Update*&quot;,<br>                &quot;kms:Revoke*&quot;,<br>                &quot;kms:Disable*&quot;,<br>                &quot;kms:Get*&quot;,<br>                &quot;kms:Delete*&quot;,<br>                &quot;kms:TagResource&quot;,<br>                &quot;kms:UntagResource&quot;,<br>                &quot;kms:ScheduleKeyDeletion&quot;,<br>                &quot;kms:CancelKeyDeletion&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;<br>        }<br>    ]<br>}</pre><p>우선 첫번째 블록은 Default로 생성되는 구문으로 IAM Policy를 통해서 해당 Key에 대한 권한을 부여하고 접근할수 있도록 하는 구문입니다. 두번째 구문은 <em>John </em>이란 IAM 유저에게 KMS 대한 관리 권한을 주는 구문입니다. 자세히 보시면 실제로 Key를 사용하는 Encrypt, Decrypt은 빠져있니다. John 에게 부여된 IAM 정책에 두번째 구문의 권한이 부여되어 있지 않더라도 Key Policy를 통해서 권한을 부여받습니다</p><p>정리하자면 Key Policy 또는 IAM Policy 혹은 두개 다를 이용해서 KMS Key에 대한 접근관리를 할수 있습니다. 자 그럼 [<strong>Finish</strong>]을 클릭해서 Key를 생성합니다</p><p>이제 그럼 Systems Manager Parameter Store에 Paramter 들을 생성하겠습니다.</p><ol><li>AWS Management Console 에서 좌측 상단에 있는 <strong>[Services]</strong> 를 선택하고 검색창에서 Systems Manager를 검색하거나 <strong>[Management &amp; Governance]</strong> 밑에 있는 <strong>[Systems Manager] </strong>를 선택</li><li>좌측 패널 <em>Application Management</em> 탭 아래 <strong>Parameter Store</strong> 클릭 → [<strong>Create parameter</strong>]</li><li>한번에 동일한 Path에 있는 모든 파라미터를 불러올거기 때문에 Name은 Path 형식으로 작성합니다. Fakebook 이라는 서비스에 Test 환경의 DB Credentials을 저장한다고 가정하고 <strong>Name</strong>을 /FAKEBOOK/TEST/DB_URL 로 지정하겠습니다</li><li>Type은 위에서 생성한 KMS Key로 암호화 할거기 때문에 <strong>SecureString </strong>으로 선택하고 KMS Key ID를 위에서 생성한 KMS Key를 선택합니다</li><li>Value에 접속할 Database endpoint 값을 넣고 [<strong>Create parameter</strong>]</li><li>동일한 방법으로 /FAKEBOOK/TEST/DB_USER, /FAKEBOOK/TEST/DB_PASSWORD 파라미터를 생성합니다.</li><li>생성한 파라미터를 클릭해서 상세내용을 보면 <strong>Value </strong>가 ******** 로 보이지 않습니다. 옆에 Show 를 클릭하면 볼수있지만 로그인되어 있는 유저가 (1) 해당 파라미터를 볼수 있는 GetParameter 권한과 (2) 해당 파라미터를 암호화한 KMS Key의 대한 Decrypt 권한이 있어야지만 복호화를 통해서 파라미터 값을 볼수 있습니다</li></ol><p>이제 EC2를 생성해서 위에서 만든 파라미터를 불러와 보도록 하겠습니다</p><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;ssm:GetParametersByPath&quot;,<br>                &quot;ssm:GetParameter&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;arn:aws:ssm:<em>AWS_REGION</em>:<em>ACCOUNT_ID</em>:parameter/FAKEBOOK/TEST/*&quot;<br>        }<br>    ]<br>}</pre><ol><li>EC2에 부여할 IAM Role을 생성하고 위와 같은 IAM 정책을 생성하여 부여합니다</li><li>KMS Dashboard로 이동해서 앞에서 생성한 KMS Key users에 방금 만든 IAM Role을 추가합니다</li><li>EC2를 생성하고 위에서 만든 IAM Role을 부여합니다.</li><li>MySQL 서버 방화벽 설정에서 해당 EC2로의 접근을 열어줍니다</li><li>EC2에 접속해서 데모 어플리케이션을 설치합니다</li></ol><pre># Python3 및 Git 설치<br>$ sudo yum install python3 git -y</pre><pre># Demo application repository clone<br>$ git clone <a href="https://github.com/youngwjung/ssm_ps.git">https://github.com/youngwjung/ssm_ps.git</a></pre><pre># Python library 설치<br>$ sudo pip3 install -r ssm_ps/requirements.txt</pre><pre># 환경변수 설정 (AWS_REGION를 파라미터가 저장된 리전코드로 변경하세요)<br>$ export AWS_DEFAULT_REGION=<em>AWS_REGION </em>SSM_PATH=/FAKEBOOK/TEST/</pre><pre># Application 실행<br>$ cd ssm_ps &amp;&amp; python3 app.py</pre><p>성공적으로 구성됬을 경우 아래와 같은 메시지를 볼수 있습니다</p><pre>Connected to xxxxxx.xxxxxx.ap-northeast-2.rds.amazonaws.com</pre><p>데모 어플리케이션에 대해서 살펴보면 간단히 살펴보면</p><pre># ssm_ps.py</pre><pre>import boto3</pre><pre># 한개의 Parameter 불러오기<br>def get_ssmparameter(param_name):<br>    <br>    ssm = boto3.client(&#39;ssm&#39;)<br><br>    # Parameter 불러올때 복호화를 통해서 평문으로 불러오기<br>    response = ssm.get_parameters(<br>        Names=[<br>            param_name,<br>        ],<br>        WithDecryption=True<br>    )<br><br>    <br>    # Response 에서 Parameter 값 리턴<br>    if not response[&#39;InvalidParameters&#39;]:<br>        param_value = response[&#39;Parameters&#39;][0][&#39;Value&#39;]<br>    else:<br>        param_value = &#39;InvalidParameter&#39;<br><br>    return param_value<br><br># 특정 Path에 있는 모든 파라미터 불러오기<br>def get_ssmparameters_by_path(path, next_token=&#39;&#39;):<br><br>    ssm = boto3.client(&#39;ssm&#39;)<br><br>    # 한번에 10개의 파라미터를 불러올수 있어서 이전 Response에서 NextToken이 있을경우 다음 아이템 불러오기<br>    if next_token:<br>        response = ssm.get_parameters_by_path(<br>            Path=path,<br>            Recursive=True,<br>            WithDecryption=True,<br>            NextToken=next_token<br>        )<br>    else:<br>        response = ssm.get_parameters_by_path(<br>            Path=path,<br>            Recursive=True,<br>            WithDecryption=True<br>        )<br><br>    return response</pre><pre># env.py</pre><pre>import os<br>from ssm_ps import get_ssmparameters_by_path<br><br>token = &quot;&quot;</pre><pre># NextToken이 없을때까지 파라미터값을 가져오기<br>while True:<br>    response = get_ssmparameters_by_path(os.environ[&#39;SSM_PATH&#39;], token)<br><br>    for param in response[&#39;Parameters&#39;]:</pre><pre>        # 불러온 파라미터 이름에서 Prefix 제거해서 환경변수로 지정<br>        os.environ[param[&#39;Name&#39;].replace(os.environ[&#39;SSM_PATH&#39;], &#39;&#39;)] = param[&#39;Value&#39;]<br>        <br>    if &#39;NextToken&#39; in response:<br>        token=response[&#39;NextToken&#39;]<br><br>    else:<br>        break</pre><pre># app.py</pre><pre>import mysql.connector<br>import os<br></pre><pre># env.py 모듈을 통해서 Parameter Store에서 불러온 파라미터를 환경변수로 지정<br>from env import *</pre><pre>try:<br>    db = mysql.connector.connect(<br>        host = os.environ[&#39;DB_URL&#39;],<br>        user = os.environ[&#39;DB_USER&#39;],<br>        passwd = os.environ[&#39;DB_PASSWORD&#39;],<br>        connection_timeout = 5<br>    )<br>    print (f&quot;Connected to {os.environ[&#39;DB_URL&#39;]}&quot;)<br>except Exception as e: print(e)</pre><p>만약 STAG 환경의 DB 접속정보를 불러오고 싶다면 /FAKEBOOK/STAG/ Prefix 아래로 DB_URL, DB_USER, DB_PASSWORD를 저장하고, SSM_PATH 환경변수만 /FAKEBOOK/STAG로 지정하고 애플리케이션 실행시키면 소스코드의 변경없이 다양한 환경의 파라미터를 불러올수 있습니다.</p><p>이와같은 방식의 장점은 운영자의 입장에서는 소스코드의 변경없이 Secrets을 추가, 변경, 삭제할수 있고, 개발자의 입장에서는 간단히 환경변수에서 Secrets들을 불러와서 사용할수 있습니다. Application에는 어떤 암호화 Key도 평문화된 비밀정보도 저장할 필요 없이요.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=209047d5ab54" width="1" height="1" alt=""><hr><p><a href="https://medium.com/saltware/aws-systems-manager%EC%99%80-kms%EB%A1%9C-%EC%89%BD%EA%B3%A0-%EC%95%88%EC%A0%84%ED%95%98%EA%B2%8C-%ED%99%98%EA%B2%BD%EB%B3%80%EC%88%98-%EA%B4%80%EB%A6%AC%ED%95%98%EA%B8%B0-209047d5ab54">AWS Systems Manager와 KMS로 쉽고 안전하게 환경변수 관리하기</a> was originally published in <a href="https://medium.com/saltware">Saltware</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Principle of Least Privilege with IAM Policy]]></title>
            <link>https://medium.com/saltware/principle-of-least-privilege-with-iam-policy-454faa566f9b?source=rss-95bc8e3af337------2</link>
            <guid isPermaLink="false">https://medium.com/p/454faa566f9b</guid>
            <category><![CDATA[lambda]]></category>
            <category><![CDATA[amazon-web-services]]></category>
            <category><![CDATA[identity-and-access]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Young Woo Jung]]></dc:creator>
            <pubDate>Tue, 28 Jan 2020 09:11:08 GMT</pubDate>
            <atom:updated>2020-01-28T09:13:50.765Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*038bSFqss-GBDX8A" /><figcaption>Photo by <a href="https://unsplash.com/@kelli_mcclintock?utm_source=medium&amp;utm_medium=referral">Kelli McClintock</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Principle of Least Privilege, 굳이 직역하자면 최소 권한의 원칙(?)일거 같고 풀어서 말하자면 특정 임무를 수행하는 객체에 그 특정 임무를 수행하는데 꼭 필요한 최소한의 권한만 부여 및 허용하는 방법론입니다.</p><p>AWS에서는 IAM Policy에 권한을 명시하고 IAM User나 IAM Role에 IAM Policy를 부여하는 방식으로 AWS Resources에 대한 접근 제어를 할수 있습니다. 고로 IAM Policy를 어떻게 사용하느냐에 따라서 AWS 클라우드 상에서의 보안을 더욱 견고하게 할수 있는데요. 몇가지 예를 통해서 올바른 IAM Policy를 만드는법을 알아보겠습니다.</p><blockquote>Scenario 1 - 특정 IAM User에게least_privilege_principle S3 Bucket에 있는 객체들을 보고, 읽고, 지우는 권한을 부여하십시오</blockquote><p>이 경우 AWS 초심자의 경우에는 잘 몰라서, AWS를 잘 사용한다고 하는 분들은 <strong>귀찮아서</strong> AWS Managed Policy인 AmazonS3FullAccesss 권한을 부여하곤 하는데요 (사실 저도 테스트용이라는 변명과 함께 종종 사용하는 방법입니다 😝) 이 정책에 부여된 권한을 JSON 으로 본다면 아래와 같습니다</p><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: &quot;s3:*&quot;,<br>            &quot;Resource&quot;: &quot;*&quot;<br>        }<br>    ]<br>}</pre><p>해당 AWS 계정에 있는 모든 S3 Bucket에 S3 관련 모든 Action들을 취할수 있는 권한입니다. <em>least_privilege_principle </em>Bucket에 대한 권한만 필요하므로 약간의 수정을 해보겠습니다.</p><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: &quot;s3:*&quot;,<br>            &quot;Resource&quot;: [<br>                &quot;arn:aws:s3:::least_privilege_principle&quot;,<br>                &quot;arn:aws:s3:::least_privilege_principle/*&quot;<br>            ]<br>        }<br>    ]<br>}</pre><p>조금 더 나아지기는 했지만 Action 부분에 대한 수정이 필요할듯 하네요. ListBucket, GetObject, DeleteObject Action만 실행 할수있게 수정해 보겠습니다.</p><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: &quot;s3:ListBucket&quot;,<br>            &quot;Resource&quot;: &quot;arn:aws:s3:::least_privilege_principle&quot;<br>        },<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;s3:GetObject&quot;,<br>                &quot;s3:DeleteObject&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;arn:aws:s3:::least_privilege_principle/*&quot;<br>        }<br>    ]<br>}</pre><blockquote>Scenario 2 - 특정 IAM User에게<em>least_privilege_principle</em> S3 Bucket에 있는 객체들을 보고, 읽고, 지우는 권한을 부여하십시오. 단 <strong>GetObject</strong>와 <strong>DeleteObject</strong> Action은 해당 IAM 유저가 회사 네트위크에 접속한 상태에서만 실행할수 있어야 합니다.</blockquote><p>이 경우 IAM Policy 요소중에서 Condition을 이용해서 특정 IP 대역대에서 오는 요청에 대해서만 허가하는 조건을 넣을수 있습니다. 회사 네트워크 IP 대역대가 123.123.123.123/32 라고 가정을 한다면 아래와 같은 조건문을 넣어서 IP주소 기반 접근제어를 할수 있습니다.</p><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: &quot;s3:ListBucket&quot;,<br>            &quot;Resource&quot;: &quot;arn:aws:s3:::least_privilege_principle&quot;<br>        },<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;s3:GetObject&quot;,<br>                &quot;s3:DeleteObject&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;arn:aws:s3:::least_privilege_principle/*&quot;,<br>            &quot;Condition&quot;: {<br>                &quot;IpAddress&quot;: {<br>                    &quot;aws:SourceIp&quot;: &quot;123.123.123.123/32&quot;<br>                }<br>            }    <br>        }<br>    ]<br>}</pre><blockquote>Scenario 3 - 특정 IAM User에게<em>least_privilege_principle</em> S3 Bucket에 있는 객체들을 보고, 읽고, 지우는 권한을 부여하십시오. 단 <strong>GetObject</strong>와 <strong>DeleteObject</strong> Action은 해당 IAM 유저가 회사 네트위크에 접속한 상태에서만 실행할수 있어야 합니다.해당 IAM 유저에 MFA가 설정되어 있지 않을 경우 <strong>DeleteObject </strong>를 실행할수 없어야 합니다</blockquote><p>아무리 완벽한 IAM Policy를 생성했다고 해도 해당 정책을 가진 IAM User의 Credential이 유출됐다면.. 상상만 해도 끔찍한 일이네요. MFA 역시 Condition을 통해서 제어할수 있습니다.</p><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: &quot;s3:ListBucket&quot;,<br>            &quot;Resource&quot;: &quot;arn:aws:s3:::least_privilege_principle&quot;<br>        },<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;s3:GetObject&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;arn:aws:s3:::least_privilege_principle/*&quot;,<br>            &quot;Condition&quot;: {<br>                &quot;IpAddress&quot;: {<br>                    &quot;aws:SourceIp&quot;: &quot;123.123.123.123/32&quot;<br>                }<br>            }<br>        },<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;s3:DeleteObject&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;arn:aws:s3:::least_privilege_principle/*&quot;,<br>            &quot;Condition&quot;: {<br>                &quot;Bool&quot;: {<br>                    &quot;aws:MultiFactorAuthPresent&quot;: &quot;true&quot;<br>                },<br>                &quot;IpAddress&quot;: {<br>                    &quot;aws:SourceIp&quot;: &quot;123.123.123.123/32&quot;<br>                }<br>            }<br>        }<br>    ]<br>}</pre><blockquote>Scenario 4 - 한국시간 기준 업무시간 (9am - 5pm) 이외에는 AWS 상에서 어떤 작업도 할수 없어야 합니다.</blockquote><p>이 경우에도 역시 Condition을 이용해서 특정 날짜와 시간대에 따라서 접근제어를 할수 있지만 여기서 문제점은 <strong>날짜</strong>에 있습니다. ISO 8061 포맷에 맞춰진, 예를 들자면 <strong>2020–01–28T08:00:00+00:00</strong>, 시간대만 지원하므로 매일 매일 수동 혹은 자동으로 YYYY-MM-DD 부분을 업데이트 해줘야 합니다. CloudWatch Events와 AWS Lambda를 사용해서 자동화 해보도록 하겠습니다</p><ol><li>아래와 같은 IAM Policy 생성합니다. 현재 시간이 한국시간 기준 2020년 1월 28일 오전 9시라고 가정하고 아래와 같은 IAM Policy를 생성하고 부여한다면, 2020년 1월 28일 오후 5시 (UTC기준 오전 8시) 이후에 오는 모든 요청을 거부되겠죠</li></ol><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Effect&quot;: &quot;Deny&quot;,<br>            &quot;Action&quot;: &quot;*&quot;,<br>            &quot;Resource&quot;: &quot;*&quot;,<br>            &quot;Condition&quot;: {<br>                &quot;DateGreaterThanEquals&quot;: {<br>                    &quot;aws:CurrentTime&quot;: &quot;2020-01-28T08:00:00+00:00&quot;<br>                }<br>            }<br>        }<br>    ]<br>}</pre><p>2. 아래와 같은 Lambda function을 생성하고, Lambdma 환경 변수에 키 = POLICY_ARN, 값 = 위에서 생성한 IAM Policy ARN을 넣어서 지정합니다. 해당 Lambda fucntion이 실행되는 시점을 기준으로 위에서 생성한 IAM Policy에서의 날짜조건을 오늘 기준으로 업데이트 합니다.</p><pre>import json<br>import boto3<br>import datetime<br>import os</pre><pre>def lambda_handler(event, context):<br>    <br>    policyArn = os.environ[&#39;POLICY_ARN&#39;]<br>    <br>    client = boto3.client(&#39;iam&#39;)<br>    day = datetime.date.today()<br>    to_date = datetime.datetime(day.year, day.month, day.day, 8, 00, 00).replace(tzinfo=datetime.timezone.utc).isoformat()<br>    <br>    iam_policy = {<br>        &quot;Version&quot;: &quot;2012-10-17&quot;,<br>        &quot;Statement&quot;: [<br>            {<br>                &quot;Effect&quot;: &quot;Deny&quot;,<br>                &quot;Action&quot;: &quot;*&quot;,<br>                &quot;Resource&quot;: &quot;*&quot;,<br>                &quot;Condition&quot;: {<br>                    &quot;DateGreaterThanEquals&quot;: {<br>                        &quot;aws:CurrentTime&quot;: to_date<br>                    }<br>                }<br>            }<br>        ]<br>    }<br>    <br>    lpv_response = client.list_policy_versions(<br>        PolicyArn=policyArn<br>    )<br>    <br>    if len(lpv_response[&#39;Versions&#39;]) &gt; 4:<br>        dpv_response = client.delete_policy_version(<br>            PolicyArn=policyArn,<br>            VersionId=lpv_response[&#39;Versions&#39;][4][&#39;VersionId&#39;]<br>        )<br>        <br>    cpv_reponse = client.create_policy_version(<br>        PolicyArn=policyArn,<br>        PolicyDocument=json.dumps(iam_policy),<br>        SetAsDefault=True<br>    )</pre><p>3. CloudWatch Event에 Schedule Rule을 생성합니다. UTC 기준 월요일부터 금요일까지 매일 00시에(한국시간 기준 오전 9시) 위에서 생성한 Lambda Function이 실행되도록 설정합니다</p><p>자 그럼 현재 시간이 한국시간 기준 2020년 1월 28일 오후 5시 (UTC 기준 오전 8시)라고 가정한다면, 이 시간 이후로 오는 모든 요청은 <strong>Deny</strong> 될것입니다. 하루가 지나고 2020년 1월 29일 오전 9시(UTC 기준 00시) 위의 Lambda function이 실행되면 IAM Policy의 날짜 조건은 <strong>2020–01–29T08:00:00+00:00</strong>로 업데이트가 되어서 당일 기준 오후 5시까지 모든 Action에 대한 Explicy Deny 가 적용되지 않을겁니다. 이후 오후 5시부터 다음날 오전 8시59분까지는 모든 요청이 거부되겠죠</p><h3>My two cents</h3><p>위에서 간단한 예를 들어서 IAM Policy를 어떻게 하면 잘 생성할수 있는지에 대해서 소개를 했는데요. IAM Policy에 권한을 부여하는 가장 좋지만 가장 귀찮은 방법은 아무 권한도 부여하지 않고 시작하는것입니다. AWS Console, SDK, CLI를 이용할때 권한문제가 있을때 AWS는 친절하게도 Error Message는 보여줍니다. 예를 들자면 아래와 같은</p><pre>A client error (AccessDenied) occurred when calling the ListObjects operation: Access Denied</pre><p>이 에러인 즉슨 <strong>ListObjects</strong> 에 대한 권한이 없어서 명령을 수행할수 없다는 뜻이죠. 자 그럼 이제 뭘 해야할까요? IAM Policy에 해당 권한을 추가하면 되겠죠. 無에서 시작해서 Access Denied를 볼때마다 해당 권한을 추가한다면 나에게 꼭 맞은 IAM 정책을 수립할수 있을겁니다.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=454faa566f9b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/saltware/principle-of-least-privilege-with-iam-policy-454faa566f9b">Principle of Least Privilege with IAM Policy</a> was originally published in <a href="https://medium.com/saltware">Saltware</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Elastic IP 복구 하기]]></title>
            <link>https://medium.com/saltware/elastic-ip-%EB%B3%B5%EA%B5%AC-%ED%95%98%EA%B8%B0-3c70f1037d4?source=rss-95bc8e3af337------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c70f1037d4</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[elastic-ip]]></category>
            <category><![CDATA[amazon-web-services]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Young Woo Jung]]></dc:creator>
            <pubDate>Thu, 16 Jan 2020 02:17:10 GMT</pubDate>
            <atom:updated>2020-01-16T02:17:10.068Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DFk8cmJ4CLBBpiQHZabPTQ.jpeg" /></figure><p>만약 실수로 또는 더이상 필요하지 않아서 Elastic IP를 해제 (Release) 했을때 아래와 같은 조건을 충족한다면 해제한 Elastic IP를 복구 할수 있습니다</p><ol><li>해당 Elastic IP가 다른 계정에 할당되지 않았을 경우</li><li>Elastic IP 할당 한도가 초과되지 않았을 경우</li></ol><p>우선 Elastic IP를 생성해보도록 하겠습니다.</p><p>AWS Management Console 에서 좌측 상단에 있는 <strong>[Services]</strong> 를 선택하고 검색창에서 EC2를 검색하거나 <strong>[Compute]</strong> 바로 밑에 있는 <strong>[EC2] </strong>를 선택 후 [<strong>Elastic IPs</strong>] → [<strong>Allocate new address</strong>] → [<strong>Allocate</strong>] 클릭</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/871/1*Nv9pQd5zOG0lVbaBGolgRg.png" /></figure><p>생성된 Elastic IP 주소를 메모하고 할당받은 Elastic IP 주소를 해제하겠습니다. 방금 할당받은 Elastic IP 선택 → [<strong>Actions</strong>] → [<strong>Release Elastic IP addresses</strong>] → [<strong>Release</strong>]</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FEA7w5hDg9E68dCqJkdziA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LibZ_ZdM9MtAjAtZoCL-fA.png" /></figure><p>이제 AWS CLI를 사용해서 방금 해제한 Elastic IP를 복구해보겠습니다.</p><pre>$ aws ec2 allocate-address --domain vpc --address 15.165.171.152<br>{<br>    &quot;PublicIp&quot;: &quot;15.165.171.152&quot;,<br>    &quot;Domain&quot;: &quot;vpc&quot;,<br>    &quot;AllocationId&quot;: &quot;eipalloc-0607f43dcb7fe1b44&quot;,<br>    &quot;PublicIpv4Pool&quot;: &quot;amazon&quot;<br>}</pre><p>방금 해제한 Elastic IP를 성공적으로 복구했습니다. 하지만 위에서 언급했듯이 해제한 Elastic IP가 다른 AWS 계정에 할당되지 않을때 경우에만 복구가 가능하구요. 만약 재할당을 요청하기 전에 이미 해당 Elastic IP 주소가 다른 계정에 할당되었다면 아래와 같은 에러메세지가 Return 됩니다</p><pre>An error occurred (InvalidAddress.NotFound) when calling the AllocateAddress operation: The Elastic IP address &#39;xxx.xxx.xxx.xxx&#39; does not exist or is not available.</pre><p>100% 복구된다는 보장은 없으니 Elastic IP는 최대한 해제하지 않는 쪽으로 😃</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c70f1037d4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/saltware/elastic-ip-%EB%B3%B5%EA%B5%AC-%ED%95%98%EA%B8%B0-3c70f1037d4">Elastic IP 복구 하기</a> was originally published in <a href="https://medium.com/saltware">Saltware</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>