<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>JaeYoung Heo</title>
    <description>JaeYoung&apos;s Tech blog. Studying for DBA.
</description>
    <link>https://hjy.today/</link>
    <atom:link href="https://hjy.today/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Thu, 22 Oct 2026 22:49:23 +0900</pubDate>
    <lastBuildDate>Thu, 22 Oct 2026 22:49:23 +0900</lastBuildDate>
    <generator>Jekyll v3.10.0</generator>
    
      <item>
        <title>[Vue.js] #3 컴포넌트</title>
        <description>&lt;p&gt;&lt;a href=&quot;https://www.inflearn.com/course/age-of-vuejs/dashboard&quot;&gt;Vue.js 시작하기 - Age of Vue.js&lt;/a&gt; 강의 섹션 3. 컴포넌트&lt;/p&gt;

&lt;!--more--&gt;

&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#컴포넌트란&quot; id=&quot;markdown-toc-컴포넌트란&quot;&gt;컴포넌트란&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#컴포넌트-등록&quot; id=&quot;markdown-toc-컴포넌트-등록&quot;&gt;컴포넌트 등록&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;컴포넌트란&quot;&gt;컴포넌트란&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Web/2023-07-25-[Vue.js]_3_컴포넌트/1.png&quot; alt=&quot;1&quot; /&gt;&lt;/p&gt;

&lt;p&gt;현대의 프레임워크들은 대부분 컴포넌트 기반으로 개발하고 있다.&lt;br /&gt;
컴포넌트란, 화면을 영역별로 나누어서 따로 관리할 수 있도록 한 것이다.&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;이렇게 함으로써 코드의 재사용성을 높일 수 있다.&lt;br /&gt;&lt;/p&gt;

&lt;h1 id=&quot;컴포넌트-등록&quot;&gt;컴포넌트 등록&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;예시 코드를 통해 학습해보자.&lt;/p&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// /playground/component.html&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;c&quot;&gt;&amp;lt;!--&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;컴포넌트&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;태그&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;사용&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;--&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;header&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/app-header&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;        &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/app-content&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;        &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;footer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/app-footer&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/div&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;app2&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;header&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/app-header&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;        &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;footer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/app-footer&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/div&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;script&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;https://cdn.jsdelivr.net/npm/vue/dist/vue.js&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/script&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// 2-1. 전역 컴포넌트 등록&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// Vue.component(&apos;컴포넌트 이름&apos;, {&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;//  컴포넌트 내용&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// })&lt;/span&gt;
        &lt;span class=&quot;nx&quot;&gt;Vue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;component&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;app-header&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;na&quot;&gt;template&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;lt;h1&amp;gt;Header&amp;lt;/h1&amp;gt;&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;

        &lt;span class=&quot;nx&quot;&gt;Vue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;component&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;app-content&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;na&quot;&gt;template&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;lt;div&amp;gt;content&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;

        &lt;span class=&quot;c1&quot;&gt;// 1. Vue 생성자 만들기&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Vue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt; 
            &lt;span class=&quot;na&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;#app&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;// 2-2. 지역 컴포넌트 등록&lt;/span&gt;
            &lt;span class=&quot;na&quot;&gt;components&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
              &lt;span class=&quot;c1&quot;&gt;// &apos;컴포넌트 이름&apos;: {컴포넌트 내용}&lt;/span&gt;
                &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;app-footer&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
                    &lt;span class=&quot;na&quot;&gt;template&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;lt;footer&amp;gt;footer&amp;lt;/footer&amp;gt;&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;
                &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Vue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;
            &lt;span class=&quot;na&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;#app2&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;// components: {&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;//     &apos;app-footer&apos;: {&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;//         template: &apos;&amp;lt;footer&amp;gt;footer&amp;lt;/footer&amp;gt;&apos;&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;//     }&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;// }&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/script&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/body&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Web/2023-07-25-[Vue.js]_3_컴포넌트/2.png&quot; alt=&quot;2&quot; /&gt;&lt;/p&gt;

&lt;table&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Vue 생성자&lt;/code&gt;를 통해 두 개의 div 태그(app1, app2)에 인스턴스를 붙였다.&lt;br /&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2-1&lt;/td&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;전역 컴포넌트&lt;/code&gt;를 등록하였다.&lt;br /&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2-2&lt;/td&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;지역 컴포넌트&lt;/code&gt;를 등록하였다.&lt;br /&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;3&lt;/td&gt;
      &lt;td&gt;만들어진 컴포넌트 태그를 사용하였다.&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;그 결과, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;App1&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;App2&lt;/code&gt; 라는 각 태그를 나타내는 영역이 생겼으며, &lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Root&lt;/code&gt; 컴포넌트 아래에 하위 컴포넌트가 생겼다.&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;여기서 주목할점은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;app-footer&lt;/code&gt; 이다.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;App1&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;App2&lt;/code&gt; 모두 동일하게 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;app-footer&lt;/code&gt; 컴포넌트를 사용했지만&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;App1&lt;/code&gt;의 경우 자신의 생성자에 선언한 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;app-footer&lt;/code&gt; 컴포넌트를 사용하였고,&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;App2&lt;/code&gt;의 경우 사용할 수 없기 때문에 출력되지 않았다.&lt;/p&gt;

&lt;p&gt;아주 익숙한 전역 변수, 지역 변수와 같은 개념같다.&lt;br /&gt;
보통 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;전역 컴포넌트&lt;/code&gt;는 잘 안쓰고, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;지역 컴포넌트&lt;/code&gt;를 사용하여 관리할 것이라고 한다.&lt;/p&gt;
</description>
        <pubDate>Tue, 25 Jul 2023 00:30:00 +0900</pubDate>
        <link>https://hjy.today/vue.js/Vue.js-_3_%EC%BB%B4%ED%8F%AC%EB%84%8C%ED%8A%B8.html</link>
        <guid isPermaLink="true">https://hjy.today/vue.js/Vue.js-_3_%EC%BB%B4%ED%8F%AC%EB%84%8C%ED%8A%B8.html</guid>
        
        <category>web</category>
        
        <category>vue.js</category>
        
        
        <category>vue.js</category>
        
      </item>
    
      <item>
        <title>[Vue.js] #2 인스턴스</title>
        <description>&lt;p&gt;&lt;a href=&quot;https://www.inflearn.com/course/age-of-vuejs/dashboard&quot;&gt;Vue.js 시작하기 - Age of Vue.js&lt;/a&gt; 강의 섹션 2. 인스턴스&lt;/p&gt;

&lt;!--more--&gt;

&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#인스턴스란&quot; id=&quot;markdown-toc-인스턴스란&quot;&gt;인스턴스란&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#인스턴스와-생성자-함수&quot; id=&quot;markdown-toc-인스턴스와-생성자-함수&quot;&gt;인스턴스와 생성자 함수&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#인스턴스-옵션-속성&quot; id=&quot;markdown-toc-인스턴스-옵션-속성&quot;&gt;인스턴스 옵션 속성&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;인스턴스란&quot;&gt;인스턴스란&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;인스턴스&lt;/code&gt;는 뷰로 개발할 때 필수로 생성해야 하는 코드이다.&lt;br /&gt;&lt;/p&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Vue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// 생성&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;vm&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Vue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// 할당(vm은 viewModel의 약자)&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;vm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// 인스턴스 속성 및 API 확인&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;인스턴스와-생성자-함수&quot;&gt;인스턴스와 생성자 함수&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;아래 예제 코드를 통해 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Vue&lt;/code&gt; 의 기능을 체감해보자.&lt;/p&gt;

&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;&amp;lt;!-- /playground/instance.html --&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;app&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;

    &lt;span class=&quot;c&quot;&gt;&amp;lt;!-- Vue cdn --&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;script &lt;/span&gt;&lt;span class=&quot;na&quot;&gt;src=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;https://cdn.jsdelivr.net/npm/vue/dist/vue.js&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

    &lt;span class=&quot;nt&quot;&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;vm&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Vue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;// id가 app인 태그를 찾아서 인스턴스를 붙입니다.&lt;/span&gt;
            &lt;span class=&quot;na&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;#app&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// el은 element의 약자입니다.&lt;/span&gt;
            &lt;span class=&quot;na&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; 
                &lt;span class=&quot;na&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;hi&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Live Server&lt;/code&gt; 에서 실행하고, 아래 코드를 콘솔 창에 입력해보자.&lt;br /&gt;
참고로, 함수 명을 대문자로 적으면 이는 곧 생성자임을 나타낸다.&lt;/p&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Vue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;logText&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;Hello&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;vm&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Vue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;vm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;logText&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Web/2023-07-24-[Vue.js]_2_인스턴스/1.png&quot; alt=&quot;1&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Vue 생성자&lt;/code&gt;에서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;logText()&lt;/code&gt; 라는 함수를 정의하였다.&lt;br /&gt;
이제 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Vue 생성자&lt;/code&gt;를 통해서 생성되는 객체는 모두 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;logText()&lt;/code&gt; 함수를 재사용할 수 있다.&lt;/p&gt;

&lt;h1 id=&quot;인스턴스-옵션-속성&quot;&gt;인스턴스 옵션 속성&lt;/h1&gt;
&lt;hr /&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Vue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// 인스턴스가 그려지는 화면의 시작점(특정 HTML 태그)&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;template&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// 화면에 표시할 요소(HTML, CSS 등&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// 뷰의 반응성(Reactivity)가 반영된 데이터 속성&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;methods&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// 화면의 동작과 이벤트 로직을 제어하는 메소드&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;created&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// 뷰의 라이프 사이클과 관련된 속성&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;watch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// data에서 정의된 속성이 변화했을 떄 추가 동작을 수행할 수 있게 정의하는 속성&lt;/span&gt;

  &lt;span class=&quot;c1&quot;&gt;// 등등...&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;인스턴스 옵션의 속성은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;키:값&lt;/code&gt; 형태로 이루어져있다.&lt;br /&gt;&lt;/p&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/div&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;script&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;https://cdn.jsdelivr.net/npm/vue/dist/vue.js&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/script&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
        
        &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;options&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;#app&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;na&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;hi&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;
          &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

        &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;vm&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Vue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;options&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/script&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/body&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;위 코드에서는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;options&lt;/code&gt; 라는 객체를 정의하고 이를 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Vue 인스턴스&lt;/code&gt; 안에 담았다.&lt;br /&gt;
하지만 강의에서는 이렇게 말고, 아래와 같은 방법을 추천하였다.&lt;/p&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/div&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;script&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;https://cdn.jsdelivr.net/npm/vue/dist/vue.js&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/script&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;

        &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;vm&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Vue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;#app&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;na&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;hi&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;
          &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;

    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/script&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/body&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;위와 같이 가독성을 위하여 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;객체 리터럴&lt;/code&gt;로 선언하여 사용하기를 추천하였다.&lt;/p&gt;

&lt;p&gt;#2 인스턴스는 여기까지다.
다음 강의에서는 컴포넌트에 대해서 공부해보자.&lt;/p&gt;
</description>
        <pubDate>Mon, 24 Jul 2023 23:45:00 +0900</pubDate>
        <link>https://hjy.today/vue.js/Vue.js-_2_%EC%9D%B8%EC%8A%A4%ED%84%B4%EC%8A%A4.html</link>
        <guid isPermaLink="true">https://hjy.today/vue.js/Vue.js-_2_%EC%9D%B8%EC%8A%A4%ED%84%B4%EC%8A%A4.html</guid>
        
        <category>web</category>
        
        <category>vue.js</category>
        
        
        <category>vue.js</category>
        
      </item>
    
      <item>
        <title>[Vue.js] #1 Vue.js 소개</title>
        <description>&lt;p&gt;&lt;a href=&quot;https://www.inflearn.com/course/age-of-vuejs/dashboard&quot;&gt;Vue.js 시작하기 - Age of Vue.js&lt;/a&gt; 강의 섹션 1. Vue.js 소개&lt;/p&gt;

&lt;!--more--&gt;

&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#vue란-무엇인가-디자인패턴-mvvm&quot; id=&quot;markdown-toc-vue란-무엇인가-디자인패턴-mvvm&quot;&gt;Vue란 무엇인가? 디자인패턴 MVVM&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#reactivity&quot; id=&quot;markdown-toc-reactivity&quot;&gt;Reactivity&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#vue-개발자도구&quot; id=&quot;markdown-toc-vue-개발자도구&quot;&gt;Vue 개발자도구&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;vue란-무엇인가-디자인패턴-mvvm&quot;&gt;Vue란 무엇인가? 디자인패턴 MVVM&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Web/2023-07-24-[Vue.js]_1_Vue.js_소개/1.png&quot; alt=&quot;1&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vue 란,&lt;/strong&gt;&lt;br /&gt;
MVVM 패턴의 뷰모델 레이어에 해당하는 화면(View)단 라이브러리이다.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;View = 화면(보통 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HTML&lt;/code&gt;), &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DOM(javaScript)&lt;/code&gt; 을 사용해서 조작&lt;/li&gt;
  &lt;li&gt;Model = JavaScript의 Data&lt;/li&gt;
  &lt;li&gt;ViewModel = &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;View(DOM)&lt;/code&gt; 의 동작을 캐치해서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Model&lt;/code&gt; 에 넘겨줌, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Model(JavaScript Data)&lt;/code&gt; 의 변화를 바인딩해서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;View&lt;/code&gt; 단에 반영함&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Web/2023-07-24-[Vue.js]_1_Vue.js_소개/2.png&quot; alt=&quot;2&quot; /&gt;&lt;/p&gt;

&lt;p&gt;살펴보면 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MVVM 패턴&lt;/code&gt; 은 Spring에서의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MVC 패턴&lt;/code&gt; 과 유사한 것 같다.&lt;br /&gt;
MVC의 Controller의 역할을 MVVM의 ViewModel이 담당하는 것처럼 보인다.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://scshim.tistory.com/407&quot;&gt;찾아보니&lt;/a&gt;, &lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MVC&lt;/code&gt; - Controller의 경우 View와 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;1:다&lt;/code&gt;의 관계를 가지고&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MVVM&lt;/code&gt; - ViewModel의 경우 View와 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;다:1&lt;/code&gt;의 관계를 가지는 등의 차이가 있다고 한다.&lt;br /&gt;
사실 아직 감은 잘 안오는데, 강의를 들으면서 차차 이해가 될 것이라고 생각…&lt;/p&gt;

&lt;h1 id=&quot;reactivity&quot;&gt;Reactivity&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;기존에 화면의 값을 할당한 후, 재할당하기 위해서는 다음과 같이 코드를 작성하였다.&lt;/p&gt;

&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;&amp;lt;!-- playground/web-dev.html --&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;body&amp;gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;app&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;

    &lt;span class=&quot;nt&quot;&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;#app&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;str&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;hello world&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;nx&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;innerHTML&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

        &lt;span class=&quot;nx&quot;&gt;str&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;hello world!!!&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;nx&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;innerHTML&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;str&lt;/code&gt; 에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&apos;hello world&apos;&lt;/code&gt; 라는 값을 담은 뒤 이를 화면에 반영해주고, &lt;br /&gt;
다시 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&apos;hello world!!!&apos;&lt;/code&gt; 라는 값을 할당한 뒤 화면에 반영해주는 과정을 거쳤다.&lt;br /&gt;
다음을 한 번 보자.&lt;br /&gt;&lt;/p&gt;

&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;&amp;lt;!-- playground/vue-way.html --&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;app&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;

    &lt;span class=&quot;nt&quot;&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;#app&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;viewModel&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{};&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// viewModel 이라는 객체 선언&lt;/span&gt;

        &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// 즉시실행함수&lt;/span&gt;
            &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;init&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;c1&quot;&gt;// 객체의 동작을 재정의하는 API&lt;/span&gt;
                &lt;span class=&quot;c1&quot;&gt;// Object.defineProperty(대상 객체, 객체의 속성, {&lt;/span&gt;
                &lt;span class=&quot;c1&quot;&gt;//  정의할 내용&lt;/span&gt;
                &lt;span class=&quot;c1&quot;&gt;// })&lt;/span&gt;
                &lt;span class=&quot;nb&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;defineProperty&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;viewModel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
                    &lt;span class=&quot;c1&quot;&gt;// get : 속성에 접근했을 떄의 동작을 정의&lt;/span&gt;
                    &lt;span class=&quot;na&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
                        &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;접근&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
                    &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
                    &lt;span class=&quot;c1&quot;&gt;// set : 속성에 값을 할당했을 때의 동작을 정의&lt;/span&gt;
                    &lt;span class=&quot;c1&quot;&gt;// Data Binding&lt;/span&gt;
                    &lt;span class=&quot;na&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;newValue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// newValue는 할당 될 값을 의미&lt;/span&gt;
                        &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;할당&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;newValue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; 
                        &lt;span class=&quot;nx&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;newValue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
                    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
                &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

            &lt;span class=&quot;c1&quot;&gt;// 함수 정의&lt;/span&gt;
            &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;nx&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;innerHTML&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

            &lt;span class=&quot;nx&quot;&gt;init&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;})();&lt;/span&gt;
        
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;주석을 보고 충분히 파악할 수 있다.&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Object.defineProperty&lt;/code&gt; 라는 API를 사용해서 접근의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;get&lt;/code&gt;, 할당의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;set&lt;/code&gt; 을 재정의하였으며&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;render()&lt;/code&gt; 라는 함수를 사용하여 화면에 값을 뿌려주도록 하였다.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Web/2023-07-24-[Vue.js]_1_Vue.js_소개/3.png&quot; alt=&quot;3&quot; /&gt;&lt;/p&gt;

&lt;p&gt;개발자 도구를 사용하여 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;viewModel.str&lt;/code&gt; 의 값을 새로 할당해 줄 때마다, 즉각적으로 바뀌는 화면을 경험할 수 있다.&lt;br /&gt;
이것이 Vue의 핵심인 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Reactivity&lt;/code&gt; 로, 간단한 Javascript를 통해 구현해 보았다.
Vue를 사용하면 이 데이터의 변화를 라이브러리에서 감지할 것이다.&lt;/p&gt;

&lt;p&gt;여기서 또 한 가지 주목할 곳이 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;즉시실행함수&lt;/code&gt; 부분이다.&lt;br /&gt;
이는 내부 코드를 또다른 스코프에 넣음으로써 유효범위를 조정할 수 있게 해준다.&lt;/p&gt;

&lt;h1 id=&quot;vue-개발자도구&quot;&gt;Vue 개발자도구&lt;/h1&gt;
&lt;hr /&gt;

&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;&amp;lt;!-- getting-started/index.html --&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;app&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
      
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;

    &lt;span class=&quot;nt&quot;&gt;&amp;lt;script &lt;/span&gt;&lt;span class=&quot;na&quot;&gt;src=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;https://cdn.jsdelivr.net/npm/vue/dist/vue.js&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Vue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;#app&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;Hello Vue.js&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;본격적인 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Vue&lt;/code&gt; 를 사용하는 간단한 예제 코드를 개발자도구를 통해 살펴보자.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Web/2023-07-24-[Vue.js]_1_Vue.js_소개/4.png&quot; alt=&quot;4&quot; /&gt;&lt;/p&gt;

&lt;p&gt;디자인이 아주 예쁘다 …&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;App1&lt;/code&gt; &amp;gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Root&lt;/code&gt; &amp;gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;data&lt;/code&gt; &amp;gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;message&lt;/code&gt; 를 주목해보자.&lt;br /&gt;
현재 이 값이 화면에 뿌려지고 있다.&lt;br /&gt;
이를 변경해보자.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Web/2023-07-24-[Vue.js]_1_Vue.js_소개/5.png&quot; alt=&quot;5&quot; /&gt;&lt;/p&gt;

&lt;p&gt;즉각적으로 바뀌는 화면을 볼 수 있다.&lt;br /&gt;
이것이 위에서 말한 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Reactivity&lt;/code&gt; 이다.&lt;/p&gt;

&lt;p&gt;#1은 여기서 마무리.&lt;br /&gt;
다음 글에서는 Vue의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;인스턴스&lt;/code&gt; 에 대해서 배워보자.&lt;/p&gt;
</description>
        <pubDate>Mon, 24 Jul 2023 21:45:00 +0900</pubDate>
        <link>https://hjy.today/vue.js/Vue.js-_1_Vue.js_%EC%86%8C%EA%B0%9C.html</link>
        <guid isPermaLink="true">https://hjy.today/vue.js/Vue.js-_1_Vue.js_%EC%86%8C%EA%B0%9C.html</guid>
        
        <category>web</category>
        
        <category>vue.js</category>
        
        
        <category>vue.js</category>
        
      </item>
    
      <item>
        <title>[AWS] SAP-C02 ExamTopics 61~70</title>
        <description>&lt;p&gt;SAP-C02 기출 61~70번 문제를 풀어보자.&lt;br /&gt;
1차 ?/10&lt;br /&gt;&lt;/p&gt;

&lt;!--more--&gt;

&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-61-&quot; id=&quot;markdown-toc-prob-61-&quot;&gt;Prob. 61 ❌&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-62-&quot; id=&quot;markdown-toc-prob-62-&quot;&gt;Prob. 62 ❌&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-63-️&quot; id=&quot;markdown-toc-prob-63-️&quot;&gt;Prob. 63 ⭕️&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-64-&quot; id=&quot;markdown-toc-prob-64-&quot;&gt;Prob. 64 ❌&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-65-&quot; id=&quot;markdown-toc-prob-65-&quot;&gt;Prob. 65 ❌&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-66&quot; id=&quot;markdown-toc-prob-66&quot;&gt;Prob. 66&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-67&quot; id=&quot;markdown-toc-prob-67&quot;&gt;Prob. 67&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-68&quot; id=&quot;markdown-toc-prob-68&quot;&gt;Prob. 68&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-69&quot; id=&quot;markdown-toc-prob-69&quot;&gt;Prob. 69&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-70&quot; id=&quot;markdown-toc-prob-70&quot;&gt;Prob. 70&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-61-&quot;&gt;Prob. 61 ❌&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A finance company hosts a data lake in Amazon S3. The company receives financial data records over SFTP each night from several third parties. The company runs its own SFTP server on an Amazon EC2 instance in a public subnet of a VPC. After the files are uploaded, they are moved to the data lake by a cron job that runs on the same instance. The SFTP server is reachable on DNS sftp.example.com through the use of Amazon Route 53.&lt;/p&gt;

&lt;p&gt;What should a solutions architect do to improve the reliability and scalability of the SFTP solution?&lt;/p&gt;

&lt;p&gt;A. Move the EC2 instance into an Auto Scaling group. Place the EC2 instance behind an Application Load Balancer (ALB). Update the DNS record sftp.example.com in Route 53 to point to the ALB.&lt;/p&gt;

&lt;p&gt;B. Migrate the SFTP server to AWS Transfer for SFTP. Update the DNS record sftp.example.com in Route 53 to point to the server endpoint hostname.&lt;/p&gt;

&lt;p&gt;C. Migrate the SFTP server to a file gateway in AWS Storage Gateway. Update the DNS record sftp.example.com in Route 53 to point to the file gateway endpoint.&lt;/p&gt;

&lt;p&gt;D. Place the EC2 instance behind a Network Load Balancer (NLB). Update the DNS record sftp.example.com in Route 53 to point to the NLB.&lt;/p&gt;
&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : B&lt;/p&gt;

    &lt;p&gt;1차 시도 : C&lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;A=ALB cannot be used with SFTP&lt;/p&gt;

    &lt;p&gt;B = Correct&lt;/p&gt;

    &lt;p&gt;C=Storage Gateway is not an SFTP Server&lt;/p&gt;

    &lt;p&gt;D=NLB can be used with SFTP, but EC2 is single&lt;/p&gt;
  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-62-&quot;&gt;Prob. 62 ❌&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company wants to migrate an application to Amazon EC2 from VMware Infrastructure that runs in an on-premises data center. A solutions architect must preserve the software and configuration settings during the migration.&lt;/p&gt;

&lt;p&gt;What should the solutions architect do to meet these requirements?&lt;/p&gt;

&lt;p&gt;A. Configure the AWS DataSync agent to start replicating the data store to Amazon FSx for Windows File Server. Use the SMB share to host the VMware data store. Use VM Import/Export to move the VMs to Amazon EC2.&lt;/p&gt;

&lt;p&gt;B. Use the VMware vSphere client to export the application as an image in Open Virtualization Format (OVF) format. Create an Amazon S3 bucket to store the image in the destination AWS Region. Create and apply an IAM role for VM Import. Use the AWS CLI to run the EC2 import command.&lt;/p&gt;

&lt;p&gt;C. Configure AWS Storage Gateway for files service to export a Common Internet File System (CIFS) share. Create a backup copy to the shared folder. Sign in to the AWS Management Console and create an AMI from the backup copy. Launch an EC2 instance that is based on the AMI.&lt;/p&gt;

&lt;p&gt;D. Create a managed-instance activation for a hybrid environment in AWS Systems Manager. Download and install Systems Manager Agent on the on-premises VM. Register the VM with Systems Manager to be a managed instance. Use AWS Backup to create a snapshot of the VM and create an AMI. Launch an EC2 instance that is based on the AMI&lt;/p&gt;
&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : B&lt;/p&gt;

    &lt;p&gt;1차 시도 : C&lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;Use VM Import/Export. B is correct . https://aws.amazon.com/ec2/vm-import/&lt;/p&gt;

    &lt;p&gt;https://docs.aws.amazon.com/vm-import/latest/userguide/vmimport-image-import.html&lt;/p&gt;

    &lt;p&gt;Prerequisites&lt;/p&gt;

    &lt;p&gt;Create an Amazon S3 bucket for storing the exported images or choose an existing bucket. &lt;br /&gt;
The bucket must be in the Region where you want to import your VMs. &lt;br /&gt;
For more information about S3 buckets, see the Amazon Simple Storage Service User Guide.  &lt;br /&gt;
Create an IAM role named vmimport. &lt;br /&gt;
For more information, see Required service role. &lt;br /&gt;
 If you have not already installed the AWS CLI on the computer you’ll use to run the import commands, see the AWS Command Line Interface User Guide.&lt;/p&gt;
  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-63-️&quot;&gt;Prob. 63 ⭕️&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A video processing company has an application that downloads images from an Amazon S3 bucket, processes the images, stores a transformed image in a second S3 bucket, and updates metadata about the image in an Amazon DynamoDB table. The application is written in Node.js and runs by using an AWS Lambda function. The Lambda function is invoked when a new image is uploaded to Amazon S3.&lt;/p&gt;

&lt;p&gt;The application ran without incident for a while. However, the size of the images has grown significantly. The Lambda function is now failing frequently with timeout errors. The function timeout is set to its maximum value. A solutions architect needs to refactor the application’s architecture to prevent invocation failures. The company does not want to manage the underlying infrastructure.&lt;/p&gt;

&lt;p&gt;Which combination of steps should the solutions architect take to meet these requirements? (Choose two.)&lt;/p&gt;

&lt;p&gt;A. Modify the application deployment by building a Docker image that contains the application code. Publish the image to Amazon Elastic Container Registry (Amazon ECR).&lt;/p&gt;

&lt;p&gt;B. Create a new Amazon Elastic Container Service (Amazon ECS) task definition with a compatibility type of AWS Fargate. Configure the task definition to use the new image in Amazon Elastic Container Registry (Amazon ECR). Adjust the Lambda function to invoke an ECS task by using the ECS task definition when a new file arrives in Amazon S3.&lt;/p&gt;

&lt;p&gt;C. Create an AWS Step Functions state machine with a Parallel state to invoke the Lambda function. Increase the provisioned concurrency of the Lambda function.&lt;/p&gt;

&lt;p&gt;D. Create a new Amazon Elastic Container Service (Amazon ECS) task definition with a compatibility type of Amazon EC2. Configure the task definition to use the new image in Amazon Elastic Container Registry (Amazon ECR). Adjust the Lambda function to invoke an ECS task by using the ECS task definition when a new file arrives in Amazon S3.&lt;/p&gt;

&lt;p&gt;E. Modify the application to store images on Amazon Elastic File System (Amazon EFS) and to store metadata on an Amazon RDS DB instance. Adjust the Lambda function to mount the EFS file share.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : A, B&lt;/p&gt;

    &lt;p&gt;1차 시도 : A, B&lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;A: create Docker image and save it to ECR &lt;br /&gt;
B: run this image on Fargate  &lt;br /&gt;
No answer should have Lambda the will be time out&lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;Based on Serverless solutions used, need to go with Fargate in combination with either ECS/EC2.&lt;br /&gt;
As company does not want to manage infra, we go for because Fargate-ECS combo as Fargate-EC2 needs more maintenance .&lt;br /&gt;
That means D is out.&lt;br /&gt;
E is obviously out EFS does not contribute to lambda invocation timeouts. &lt;br /&gt;
C is wrong because, increased concurrency (more lambda versions) won’t solve timeouts. &lt;br /&gt;
That leaves A and B as right answers.&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-64-&quot;&gt;Prob. 64 ❌&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company has an organization in AWS Organizations. The company is using AWS Control Tower to deploy a landing zone for the organization. The company wants to implement governance and policy enforcement. The company must implement a policy that will detect Amazon RDS DB instances that are not encrypted at rest in the company’s production OU.&lt;/p&gt;

&lt;p&gt;Which solution will meet this requirement?&lt;/p&gt;

&lt;p&gt;A. Turn on mandatory guardrails in AWS Control Tower. Apply the mandatory guardrails to the production OU.&lt;/p&gt;

&lt;p&gt;B. Enable the appropriate guardrail from the list of strongly recommended guardrails in AWS Control Tower. Apply the guardrail to the production OU.&lt;/p&gt;

&lt;p&gt;C. Use AWS Config to create a new mandatory guardrail. Apply the rule to all accounts in the production OU.&lt;/p&gt;

&lt;p&gt;D. Create a custom SCP in AWS Control Tower. Apply the SCP to the production OU.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : B&lt;/p&gt;

    &lt;p&gt;1차 시도 : A&lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;Mandatory controls are owned by AWS Control Tower, and they apply to every OU on your landing zone. &lt;br /&gt;
These controls are applied by default when you set up your landing zone, and they can’t be deactivated. &lt;br /&gt;
The solution requirement falls under a proactive(Recommended Control). &lt;br /&gt;
https://docs.aws.amazon.com/controltower/latest/userguide/rds-rules.html#ct-rds-pr-16-description 
&lt;br /&gt;
Optional controls are OU specific.&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-65-&quot;&gt;Prob. 65 ❌&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A startup company hosts a fleet of Amazon EC2 instances in private subnets using the latest Amazon Linux 2 AMI. The company’s engineers rely heavily on SSH access to the instances for troubleshooting.&lt;/p&gt;

&lt;p&gt;The company’s existing architecture includes the following:&lt;/p&gt;

&lt;p&gt;• A VPC with private and public subnets, and a NAT gateway.
• Site-to-Site VPN for connectivity with the on-premises environment.
• EC2 security groups with direct SSH access from the on-premises environment.&lt;/p&gt;

&lt;p&gt;The company needs to increase security controls around SSH access and provide auditing of commands run by the engineers.&lt;/p&gt;

&lt;p&gt;Which strategy should a solutions architect use?&lt;/p&gt;

&lt;p&gt;A. Install and configure EC2 Instance Connect on the fleet of EC2 instances. Remove all security group rules attached to EC2 instances that allow inbound TCP on port 22. Advise the engineers to remotely access the instances by using the EC2 Instance Connect CLI.&lt;/p&gt;

&lt;p&gt;B. Update the EC2 security groups to only allow inbound TCP on port 22 to the IP addresses of the engineer’s devices. Install the Amazon CloudWatch agent on all EC2 instances and send operating system audit logs to CloudWatch Logs.&lt;/p&gt;

&lt;p&gt;C. Update the EC2 security groups to only allow inbound TCP on port 22 to the IP addresses of the engineer’s devices. Enable AWS Config for EC2 security group resource changes. Enable AWS Firewall Manager and apply a security group policy that automatically remediates changes to rules.&lt;/p&gt;

&lt;p&gt;D. Create an IAM role with the AmazonSSMManagedInstanceCore managed policy attached. Attach the IAM role to all the EC2 instances. Remove all security group rules attached to the EC2 instances that allow inbound TCP on port 22. Have the engineers install the AWS Systems Manager Session Manager plugin for their devices and remotely access the instances by using the start-session API call from Systems Manager.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : D&lt;/p&gt;

    &lt;p&gt;1차 시도 : C&lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;A is wrong because Instance connect does not provided auditing&lt;br /&gt;
B is wrong because it mentions OS audit logs. we need to audit SSH trafic&lt;br /&gt;
C is wrong because we want to audit not remediate as asked in question. config service is to record using predefined rules and remediate as well&lt;/p&gt;

    &lt;p&gt;D is correct because,&lt;br /&gt;
By attaching the AmazonSSMManagedInstanceCore policy to an IAM role, EC2 instances can be controlled and monitored through the Systems Manager service, enabling capabilities such as remote instance management, patching, and compliance reporting.&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-66&quot;&gt;Prob. 66&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company that usese AWS Organizations allows developers to experiment on AWS. AS part of the landing zone that the company has deployed, develipers use their company email adderss to request an account. The company
wants to ensure that developers are not launching costly services or running services unnecessarily. The company must give devlopers a fied monthly budget to limit their AWS costs.&lt;/p&gt;

&lt;p&gt;A company that users AWS Organizations allows developers to experimnet on AWS. AS part of the landing zone that the company has deployed, develipers use their company email adderess to request an acocount./ The comapny wants to ensure that developers are not launcing costly services or runnign services unnecessarily. The company must give devlopers a fixed montlhhy budget to limit their AWS costs.&lt;/p&gt;

&lt;p&gt;A company that uses AWS Organizations allows developers to experiment on AWSW. As part of the landing zone that the company ahs deployed, developers use their company email adderess to request an account. The company wants to ensure that devlopers are not laun ching costly services or running services unnecesarily.&lt;/p&gt;

&lt;p&gt;A company that uses AWS Organizations allows developers to experiment on AWS. As part of the landing zone that the company has deployed, developers use their company email address to request an account. The company wants to ensure that developers are not launching costly services or running services unnecessarily. The company must give developers a fixed monthly budget to limit their AWS costs.&lt;/p&gt;

&lt;p&gt;Which combination of steps will meet these requirements? (Choose three.)&lt;/p&gt;

&lt;p&gt;A. Create an SCP to set a fixed monthly account usage limit. Apply the SCP to the developer accounts.&lt;/p&gt;

&lt;p&gt;B. Use AWS Budgets to create a fixed monthly budget for each developer’s account as part of the account creation process.&lt;/p&gt;

&lt;p&gt;C. Create an SCP to deny access to costly services and components. Apply the SCP to the developer accounts.&lt;/p&gt;

&lt;p&gt;D. Create an IAM policy to deny access to costly services and components. Apply the IAM policy to the developer accounts.&lt;/p&gt;

&lt;p&gt;E. Create an AWS Budgets alert action to terminate services when the budgeted amount is reached. Configure the action to terminate all services.&lt;/p&gt;

&lt;p&gt;F. Create an AWS Budgets alert action to send an Amazon Simple Notification Service (Amazon SNS) notification when the budgeted amount is reached. Invoke an AWS Lambda function to terminate all services.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer :&lt;/p&gt;

    &lt;p&gt;1차 시도 : &lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;내 생각엔&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-67&quot;&gt;Prob. 67&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A health insurance company stores&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer :&lt;/p&gt;

    &lt;p&gt;1차 시도 : &lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;내 생각엔&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-68&quot;&gt;Prob. 68&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A health insurance company stores&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer :&lt;/p&gt;

    &lt;p&gt;1차 시도 : &lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;내 생각엔&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-69&quot;&gt;Prob. 69&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A health insurance company stores&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer :&lt;/p&gt;

    &lt;p&gt;1차 시도 : &lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;내 생각엔&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-70&quot;&gt;Prob. 70&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A health insurance company stores&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer :&lt;/p&gt;

    &lt;p&gt;1차 시도 : &lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;내 생각엔&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;hr /&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Ref
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;https://www.examtopics.com/exams/amazon/aws-certified-solutions-architect-professional-sap-c02/view/13/&quot;&gt;ExamTopics&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Fri, 05 May 2023 17:00:00 +0900</pubDate>
        <link>https://hjy.today/study/AWS-_SAP-C02_ExamTopics_61~70.html</link>
        <guid isPermaLink="true">https://hjy.today/study/AWS-_SAP-C02_ExamTopics_61~70.html</guid>
        
        <category>aws</category>
        
        <category>sap-c02</category>
        
        
        <category>study</category>
        
      </item>
    
      <item>
        <title>[AWS] SAP-C02 ExamTopics 51~60</title>
        <description>&lt;p&gt;SAP-C02 기출 51~60번 문제를 풀어보자.&lt;br /&gt;
1차 4/10&lt;br /&gt;&lt;/p&gt;

&lt;!--more--&gt;

&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-51-&quot; id=&quot;markdown-toc-prob-51-&quot;&gt;Prob. 51 ❌&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-52-&quot; id=&quot;markdown-toc-prob-52-&quot;&gt;Prob. 52 ❌&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-53-&quot; id=&quot;markdown-toc-prob-53-&quot;&gt;Prob. 53 ❌&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-54-️&quot; id=&quot;markdown-toc-prob-54-️&quot;&gt;Prob. 54 ⭕️&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-55-️&quot; id=&quot;markdown-toc-prob-55-️&quot;&gt;Prob. 55 ⭕️&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-56-️&quot; id=&quot;markdown-toc-prob-56-️&quot;&gt;Prob. 56 ⭕️&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-57-️&quot; id=&quot;markdown-toc-prob-57-️&quot;&gt;Prob. 57 ⭕️&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-58-&quot; id=&quot;markdown-toc-prob-58-&quot;&gt;Prob. 58 ❌&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-59-&quot; id=&quot;markdown-toc-prob-59-&quot;&gt;Prob. 59 ❌&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-60-&quot; id=&quot;markdown-toc-prob-60-&quot;&gt;Prob. 60 ❌&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-51-&quot;&gt;Prob. 51 ❌&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A health insurance company stores personally identifiable information (PII) in an Amazon S3 bucket. The company uses server-side encryption with S3 managed encryption keys (SSE-S3) to encrypt the objects. According to a new requirement, all current and future objects in the S3 bucket must be encrypted by keys that the company’s security team manages. The S3 bucket does not have versioning enabled.&lt;/p&gt;

&lt;p&gt;Which solution will meet these requirements?&lt;/p&gt;

&lt;p&gt;A. In the S3 bucket properties, change the default encryption to SSE-S3 with a customer managed key. Use the AWS CLI to re-upload all objects in the S3 bucket. Set an S3 bucket policy to deny unencrypted PutObject requests.&lt;/p&gt;

&lt;p&gt;B. In the S3 bucket properties, change the default encryption to server-side encryption with AWS KMS managed encryption keys (SSE-KMS). Set an S3 bucket policy to deny unencrypted PutObject requests. Use the AWS CLI to re-upload all objects in the S3 bucket.&lt;/p&gt;

&lt;p&gt;C. In the S3 bucket properties, change the default encryption to server-side encryption with AWS KMS managed encryption keys (SSE-KMS). Set an S3 bucket policy to automatically encrypt objects on GetObject and PutObject requests.&lt;/p&gt;

&lt;p&gt;D. In the S3 bucket properties, change the default encryption to AES-256 with a customer managed key. Attach a policy to deny unencrypted PutObject requests to any entities that access the S3 bucket. Use the AWS CLI to re-upload all objects in the S3 bucket.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : B&lt;/p&gt;

    &lt;p&gt;1차 시도 : D &lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;내 생각엔 분명 D 인 것 같은데 … B라고 한다.&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-52-&quot;&gt;Prob. 52 ❌&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company is running a web application in the AWS Cloud. The application consists of dynamic content that is created on a set of Amazon EC2 instances. The EC2 instances run in an Auto Scaling group that is configured as a target group for an Application Load Balancer (ALB).&lt;/p&gt;

&lt;p&gt;The company is using an Amazon CloudFront distribution to distribute the application globally. The CloudFront distribution uses the ALB as an origin. The company uses Amazon Route 53 for DNS and has created an A record of www.example.com for the CloudFront distribution.&lt;/p&gt;

&lt;p&gt;A solutions architect must configure the application so that itis highly available and fault tolerant.&lt;/p&gt;

&lt;p&gt;Which solution meets these requirements?&lt;/p&gt;

&lt;p&gt;A. Provision a full, secondary application deployment in a different AWS Region. Update the Route 53 A record to be a failover record. Add both of the CloudFront distributions as values. Create Route 53 health checks.&lt;/p&gt;

&lt;p&gt;B. Provision an ALB, an Auto Scaling group, and EC2 instances in a different AWS Region. Update the CloudFront distribution, and create a second origin for the new ALCreate an origin group for the two origins. Configure one origin as primary and one origin as secondary.&lt;/p&gt;

&lt;p&gt;C. Provision an Auto Scaling group and EC2 instances in a different AWS Region. Create a second target for the new Auto Scaling group in the ALB. Set up the failover routing algorithm on the ALB.&lt;/p&gt;

&lt;p&gt;D. Provision a full, secondary application deployment in a different AWS Region. Create a second CloudFront distribution, and add the new application setup as an origin. Create an AWS Global Accelerator accelerator. Add both of the CloudFront distributions as endpoints.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : B&lt;/p&gt;

    &lt;p&gt;1차 시도 : A &lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;일단 A인 R53 페일오버 솔루션보단 B가 더 HA인 솔루션이라고 한다.&lt;/p&gt;

    &lt;p&gt;C에서 ALB는 지역 서비스이기 때문에, ALB도 추가되어야 한다고 한다.&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-53-&quot;&gt;Prob. 53 ❌&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company has an organization in AWS Organizations that has a large number of AWS accounts. One of the AWS accounts is designated as a transit account and has a transit gateway that is shared with all of the other AWS accounts. AWS Site-to-Site VPN connections are configured between all of the company’s global offices and the transit account. The company has AWS Config enabled on all of its accounts.&lt;/p&gt;

&lt;p&gt;The company’s networking team needs to centrally manage a list of internal IP address ranges that belong to the global offices. Developers will reference this list to gain access to their applications securely.&lt;/p&gt;

&lt;p&gt;Which solution meets these requirements with the LEAST amount of operational overhead?&lt;/p&gt;

&lt;p&gt;A. Create a JSON file that is hosted in Amazon S3 and that lists all of the internal IP address ranges. Configure an Amazon Simple Notification Service (Amazon SNS) topic in each of the accounts that can be invoked when the JSON file is updated. Subscribe an AWS Lambda function to the SNS topic to update all relevant security group rules with the updated IP address ranges.&lt;/p&gt;

&lt;p&gt;B. Create a new AWS Config managed rule that contains all of the internal IP address ranges. Use the rule to check the security groups in each of the accounts to ensure compliance with the list of IP address ranges. Configure the rule to automatically remediate any noncompliant security group that is detected.&lt;/p&gt;

&lt;p&gt;C. In the transit account, create a VPC prefix list with all of the internal IP address ranges. Use AWS Resource Access Manager to share the prefix list with all of the other accounts. Use the shared prefix list to configure security group rules in the other accounts.&lt;/p&gt;

&lt;p&gt;D. In the transit account, create a security group with all of the internal IP address ranges. Configure the security groups in the other accounts to reference the transit account’s security group by using a nested security group reference of “/sg-1a2b3c4d”.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : C&lt;/p&gt;

    &lt;p&gt;1차 시도 : A &lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;prefix list와 RAM을 이용하는것이 정답&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-54-️&quot;&gt;Prob. 54 ⭕️&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company runs a new application as a static website in Amazon S3. The company has deployed the application to a production AWS account and uses Amazon CloudFront to deliver the website. The website calls an Amazon API Gateway REST API. An AWS Lambda function backs each API method.&lt;/p&gt;

&lt;p&gt;The company wants to create a CSV report every 2 weeks to show each API Lambda function’s recommended configured memory, recommended cost, and the price difference between current configurations and the recommendations. The company will store the reports in an S3 bucket.&lt;/p&gt;

&lt;p&gt;Which solution will meet these requirements with the LEAST development time?&lt;/p&gt;

&lt;p&gt;A. Create a Lambda function that extracts metrics data for each API Lambda function from Amazon CloudWatch Logs for the 2-week period. Collate the data into tabular format. Store the data as a .csv file in an S3 bucket. Create an Amazon EventBridge rule to schedule the Lambda function to run every 2 weeks.&lt;/p&gt;

&lt;p&gt;B. Opt in to AWS Compute Optimizer. Create a Lambda function that calls the ExportLambdaFunctionRecommendations operation. Export the .csv file to an S3 bucket. Create an Amazon EventBridge rule to schedule the Lambda function to run every 2 weeks.&lt;/p&gt;

&lt;p&gt;C. Opt in to AWS Compute Optimizer. Set up enhanced infrastructure metrics. Within the Compute Optimizer console, schedule a job to export the Lambda recommendations to a .csv file. Store the file in an S3 bucket every 2 weeks.&lt;/p&gt;

&lt;p&gt;D. Purchase the AWS Business Support plan for the production account. Opt in to AWS Compute Optimizer for AWS Trusted Advisor checks. In the Trusted Advisor console, schedule a job to export the cost optimization checks to a .csv file. Store the file in an S3 bucket every 2 weeks.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : B&lt;/p&gt;

    &lt;p&gt;1차 시도 : B &lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;AWS Compute Optimizer와 Lambda을 사용한다.&lt;/p&gt;

    &lt;p&gt;그리고 Recommendation을 위해서는 람다를 사용해야한다.&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-55-️&quot;&gt;Prob. 55 ⭕️&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company’s factory and automation applications are running in a single VPC. More than 20 applications run on a combination of Amazon EC2, Amazon Elastic Container Service (Amazon ECS), and Amazon RDS.&lt;/p&gt;

&lt;p&gt;The company has software engineers spread across three teams. One of the three teams owns each application, and each time is responsible for the cost and performance of all of its applications. Team resources have tags that represent their application and team. The teams use IAM access for daily activities.&lt;/p&gt;

&lt;p&gt;The company needs to determine which costs on the monthly AWS bill are attributable to each application or team. The company also must be able to create reports to compare costs from the last 12 months and to help forecast costs for the next 12 months. A solutions architect must recommend an AWS Billing and Cost Management solution that provides these cost reports.&lt;/p&gt;

&lt;p&gt;Which combination of actions will meet these requirements? (Choose three.)&lt;/p&gt;

&lt;p&gt;A. Activate the user-define cost allocation tags that represent the application and the team.&lt;/p&gt;

&lt;p&gt;B. Activate the AWS generated cost allocation tags that represent the application and the team.&lt;/p&gt;

&lt;p&gt;C. Create a cost category for each application in Billing and Cost Management.&lt;/p&gt;

&lt;p&gt;D. Activate IAM access to Billing and Cost Management.&lt;/p&gt;

&lt;p&gt;E. Create a cost budget.&lt;/p&gt;

&lt;p&gt;F. Enable Cost Explorer.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer :&lt;/p&gt;

    &lt;p&gt;1차 시도 : A, C, F &lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;Enabling Cost Explorer at the management account level enables Cost Explorer for all of your organization accounts. All accounts in the organization are granted access, and you can’t grant or deny access individually.&lt;/p&gt;

    &lt;p&gt;A, F는 답이 확정인데 C냐 D냐에 대해 의견이 분분하다.&lt;br /&gt;
일단 나는 C로 ..&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-56-️&quot;&gt;Prob. 56 ⭕️&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;An AWS customer has a web application that runs on premises. The web application fetches data from a third-party API that is behind a firewall. The third party accepts only one public CIDR block in each client’s allow list.&lt;/p&gt;

&lt;p&gt;The customer wants to migrate their web application to the AWS Cloud. The application will be hosted on a set of Amazon EC2 instances behind an Application Load Balancer (ALB) in a VPC. The ALB is located in public subnets. The EC2 instances are located in private subnets. NAT gateways provide internet access to the private subnets.&lt;/p&gt;

&lt;p&gt;How should a solutions architect ensure that the web application can continue to call the third-party API after the migration?&lt;/p&gt;

&lt;p&gt;A. Associate a block of customer-owned public IP addresses to the VPC. Enable public IP addressing for public subnets in the VPC.&lt;/p&gt;

&lt;p&gt;B. Register a block of customer-owned public IP addresses in the AWS account. Create Elastic IP addresses from the address block and assign them to the NAT gateways in the VPC.&lt;/p&gt;

&lt;p&gt;C. Create Elastic IP addresses from the block of customer-owned IP addresses. Assign the static Elastic IP addresses to the ALB.&lt;/p&gt;

&lt;p&gt;D. Register a block of customer-owned public IP addresses in the AWS account. Set up AWS Global Accelerator to use Elastic IP addresses from the address block. Set the ALB as the accelerator endpoint.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : B&lt;/p&gt;

    &lt;p&gt;1차 시도 : B&lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;중요한건 서드파티에서 허용하는 IP 주소로 접근하는 것이다.&lt;br /&gt;
그러므로 customer-owned public IP를 AWS 계정에 등록하고, Elastic IP를 만들어서 NAT Gateway에 등록하면 된다.&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-57-️&quot;&gt;Prob. 57 ⭕️&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company with several AWS accounts is using AWS Organizations and service control policies (SCPs). An administrator created the following SCP and has attached it to an organizational unit (OU) that contains AWS account 1111-1111-1111:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_AWS/2023-05-01-[AWS]_SAP-C02_ExamTopics_51~60/1.png&quot; alt=&quot;1&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Developers working in account 1111-1111-1111 complain that they cannot create Amazon S3 buckets. How should the administrator address this problem?&lt;/p&gt;

&lt;p&gt;A. Add s3:CreateBucket with “Allow” effect to the SCP.&lt;/p&gt;

&lt;p&gt;B. Remove the account from the OU, and attach the SCP directly to account 1111-1111-1111.&lt;/p&gt;

&lt;p&gt;C. Instruct the developers to add Amazon S3 permissions to their IAM entities.&lt;/p&gt;

&lt;p&gt;D. Remove the SCP from account 1111-1111-1111.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : C&lt;/p&gt;

    &lt;p&gt;1차 시도 : C &lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;SCP는 Permission을 Grant 하지 않는다.&lt;br /&gt;
즉, SCP는 허가/비허가를 위한 가드레일/Boundary 같은 역할을 하는 것이지, 실질적인 권한 부여는 IAM 사용자 또는 역할에 대한 정책 부여로 하는 것이다.&lt;/p&gt;

    &lt;p&gt;즉, SCP로 모든 리소스에 대한 모든 액션을 허가 하였더라도, 이는 권한 부여가 아닌 단순한 허가일 뿐이기 때문에, 위 상황과 같은 경우 S3 Bucket Creation에 대한 권한이 Developer가 속한 IAM에 없기 때문에 발생한 것이다.&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-58-&quot;&gt;Prob. 58 ❌&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company has a monolithic application that is critical to the company’s business. The company hosts the application on an Amazon EC2 instance that runs Amazon Linux 2. The company’s application team receives a directive from the legal department to back up the data from the instance’s encrypted Amazon Elastic Block Store (Amazon EBS) volume to an Amazon S3 bucket. The application team does not have the administrative SSH key pair for the instance. The application must continue to serve the users.&lt;/p&gt;

&lt;p&gt;Which solution will meet these requirements?&lt;/p&gt;

&lt;p&gt;A. Attach a role to the instance with permission to write to Amazon S3. Use the AWS Systems Manager Session Manager option to gain access to the instance and run commands to copy data into Amazon S3.&lt;/p&gt;

&lt;p&gt;B. Create an image of the instance with the reboot option turned on. Launch a new EC2 instance from the image. Attach a role to the new instance with permission to write to Amazon S3. Run a command to copy data into Amazon S3.&lt;/p&gt;

&lt;p&gt;C. Take a snapshot of the EBS volume by using Amazon Data Lifecycle Manager (Amazon DLM). Copy the data to Amazon S3.&lt;/p&gt;

&lt;p&gt;D. Create an image of the instance. Launch a new EC2 instance from the image. Attach a role to the new instance with permission to write to Amazon S3. Run a command to copy data into Amazon S3.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : A&lt;/p&gt;

    &lt;p&gt;1차 시도 : C &lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Systems Manager Session Manager&lt;/code&gt; 는 SSH 키 없이 IAM Role 등으로 인스턴스에 접근할 수 있으며, 한 번 접근하면 모든 커맨드를 사용할 수 있다고 한다.&lt;br /&gt;
또한 EBS Snapshot, AMI를 생성할 수 있으며, 해당 작업을 할 때 인스턴스를 Shutdown 할 필요도 없다.&lt;br /&gt;
따라서 스냅샷을 생성, 커맨드를 통해 S3로 보낼 수 있다.&lt;/p&gt;

    &lt;p&gt;DLM의 경우 … 볼륨, 스냅샷을 생성하거나 하는 옵션들은 있지만 S3로 복사하는 옵션은 없다고 한다.&lt;br /&gt;
있다는 말도 있는데, 이 경우 아마존이 관리하는 S3로의 전송은 되나 내가 관리할 수 없다고 한다.&lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;그런데 … Discussion을 보다 보니 DLM이 EBS 볼륨을 다운타임 없이 백업하기 위한 서비스라고 하며, 딱 이런 케이스를 위한 것이라고 하는데 …&lt;br /&gt;
일단 A가 70%, C가 30% 정도의 비율이니 A로 가자.&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-59-&quot;&gt;Prob. 59 ❌&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A solutions architect needs to copy data from an Amazon S3 bucket m an AWS account to a new S3 bucket in a new AWS account. The solutions architect must implement a solution that uses the AWS CLI.&lt;/p&gt;

&lt;p&gt;Which combination of steps will successfully copy the data? (Choose three.)&lt;/p&gt;

&lt;p&gt;A. Create a bucket policy to allow the source bucket to list its contents and to put objects and set object ACLs in the destination bucket. Attach the bucket policy to the destination bucket.&lt;/p&gt;

&lt;p&gt;B. Create a bucket policy to allow a user in the destination account to list the source bucket’s contents and read the source bucket’s objects. Attach the bucket policy to the source bucket.&lt;/p&gt;

&lt;p&gt;C. Create an IAM policy in the source account. Configure the policy to allow a user in the source account to list contents and get objects in the source bucket, and to list contents, put objects, and set object ACLs in the destination bucket. Attach the policy to the user.&lt;/p&gt;

&lt;p&gt;D. Create an IAM policy in the destination account. Configure the policy to allow a user in the destination account to list contents and get objects in the source bucket, and to list contents, put objects, and set objectACLs in the destination bucket. Attach the policy to the user.&lt;/p&gt;

&lt;p&gt;E. Run the aws s3 sync command as a user in the source account. Specify the source and destination buckets to copy the data.&lt;/p&gt;

&lt;p&gt;F. Run the aws s3 sync command as a user in the destination account. Specify the source and destination buckets to copy the data.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : B, D, F&lt;/p&gt;

    &lt;p&gt;1차 시도 : A, B, E &lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;데이터를 쓰는 사람의 관점에서 봐야한다.&lt;br /&gt;
즉, 데이터를 쓰는(받아오는) 계정인 destination 계정에서는 source S3 bucket에 대한 접근 가능한 정책이 허용되어야 한다.&lt;br /&gt;
다음으로, destination 계정이 source 버킷으로부터 데이터를 가져올 수 있도록 IAM 정책을 구성해야한다.&lt;br /&gt;
F도 마찬가지다. 데이터를 쓰는 계정인 destination에서 실행해야한다.&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-60-&quot;&gt;Prob. 60 ❌&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company built an application based on AWS Lambda deployed in an AWS CloudFormation stack. The last production release of the web application introduced an issue that resulted in an outage lasting several minutes. A solutions architect must adjust the deployment process to support a canary release.&lt;/p&gt;

&lt;p&gt;Which solution will meet these requirements?&lt;/p&gt;

&lt;p&gt;A. Create an alias for every new deployed version of the Lambda function. Use the AWS CLI update-alias command with the routing-config parameter to distribute the load.&lt;/p&gt;

&lt;p&gt;B. Deploy the application into a new CloudFormation stack. Use an Amazon Route 53 weighted routing policy to distribute the load.&lt;/p&gt;

&lt;p&gt;C. Create a version for every new deployed Lambda function. Use the AWS CLI update-function-configuration command with the routing-config parameter to distribute the load.&lt;/p&gt;

&lt;p&gt;D. Configure AWS CodeDeploy and use CodeDeployDefault.OneAtATime in the Deployment configuration to distribute the load.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : A&lt;/p&gt;

    &lt;p&gt;1차 시도 : D &lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;aws update-alias command has routing-config option to route the weighted % traffic As is correct&lt;/p&gt;

    &lt;p&gt;https://aws.amazon.com/blogs/compute/implementing-canary-deployments-of-aws-lambda-functions-with-alias-traffic-shifting/&lt;/p&gt;

    &lt;p&gt;Point alias to new version, weighted at 5% (original version at 95% of traffic) aws lambda update-alias –function-name myfunction –name myalias –routing-config ‘{“AdditionalVersionWeights” : {“2” : 0.05} }’&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;hr /&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Ref
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;https://www.examtopics.com/exams/amazon/aws-certified-solutions-architect-professional-sap-c02/view/13/&quot;&gt;ExamTopics&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Mon, 01 May 2023 19:00:00 +0900</pubDate>
        <link>https://hjy.today/study/AWS-_SAP-C02_ExamTopics_51~60.html</link>
        <guid isPermaLink="true">https://hjy.today/study/AWS-_SAP-C02_ExamTopics_51~60.html</guid>
        
        <category>aws</category>
        
        <category>sap-c02</category>
        
        
        <category>study</category>
        
      </item>
    
      <item>
        <title>[AWS] SAP-C02 ExamTopics 41~50</title>
        <description>&lt;p&gt;SAP-C02 기출 41~50번 문제를 풀어보자.&lt;br /&gt;
1차 4/10&lt;br /&gt;
2차 8/10&lt;br /&gt;
3차 9/10&lt;br /&gt;&lt;/p&gt;

&lt;!--more--&gt;

&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-41-️️️&quot; id=&quot;markdown-toc-prob-41-️️️&quot;&gt;Prob. 41 ⭕️⭕️⭕️&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-42-️️&quot; id=&quot;markdown-toc-prob-42-️️&quot;&gt;Prob. 42 ❌⭕️⭕️&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-43-️️️&quot; id=&quot;markdown-toc-prob-43-️️️&quot;&gt;Prob. 43 ⭕️⭕️⭕️&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-44-&quot; id=&quot;markdown-toc-prob-44-&quot;&gt;Prob. 44 ❌❌❌&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-45-️️&quot; id=&quot;markdown-toc-prob-45-️️&quot;&gt;Prob. 45 ❌⭕️⭕️&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-46-️️&quot; id=&quot;markdown-toc-prob-46-️️&quot;&gt;Prob. 46 ⭕️❌⭕️&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-47-️️&quot; id=&quot;markdown-toc-prob-47-️️&quot;&gt;Prob. 47 ❌⭕️⭕️&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-48-️️&quot; id=&quot;markdown-toc-prob-48-️️&quot;&gt;Prob. 48 ❌⭕️⭕️&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-49-️️&quot; id=&quot;markdown-toc-prob-49-️️&quot;&gt;Prob. 49 ❌⭕️⭕️&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-50-️️️&quot; id=&quot;markdown-toc-prob-50-️️️&quot;&gt;Prob. 50 ⭕️⭕️⭕️&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-41-️️️&quot;&gt;Prob. 41 ⭕️⭕️⭕️&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company recently deployed an application on AWS. The application uses Amazon DynamoDB. The company measured the application load and configured the RCUs and WCUs on the DynamoDB table to match the expected peak load. The peak load occurs once a week for a 4-hour period and is double the average load. The application load is close to the average load for the rest of the week. The access pattern includes many more writes to the table than reads of the table.&lt;/p&gt;

&lt;p&gt;A solutions architect needs to implement a solution to minimize the cost of the table.&lt;/p&gt;

&lt;p&gt;Which solution will meet these requirements?&lt;/p&gt;

&lt;p&gt;A. Use AWS Application Auto Scaling to increase capacity during the peak period. Purchase reserved RCUs and WCUs to match the average load.&lt;/p&gt;

&lt;p&gt;B. Configure on-demand capacity mode for the table.&lt;/p&gt;

&lt;p&gt;C. Configure DynamoDB Accelerator (DAX) in front of the table. Reduce the provisioned read capacity to match the new peak load on the table.&lt;/p&gt;

&lt;p&gt;D. Configure DynamoDB Accelerator (DAX) in front of the table. Configure on-demand capacity mode for the table.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : A&lt;/p&gt;

    &lt;p&gt;1차 시도 : A &lt;br /&gt;
2차 시도 : A &lt;br /&gt;
3차 시도 : A &lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;일단 읽기보다 쓰기가 더 많기 때문에, 캐싱을 사용하는 DAX는 답이 될 수 없다.&lt;br /&gt;
예측할 수 없는 워크로드에 쓰이는 on demand 보다는 예상 주기와 상승폭이 일정하므로 A, reserved를 고르는 것이 적절하다.&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-42-️️&quot;&gt;Prob. 42 ❌⭕️⭕️&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A solutions architect needs to advise a company on how to migrate its on-premises data processing application to the AWS Cloud. Currently, users upload input files through a web portal. The web server then stores the uploaded files on NAS and messages the processing server over a message queue. Each media file can take up to 1 hour to process. The company has determined that the number of media files awaiting processing is significantly higher during business hours, with the number of files rapidly declining after business hours.&lt;/p&gt;

&lt;p&gt;What is the MOST cost-effective migration recommendation?&lt;/p&gt;

&lt;p&gt;A. Create a queue using Amazon SQS. Configure the existing web server to publish to the new queue. When there are messages in the queue, invoke an AWS Lambda function to pull requests from the queue and process the files. Store the processed files in an Amazon S3 bucket.&lt;/p&gt;

&lt;p&gt;B. Create a queue using Amazon MQ. Configure the existing web server to publish to the new queue. When there are messages in the queue, create a new Amazon EC2 instance to pull requests from the queue and process the files. Store the processed files in Amazon EFS. Shut down the EC2 instance after the task is complete.&lt;/p&gt;

&lt;p&gt;C. Create a queue using Amazon MQ. Configure the existing web server to publish to the new queue. When there are messages in the queue, invoke an AWS Lambda function to pull requests from the queue and process the files. Store the processed files in Amazon EFS.&lt;/p&gt;

&lt;p&gt;D. Create a queue using Amazon SQS. Configure the existing web server to publish to the new queue. Use Amazon EC2 instances in an EC2 Auto Scaling group to pull requests from the queue and process the files. Scale the EC2 instances based on the SQS queue length. Store the processed files in an Amazon S3 bucket.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : D&lt;/p&gt;

    &lt;p&gt;1차 시도 : A &lt;br /&gt;
2차 시도 : D &lt;br /&gt;
3차 시도 : D &lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;A가 안되는 이유 : 람다는 기본적으로 15분동안의 유지시간을 가지기 때문에, 파일을 업로드하는 시간이 최대 1시간이라고 하였으므로 틀렸다.&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-43-️️️&quot;&gt;Prob. 43 ⭕️⭕️⭕️&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company is using Amazon OpenSearch Service to analyze data. The company loads data into an OpenSearch Service cluster with 10 data nodes from an Amazon S3 bucket that uses S3 Standard storage. The data resides in the cluster for 1 month for read-only analysis. After 1 month, the company deletes the index that contains the data from the cluster. For compliance purposes, the company must retain a copy of all input data.&lt;/p&gt;

&lt;p&gt;The company is concerned about ongoing costs and asks a solutions architect to recommend a new solution.&lt;/p&gt;

&lt;p&gt;Which solution will meet these requirements MOST cost-effectively?&lt;/p&gt;

&lt;p&gt;A. Replace all the data nodes with UltraWarm nodes to handle the expected capacity. Transition the input data from S3 Standard to S3 Glacier Deep Archive when the company loads the data into the cluster.&lt;/p&gt;

&lt;p&gt;B. Reduce the number of data nodes in the cluster to 2 Add UltraWarm nodes to handle the expected capacity. Configure the indexes to transition to UltraWarm when OpenSearch Service ingests the data. Transition the input data to S3 Glacier Deep Archive after 1 month by using an S3 Lifecycle policy.&lt;/p&gt;

&lt;p&gt;C. Reduce the number of data nodes in the cluster to 2. Add UltraWarm nodes to handle the expected capacity. Configure the indexes to transition to UltraWarm when OpenSearch Service ingests the data. Add cold storage nodes to the cluster Transition the indexes from UltraWarm to cold storage. Delete the input data from the S3 bucket after 1 month by using an S3 Lifecycle policy.&lt;/p&gt;

&lt;p&gt;D. Reduce the number of data nodes in the cluster to 2. Add instance-backed data nodes to handle the expected capacity. Transition the input data from S3 Standard to S3 Glacier Deep Archive when the company loads the data into the cluster.&lt;/p&gt;
&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : B&lt;/p&gt;

    &lt;p&gt;1차 시도 : B&lt;br /&gt;
2차 시도 : B&lt;br /&gt;
3차 시도 : B&lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;옵션 B는 요구사항을 충족하는 가장 비용 효율적인 솔루션입니다. 
클러스터의 데이터 노드 수를 줄이고 UltraWarm 노드를 추가하면 OpenSearch 서비스 클러스터를 실행하는 데 드는 지속적인 비용을 절감할 수 있습니다. 
OpenSearch Service가 데이터를 수집할 때 인덱스를 UltraWarm으로 전환하도록 구성하면 비용이 더욱 절감됩니다. 
또한 S3 라이프사이클 정책을 사용하여 1개월 후에 입력 데이터를 S3 Glacier Deep Archive로 전환하면 규정 준수를 위해 입력 데이터를 보관하는 스토리지 비용이 절감됩니다.&lt;/p&gt;
  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-44-&quot;&gt;Prob. 44 ❌❌❌&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company has 10 accounts that are part of an organization in AWS Organizations. AWS Config is configured in each account. All accounts belong to either the Prod OU or the NonProd OU.&lt;/p&gt;

&lt;p&gt;The company has set up an Amazon EventBridge rule in each AWS account to notify an Amazon Simple Notification Service (Amazon SNS) topic when an Amazon EC2 security group inbound rule is created with 0.0.0.0/0 as the source. The company’s security team is subscribed to the SNS topic.&lt;/p&gt;

&lt;p&gt;For all accounts in the NonProd OU, the security team needs to remove the ability to create a security group inbound rule that includes 0.0.0.0/0 as the source.&lt;/p&gt;

&lt;p&gt;Which solution will meet this requirement with the LEAST operational overhead?&lt;/p&gt;

&lt;p&gt;A. Modify the EventBridge rule to invoke an AWS Lambda function to remove the security group inbound rule and to publish to the SNS topic. Deploy the updated rule to the NonProd OU.&lt;/p&gt;

&lt;p&gt;B. Add the vpc-sg-open-only-to-authorized-ports AWS Config managed rule to the NonProd OU.&lt;/p&gt;

&lt;p&gt;C. Configure an SCP to allow the ec2:AuthorizeSecurityGroupIngress action when the value of the aws:SourceIp condition key is not 0.0.0.0/0. Apply the SCP to the NonProd OU.&lt;/p&gt;

&lt;p&gt;D. Configure an SCP to deny the ec2:AuthorizeSecurityGroupIngress action when the value of the aws:SourceIp condition key is 0.0.0.0/0. Apply the SCP to the NonProd OU.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : A&lt;/p&gt;

    &lt;p&gt;1차 시도 : D&lt;br /&gt;
2차 시도 : D&lt;br /&gt;
3차 시도 : B&lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;D라고 생각했는데, AuthorizeSecurityGroupIngress 에는 ip 주소의 인바운드/아웃바운드를 제어하는 옵션이 없다고 한다.&lt;/p&gt;

    &lt;p&gt;3차 - B라고 생각했는데, 안되는 이유는 모르겠다 … A는 아무리 봐도 억지같은데 …&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-45-️️&quot;&gt;Prob. 45 ❌⭕️⭕️&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company hosts a Git repository in an on-premises data center. The company uses webhooks to invoke functionality that runs in the AWS Cloud. The company hosts the webhook logic on a set of Amazon EC2 instances in an Auto Scaling group that the company set as a target for an Application Load Balancer (ALB). The Git server calls the ALB for the configured webhooks. The company wants to move the solution to a serverless architecture.&lt;/p&gt;

&lt;p&gt;Which solution will meet these requirements with the LEAST operational overhead?&lt;/p&gt;

&lt;p&gt;A. For each webhook, create and configure an AWS Lambda function URL. Update the Git servers to call the individual Lambda function URLs.&lt;/p&gt;

&lt;p&gt;B. Create an Amazon API Gateway HTTP API. Implement each webhook logic in a separate AWS Lambda function. Update the Git servers to call the API Gateway endpoint.&lt;/p&gt;

&lt;p&gt;C. Deploy the webhook logic to AWS App Runner. Create an ALB, and set App Runner as the target. Update the Git servers to call the ALB endpoint.&lt;/p&gt;

&lt;p&gt;D. Containerize the webhook logic. Create an Amazon Elastic Container Service (Amazon ECS) cluster, and run the webhook logic in AWS Fargate. Create an Amazon API Gateway REST API, and set Fargate as the target. Update the Git servers to call the API Gateway endpoint.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : B&lt;/p&gt;

    &lt;p&gt;1차 시도 : A&lt;br /&gt;
2차 시도 : B&lt;br /&gt;
3차 시도 : B&lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;람다 + API 게이트웨이를 활용하면 webhook을 쉽게 구현할 수 있다고 한다.&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-46-️️&quot;&gt;Prob. 46 ⭕️❌⭕️&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company is planning to migrate 1,000 on-premises servers to AWS. The servers run on several VMware clusters in the company’s data center. As part of the migration plan, the company wants to gather server metrics such as CPU details, RAM usage, operating system information, and running processes. The company then wants to query and analyze the data.&lt;/p&gt;

&lt;p&gt;Which solution will meet these requirements?&lt;/p&gt;

&lt;p&gt;A. Deploy and configure the AWS Agentless Discovery Connector virtual appliance on the on-premises hosts. Configure Data Exploration in AWS Migration Hub. Use AWS Glue to perform an ETL job against the data. Query the data by using Amazon S3 Select.&lt;/p&gt;

&lt;p&gt;B. Export only the VM performance information from the on-premises hosts. Directly import the required data into AWS Migration Hub. Update any missing information in Migration Hub. Query the data by using Amazon QuickSight.&lt;/p&gt;

&lt;p&gt;C. Create a script to automatically gather the server information from the on-premises hosts. Use the AWS CLI to run the put-resource-attributes command to store the detailed server data in AWS Migration Hub. Query the data directly in the Migration Hub console.&lt;/p&gt;

&lt;p&gt;D. Deploy the AWS Application Discovery Agent to each on-premises server. Configure Data Exploration in AWS Migration Hub. Use Amazon Athena to run predefined queries against the data in Amazon S3.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : D&lt;/p&gt;

    &lt;p&gt;1차 시도 : D&lt;br /&gt;
2차 시도 : C&lt;br /&gt;
3차 시도 : D&lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;1000개의 온프레미스 서버에 각각 Discovery Agent를 배포한다는게 좋지 않은 방법이라고 생각했으나 … D가 정답이었다.
데이터를 분석하는것도 Athena에 걸맞다.
의심하지 말아야겠다.&lt;/p&gt;

    &lt;p&gt;A. Agentless는 프로세스를 수집할 수 없다고 한다. CPU/RAM, disk IO 만 읽을 수 있다고 함.&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-47-️️&quot;&gt;Prob. 47 ❌⭕️⭕️&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company is building a serverless application that runs on an AWS Lambda function that is attached to a VPC. The company needs to integrate the application with a new service from an external provider. The external provider supports only requests that come from public IPv4 addresses that are in an allow list.&lt;/p&gt;

&lt;p&gt;The company must provide a single public IP address to the external provider before the application can start using the new service.&lt;/p&gt;

&lt;p&gt;Which solution will give the application the ability to access the new service?&lt;/p&gt;

&lt;p&gt;A. Deploy a NAT gateway. Associate an Elastic IP address with the NAT gateway. Configure the VPC to use the NAT gateway.&lt;/p&gt;

&lt;p&gt;B. Deploy an egress-only internet gateway. Associate an Elastic IP address with the egress-only internet gateway. Configure the elastic network interface on the Lambda function to use the egress-only internet gateway.&lt;/p&gt;

&lt;p&gt;C. Deploy an internet gateway. Associate an Elastic IP address with the internet gateway. Configure the Lambda function to use the internet gateway.&lt;/p&gt;

&lt;p&gt;D. Deploy an internet gateway. Associate an Elastic IP address with the internet gateway. Configure the default route in the public VPC route table to use the internet gateway.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : A&lt;/p&gt;

    &lt;p&gt;1차 시도 : D&lt;br /&gt;
2차 시도 : A&lt;br /&gt;
3차 시도 : A&lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;일단 Internet Gateway는 EIP를 가질 수 없다고 한다.&lt;br /&gt;
또한 Engress는 IPv6으로 통신하다고 한다.&lt;/p&gt;

    &lt;p&gt;“기본적으로 람다 함수는 공용 인터넷에 액세스할 수 있습니다. VPC 중 하나에 액세스할 수 있도록 구성된 경우에는 그렇지 않습니다. 인터넷의 리소스에 계속 액세스해야 하는 경우 NAT 인스턴스 또는 Amazon NAT 게이트웨이를 설정합니다. 또는 VPC 엔드포인트를 사용하여 VPC와 지원되는 AWS 서비스 간의 프라이빗 통신을 지원할 수도 있습니다.”&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-48-️️&quot;&gt;Prob. 48 ❌⭕️⭕️&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A solutions architect has developed a web application that uses an Amazon API Gateway Regional endpoint and an AWS Lambda function. The consumers of the web application are all close to the AWS Region where the application will be deployed. The Lambda function only queries an Amazon Aurora MySQL database. The solutions architect has configured the database to have three read replicas.&lt;/p&gt;

&lt;p&gt;During testing, the application does not meet performance requirements. Under high load, the application opens a large number of database connections. The solutions architect must improve the application’s performance.&lt;/p&gt;

&lt;p&gt;Which actions should the solutions architect take to meet these requirements? (Choose two.)&lt;/p&gt;

&lt;p&gt;A. Use the cluster endpoint of the Aurora database.&lt;/p&gt;

&lt;p&gt;B. Use RDS Proxy to set up a connection pool to the reader endpoint of the Aurora database.&lt;/p&gt;

&lt;p&gt;C. Use the Lambda Provisioned Concurrency feature.&lt;/p&gt;

&lt;p&gt;D. Move the code for opening the database connection in the Lambda function outside of the event handler.&lt;/p&gt;

&lt;p&gt;E. Change the API Gateway endpoint to an edge-optimized endpoint.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : B, D&lt;/p&gt;

    &lt;p&gt;1차 시도 : 모름&lt;br /&gt;
2차 시도 : B, D&lt;br /&gt;
3차 시도 : B, D&lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;RDS Proxy와 Lambda function을 사용한다.&lt;/p&gt;

    &lt;p&gt;RDX proxy &amp;amp; connecting outside the handler method is up to 5 times faster than connecting inside.&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-49-️️&quot;&gt;Prob. 49 ❌⭕️⭕️&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company is planning to host a web application on AWS and wants to load balance the traffic across a group of Amazon EC2 instances. One of the security requirements is to enable end-to-end encryption in transit between the client and the web server.&lt;/p&gt;

&lt;p&gt;Which solution will meet this requirement?&lt;/p&gt;

&lt;p&gt;A. Place the EC2 instances behind an Application Load Balancer (ALB). Provision an SSL certificate using AWS Certificate Manager (ACM), and associate the SSL certificate with the ALB. Export the SSL certificate and install it on each EC2 instance. Configure the ALB to listen on port 443 and to forward traffic to port 443 on the instances.&lt;/p&gt;

&lt;p&gt;B. Associate the EC2 instances with a target group. Provision an SSL certificate using AWS Certificate Manager (ACM). Create an Amazon CloudFront distribution and configure it to use the SSL certificate. Set CloudFront to use the target group as the origin server.&lt;/p&gt;

&lt;p&gt;C. Place the EC2 instances behind an Application Load Balancer (ALB) Provision an SSL certificate using AWS Certificate Manager (ACM), and associate the SSL certificate with the ALB. Provision a third-party SSL certificate and install it on each EC2 instance. Configure the ALB to listen on port 443 and to forward traffic to port 443 on the instances.&lt;/p&gt;

&lt;p&gt;D. Place the EC2 instances behind a Network Load Balancer (NLB). Provision a third-party SSL certificate and install it on the NLB and on each EC2 instance. Configure the NLB to listen on port 443 and to forward traffic to port 443 on the instances.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : C&lt;/p&gt;

    &lt;p&gt;1차 시도 : A&lt;br /&gt;
2차 시도 : C&lt;br /&gt;
3차 시도 : C&lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;&lt;a href=&quot;https://repost.aws/knowledge-center/acm-ssl-certificate-ec2-elb&quot;&gt;https://repost.aws/knowledge-center/acm-ssl-certificate-ec2-elb&lt;/a&gt;&lt;/p&gt;

    &lt;p&gt;EC2에는 public certificates를 설치할 수 없다고 한다.&lt;br /&gt;
따라서, 써드파티 certificate를 EC2에 설치한다. 그리고 써드파티 certificate를 AWS Certificate Manager를 통해 import 함으로써 로드밸런서와 연결시킨다.&lt;/p&gt;

    &lt;p&gt;D가 답이라는 의견도 많지만… 일단 C로 한다.&lt;/p&gt;
  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-50-️️️&quot;&gt;Prob. 50 ⭕️⭕️⭕️&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company wants to migrate its data analytics environment from on premises to AWS. The environment consists of two simple Node.js applications. One of the applications collects sensor data and loads it into a MySQL database. The other application aggregates the data into reports. When the aggregation jobs run, some of the load jobs fail to run correctly.&lt;/p&gt;

&lt;p&gt;The company must resolve the data loading issue. The company also needs the migration to occur without interruptions or changes for the company’s customers.&lt;/p&gt;

&lt;p&gt;What should a solutions architect do to meet these requirements?&lt;/p&gt;

&lt;p&gt;A. Set up an Amazon Aurora MySQL database as a replication target for the on-premises database. Create an Aurora Replica for the Aurora MySQL database, and move the aggregation jobs to run against the Aurora Replica. Set up collection endpoints as AWS Lambda functions behind a Network Load Balancer (NLB), and use Amazon RDS Proxy to write to the Aurora MySQL database. When the databases are synced, disable the replication job and restart the Aurora Replica as the primary instance. Point the collector DNS record to the NLB.&lt;/p&gt;

&lt;p&gt;B. Set up an Amazon Aurora MySQL database. Use AWS Database Migration Service (AWS DMS) to perform continuous data replication from the on-premises database to Aurora. Move the aggregation jobs to run against the Aurora MySQL database. Set up collection endpoints behind an Application Load Balancer (ALB) as Amazon EC2 instances in an Auto Scaling group. When the databases are synced, point the collector DNS record to the ALDisable the AWS DMS sync task after the cutover from on premises to AWS.&lt;/p&gt;

&lt;p&gt;C. Set up an Amazon Aurora MySQL database. Use AWS Database Migration Service (AWS DMS) to perform continuous data replication from the on-premises database to Aurora. Create an Aurora Replica for the Aurora MySQL database, and move the aggregation jobs to run against the Aurora Replica. Set up collection endpoints as AWS Lambda functions behind an Application Load Balancer (ALB), and use Amazon RDS Proxy to write to the Aurora MySQL database. When the databases are synced, point the collector DNS record to the ALB. Disable the AWS DMS sync task after the cutover from on premises to AWS.&lt;/p&gt;

&lt;p&gt;D. Set up an Amazon Aurora MySQL database. Create an Aurora Replica for the Aurora MySQL database, and move the aggregation jobs to run against the Aurora Replica. Set up collection endpoints as an Amazon Kinesis data stream. Use Amazon Kinesis Data Firehose to replicate the data to the Aurora MySQL database. When the databases are synced, disable the replication job and restart the Aurora Replica as the primary instance. Point the collector DNS record to the Kinesis data stream.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : C&lt;/p&gt;

    &lt;p&gt;1차 시도 : C&lt;br /&gt;
2차 시도 : C&lt;br /&gt;
3차 시도 : C&lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;마이그레이션을 위해서 AWS Database Migration Service를 이용한다.&lt;br /&gt;
그리고 Aggregation은 읽는 작업이므로 Aurora Replica를 생성하여 읽기 작업을 시킨다.&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;hr /&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Ref
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;https://www.examtopics.com/exams/amazon/aws-certified-solutions-architect-professional-sap-c02/view/11/&quot;&gt;ExamTopics&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Thu, 30 Mar 2023 21:00:00 +0900</pubDate>
        <link>https://hjy.today/study/AWS-_SAP-C02_ExamTopics_41~50.html</link>
        <guid isPermaLink="true">https://hjy.today/study/AWS-_SAP-C02_ExamTopics_41~50.html</guid>
        
        <category>aws</category>
        
        <category>sap-c02</category>
        
        
        <category>study</category>
        
      </item>
    
      <item>
        <title>[AWS] SAP-C02 ExamTopics 31~40</title>
        <description>&lt;p&gt;SAP-C02 기출 31~40번 문제를 풀어보자.&lt;br /&gt;
1차 4/10&lt;br /&gt;
2차 9/10&lt;br /&gt;&lt;/p&gt;

&lt;!--more--&gt;

&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-31-️&quot; id=&quot;markdown-toc-prob-31-️&quot;&gt;Prob. 31 ❌⭕️&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-32-️️&quot; id=&quot;markdown-toc-prob-32-️️&quot;&gt;Prob. 32 ⭕️⭕️&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-33-&quot; id=&quot;markdown-toc-prob-33-&quot;&gt;Prob. 33 ❌❌&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-34-️️&quot; id=&quot;markdown-toc-prob-34-️️&quot;&gt;Prob. 34 ⭕️⭕️&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-35-️️&quot; id=&quot;markdown-toc-prob-35-️️&quot;&gt;Prob. 35 ⭕️⭕️&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-36-️&quot; id=&quot;markdown-toc-prob-36-️&quot;&gt;Prob. 36 ❌⭕️&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-37-️&quot; id=&quot;markdown-toc-prob-37-️&quot;&gt;Prob. 37 ❌⭕️&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-38-️️&quot; id=&quot;markdown-toc-prob-38-️️&quot;&gt;Prob. 38 ⭕️⭕️&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-39-️&quot; id=&quot;markdown-toc-prob-39-️&quot;&gt;Prob. 39 ❌⭕️&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-40-️&quot; id=&quot;markdown-toc-prob-40-️&quot;&gt;Prob. 40 ❌⭕️&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-31-️&quot;&gt;Prob. 31 ❌⭕️&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;An enterprise company wants to allow its developers to purchase third-party software through AWS Marketplace. The company uses an AWS Organizations account structure with full features enabled, and has a shared services account in each organizational unit (OU) that will be used by procurement managers. The procurement team’s policy indicates that developers should be able to obtain third-party software from an approved list only and use Private Marketplace in AWS Marketplace to achieve this requirement. The procurement team wants administration of Private Marketplace to be restricted to a role named procurement-manager-role, which could be assumed by procurement managers. Other IAM users, groups, roles, and account administrators in the company should be denied Private Marketplace administrative access.&lt;br /&gt;
What is the MOST efficient way to design an architecture to meet these requirements?&lt;/p&gt;

&lt;p&gt;A. Create an IAM role named procurement-manager-role in all AWS accounts in the organization. Add the PowerUserAccess managed policy to the role. Apply an inline policy to all IAM users and roles in every AWS account to deny permissions on the AWSPrivateMarketplaceAdminFullAccess managed policy.&lt;/p&gt;

&lt;p&gt;B. Create an IAM role named procurement-manager-role in all AWS accounts in the organization. Add the AdministratorAccess managed policy to the role. Define a permissions boundary with the AWSPrivateMarketplaceAdminFullAccess managed policy and attach it to all the developer roles.&lt;/p&gt;

&lt;p&gt;C. Create an IAM role named procurement-manager-role in all the shared services accounts in the organization. Add the AWSPrivateMarketplaceAdminFullAccess managed policy to the role. Create an organization root-level SCP to deny permissions to administer Private Marketplace to everyone except the role named procurement-manager-role. Create another organization root-level SCP to deny permissions to create an IAM role named procurement-manager-role to everyone in the organization.&lt;/p&gt;

&lt;p&gt;D. Create an IAM role named procurement-manager-role in all AWS accounts that will be used by developers. Add the AWSPrivateMarketplaceAdminFullAccess managed policy to the role. Create an SCP in Organizations to deny permissions to administer Private Marketplace to everyone except the role named procurement-manager-role. Apply the SCP to all the shared services accounts in the organization.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : C&lt;/p&gt;

    &lt;p&gt;1차 시도 : D &lt;br /&gt;
2차 시도 : C &lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;SCP는 필터링 역할만 한다고 착각했다.&lt;br /&gt;
그것은 허가 목록과 거부 목록에 한한 것이고, 이런식으로 따로 특정 IAM Role 만을 제외하고도 적용할 수 있는 SCP를 만들어 적용할 수 있다.&lt;br /&gt;&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-32-️️&quot;&gt;Prob. 32 ⭕️⭕️&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company is in the process of implementing AWS Organizations to constrain its developers to use only Amazon EC2, Amazon S3, and Amazon DynamoDB. The developers account resides in a dedicated organizational unit (OU). The solutions architect has implemented the following SCP on the developers account:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_AWS/2023-03-21-[AWS]_SAP-C02_ExamTopics_31~40/1.png&quot; alt=&quot;1&quot; /&gt;&lt;/p&gt;

&lt;p&gt;When this policy is deployed, IAM users in the developers account are still able to use AWS services that are not listed in the policy.&lt;br /&gt;
What should the solutions architect do to eliminate the developers’ ability to use services outside the scope of this policy?&lt;/p&gt;

&lt;p&gt;A. Create an explicit deny statement for each AWS service that should be constrained.&lt;/p&gt;

&lt;p&gt;B. Remove the FullAWSAccess SCP from the developers account’s OU.&lt;/p&gt;

&lt;p&gt;C. Modify the FullAWSAccess SCP to explicitly deny all services.&lt;/p&gt;

&lt;p&gt;D. Add an explicit deny statement using a wildcard to the end of the SCP.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : B&lt;/p&gt;

    &lt;p&gt;1차 시도 : B &lt;br /&gt;
2차 시도 : B &lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;기본적으로 적용되고 있는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FullAWSAccess&lt;/code&gt; SCP를 제거하면, 기본적으로 모두 묵시적으로 접근할 수 없는 상태가 되므로 위 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;허가 목록&lt;/code&gt; 에 명시된 서비스에만 접근할 수 있게 된다.&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-33-&quot;&gt;Prob. 33 ❌❌&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company is hosting a monolithic REST-based API for a mobile app on five Amazon EC2 instances in public subnets of a VPC. Mobile clients connect to the API by using a domain name that is hosted on Amazon Route 53. The company has created a Route 53 multivalue answer routing policy with the IP addresses of all the EC2 instances. Recently, the app has been overwhelmed by large and sudden increases to traffic. The app has not been able to keep up with the traffic.
A solutions architect needs to implement a solution so that the app can handle the new and varying load.&lt;br /&gt;
Which solution will meet these requirements with the LEAST operational overhead?&lt;/p&gt;

&lt;p&gt;A. Separate the API into individual AWS Lambda functions. Configure an Amazon API Gateway REST API with Lambda integration for the backend. Update the Route 53 record to point to the API Gateway API.&lt;/p&gt;

&lt;p&gt;B. Containerize the API logic. Create an Amazon Elastic Kubernetes Service (Amazon EKS) cluster. Run the containers in the cluster by using Amazon EC2. Create a Kubernetes ingress. Update the Route 53 record to point to the Kubernetes ingress.&lt;/p&gt;

&lt;p&gt;C. Create an Auto Scaling group. Place all the EC2 instances in the Auto Scaling group. Configure the Auto Scaling group to perform scaling actions that are based on CPU utilization. Create an AWS Lambda function that reacts to Auto Scaling group changes and updates the Route 53 record.&lt;/p&gt;

&lt;p&gt;D. Create an Application Load Balancer (ALB) in front of the API. Move the EC2 instances to private subnets in the VPC. Add the EC2 instances as targets for the ALB. Update the Route 53 record to point to the ALB.&lt;/p&gt;
&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : A&lt;/p&gt;

    &lt;p&gt;1차 시도 : D&lt;br /&gt;
2차 시도 : C&lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;C의 경우, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Auto Scaling group&lt;/code&gt; 에 변화나 업데이트가 있다면 그 때마다 람다 함수가 반응하게 되므로, 이는 곧 문제에서 요구하는 LEAST operational overhead를 위배하게 된다.&lt;/p&gt;

    &lt;p&gt;D의 경우, EC2 인스턴스가 public 서브넷에 존재하기 때문에 이를 private으로 옮기면 NAT gateway와 같은 추가적인 overhead를 발생시킨다.&lt;/p&gt;

    &lt;p&gt;B의 경우, EKS를 활용하는것은 부담스럽다.&lt;/p&gt;

    &lt;p&gt;A는 아키텍쳐를 갈아엎는 것이지만, serverless 서비스인 람다 함수와 API Gateway를 활용하는 것이므로 운영적인 측면에서 최소한의 overhead를 가질것이다.&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-34-️️&quot;&gt;Prob. 34 ⭕️⭕️&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company has created an OU in AWS Organizations for each of its engineering teams. Each OU owns multiple AWS accounts. The organization has hundreds of AWS accounts.
A solutions architect must design a solution so that each OU can view a breakdown of usage costs across its AWS accounts.&lt;br /&gt;
Which solution meets these requirements?&lt;/p&gt;

&lt;p&gt;A. Create an AWS Cost and Usage Report (CUR) for each OU by using AWS Resource Access Manager. Allow each team to visualize the CUR through an Amazon QuickSight dashboard.&lt;/p&gt;

&lt;p&gt;B. Create an AWS Cost and Usage Report (CUR) from the AWS Organizations management account. Allow each team to visualize the CUR through an Amazon QuickSight dashboard.&lt;/p&gt;

&lt;p&gt;C. Create an AWS Cost and Usage Report (CUR) in each AWS Organizations member account. Allow each team to visualize the CUR through an Amazon QuickSight dashboard.&lt;/p&gt;

&lt;p&gt;D. Create an AWS Cost and Usage Report (CUR) by using AWS Systems Manager. Allow each team to visualize the CUR through Systems Manager OpsCenter dashboards.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : B&lt;/p&gt;

    &lt;p&gt;1차 시도 : B&lt;br /&gt;
2차 시도 : B&lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;B가 정답이야. 해결책은 AWS 조직 관리 계정에서 AWS 비용 및 사용 보고서(CUR)를 만드는 것입니다. 이를 통해 관리 계정은 모든 회원 계정의 사용 비용을 볼 수 있으며, 팀은 Amazon QuickSight 대시보드를 통해 CUR을 시각화할 수 있습니다. 이것은 조직이 비용 내역을 볼 수 있는 중앙 집중식 장소를 가질 수 있게 하고 팀은 비용 내역에 쉽게 접근할 수 있게 해준다.&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-35-️️&quot;&gt;Prob. 35 ⭕️⭕️&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company is storing data on premises on a Windows file server. The company produces 5 GB of new data daily.
The company migrated part of its Windows-based workload to AWS and needs the data to be available on a file system in the cloud. The company already has established an AWS Direct Connect connection between the on-premises network and AWS.&lt;br /&gt;
Which data migration strategy should the company use?&lt;/p&gt;

&lt;p&gt;A. Use the file gateway option in AWS Storage Gateway to replace the existing Windows file server, and point the existing file share to the new file gateway.&lt;/p&gt;

&lt;p&gt;B. Use AWS DataSync to schedule a daily task to replicate data between the on-premises Windows file server and Amazon FSx.&lt;/p&gt;

&lt;p&gt;C. Use AWS Data Pipeline to schedule a daily task to replicate data between the on-premises Windows file server and Amazon Elastic File System (Amazon EFS).&lt;/p&gt;

&lt;p&gt;D. Use AWS DataSync to schedule a daily task to replicate data between the on-premises Windows file server and Amazon Elastic File System (Amazon EFS).&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : B&lt;/p&gt;

    &lt;p&gt;1차 시도 : B&lt;br /&gt;
2차 시도 : B&lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;B와 D 둘 다 유효하나, 윈도우 파일 시스템에는 아무래도 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FSx&lt;/code&gt; 가 어울릴 것이다.&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-36-️&quot;&gt;Prob. 36 ❌⭕️&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company’s solutions architect is reviewing a web application that runs on AWS. The application references static assets in an Amazon S3 bucket in the us-east-1 Region. The company needs resiliency across multiple AWS Regions. The company already has created an S3 bucket in a second Region.
Which solution will meet these requirements with the LEAST operational overhead?&lt;/p&gt;

&lt;p&gt;A. Configure the application to write each object to both S3 buckets. Set up an Amazon Route 53 public hosted zone with a record set by using a weighted routing policy for each S3 bucket. Configure the application to reference the objects by using the Route 53 DNS name.&lt;/p&gt;

&lt;p&gt;B. Create an AWS Lambda function to copy objects from the S3 bucket in us-east-1 to the S3 bucket in the second Region. Invoke the Lambda function each time an object is written to the S3 bucket in us-east-1. Set up an Amazon CloudFront distribution with an origin group that contains the two S3 buckets as origins.&lt;/p&gt;

&lt;p&gt;C. Configure replication on the S3 bucket in us-east-1 to replicate objects to the S3 bucket in the second Region. Set up an Amazon CloudFront distribution with an origin group that contains the two S3 buckets as origins.&lt;/p&gt;

&lt;p&gt;D. Configure replication on the S3 bucket in us-east-1 to replicate objects to the S3 bucket in the second Region. If failover is required, update the application code to load S3 objects from the S3 bucket in the second Region.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : C&lt;/p&gt;

    &lt;p&gt;1차 시도 : B&lt;br /&gt;
2차 시도 : C&lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;Amazon CloudFront를 구성하여 서로 다른 지역의 두 개의 다른 Amazon S3 버킷을 콘텐츠의 원본으로 사용할 수 있습니다. &lt;br /&gt;
이렇게 하려면 CloudFront 배포 설정에 두 개의 별도 Amazon S3 버킷 오리진을 만들어야 하며, 각 오리진은 다른 지역의 다른 S3 버킷을 가리킵니다.&lt;br /&gt;
CloudFront 배포를 만들 때 여러개의 오리진을 배포 구성에 추가할 수 있습니다.&lt;br /&gt;
각 오리진마다 오리진 도메인 이름을 지정할 수 있습니다.&lt;br /&gt;
이 도메인 이름은 오리진으로 사용할 S3 버킷의 도메인 이름에 해당합니다. &lt;br /&gt;
또한 CloudFront가 HTTP 또는 HTTPS를 사용하여 오리진과 통신하는지 여부를 결정하는 오리진 프로토콜 정책을 지정할 수 있습니다. &lt;br /&gt;
두 버킷의 내용을 동기화하려면 두 S3 버킷 간에 교차 영역 복제를 구성해야 합니다. &lt;br /&gt;
또한 두 S3 버킷에 모두 공개적으로 액세스할 수 있는지, 또는 CloudFront가 버킷에 액세스할 수 있는 적절한 권한이 있는지 확인해야 합니다.&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-37-️&quot;&gt;Prob. 37 ❌⭕️&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company is hosting a three-tier web application in an on-premises environment. Due to a recent surge in traffic that resulted in downtime and a significant financial impact, company management has ordered that the application be moved to AWS. The application is written in .NET and has a dependency on a MySQL database. A solutions architect must design a scalable and highly available solution to meet the demand of 200,000 daily users.
Which steps should the solutions architect take to design an appropriate solution?&lt;/p&gt;

&lt;p&gt;A. Use AWS Elastic Beanstalk to create a new application with a web server environment and an Amazon RDS MySQL Multi-AZ DB instance. The environment should launch a Network Load Balancer (NLB) in front of an Amazon EC2 Auto Scaling group in multiple Availability Zones. Use an Amazon Route 53 alias record to route traffic from the company’s domain to the NLB.&lt;/p&gt;

&lt;p&gt;B. Use AWS CloudFormation to launch a stack containing an Application Load Balancer (ALB) in front of an Amazon EC2 Auto Scaling group spanning three Availability Zones. The stack should launch a Multi-AZ deployment of an Amazon Aurora MySQL DB cluster with a Retain deletion policy. Use an Amazon Route 53 alias record to route traffic from the company’s domain to the ALB.&lt;/p&gt;

&lt;p&gt;C. Use AWS Elastic Beanstalk to create an automatically scaling web server environment that spans two separate Regions with an Application Load Balancer (ALB) in each Region. Create a Multi-AZ deployment of an Amazon Aurora MySQL DB cluster with a cross-Region read replica. Use Amazon Route 53 with a geoproximity routing policy to route traffic between the two Regions.&lt;/p&gt;

&lt;p&gt;D. Use AWS CloudFormation to launch a stack containing an Application Load Balancer (ALB) in front of an Amazon ECS cluster of Spot instances spanning three Availability Zones. The stack should launch an Amazon RDS MySQL DB instance with a Snapshot deletion policy. Use an Amazon Route 53 alias record to route traffic from the company’s domain to the ALB.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : B&lt;/p&gt;

    &lt;p&gt;1차 시도 : C&lt;br /&gt;
2차 시도 : B&lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;B 맞습니다. &lt;br /&gt;
솔루션 설계자는 AWS CloudFormation을 사용하여 세 개의 가용 영역에 걸쳐 있는 Amazon EC2 자동 확장 그룹 앞에 애플리케이션 로드 밸런서(ALB)가 포함된 스택을 시작해야 합니다. &lt;br /&gt;
스택은 Retain 삭제 정책을 사용하여 Amazon Aurora MySQL DB 클러스터의 다중 AZ 배포를 시작해야 합니다.&lt;br /&gt;
Amazon Route 53 별칭 레코드를 사용하여 회사 도메인에서 ALB로 트래픽을 라우팅합니다. &lt;br /&gt;
이 솔루션은 트래픽 수요에 따라 자동으로 확장 및 확장할 수 있는 여러 가용성 영역에서 Application Load Balancer 및 Auto Scaling 그룹을 사용하여 웹 응용 프로그램의 확장 성 및고 가용성을 제공합니다. &lt;br /&gt;
Multi-AZ Amazon Aurora MySQL DB 클러스터를 사용하면 데이터베이스 계층에 대한 높은 가용성을 제공하며 Retain 삭제 정책은 DB 인스턴스가 삭제되더라도 데이터가 유지되도록합니다. &lt;br /&gt;
또한 별칭 레코드와 함께 Route 53을 사용하면 트래픽이 올바른 위치로 라우팅됩니다.&lt;/p&gt;

    &lt;p&gt;Not A: we will not use NLB for web app&lt;/p&gt;

    &lt;p&gt;Not C: Beanstalk is region service. It CANNOT “automatically scaling web server environment that spans two separate Regions”&lt;/p&gt;

    &lt;p&gt;Not D: spot instances cant meet ‘highly available’&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-38-️️&quot;&gt;Prob. 38 ⭕️⭕️&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company is using AWS Organizations to manage multiple AWS accounts. For security purposes, the company requires the creation of an Amazon Simple Notification Service (Amazon SNS) topic that enables integration with a third-party alerting system in all the Organizations member accounts.
A solutions architect used an AWS CloudFormation template to create the SNS topic and stack sets to automate the deployment of CloudFormation stacks. Trusted access has been enabled in Organizations.
What should the solutions architect do to deploy the CloudFormation StackSets in all AWS accounts?&lt;/p&gt;

&lt;p&gt;A. Create a stack set in the Organizations member accounts. Use service-managed permissions. Set deployment options to deploy to an organization. Use CloudFormation StackSets drift detection.&lt;/p&gt;

&lt;p&gt;B. Create stacks in the Organizations member accounts. Use self-service permissions. Set deployment options to deploy to an organization. Enable the CloudFormation StackSets automatic deployment.&lt;/p&gt;

&lt;p&gt;C. Create a stack set in the Organizations management account. Use service-managed permissions. Set deployment options to deploy to the organization. Enable CloudFormation StackSets automatic deployment.&lt;/p&gt;

&lt;p&gt;D. Create stacks in the Organizations management account. Use service-managed permissions. Set deployment options to deploy to the organization. Enable CloudFormation StackSets drift detection.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : C&lt;/p&gt;

    &lt;p&gt;1차 시도 : C&lt;br /&gt;
2차 시도 : C&lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;가장 좋은 솔루션은 C인데, 이는 모든 구성원 계정의 중앙 통제 지점인 조직의 관리 계정에 스택 세트를 생성하는 것을 포함하기 때문입니다. &lt;br /&gt;
이를 통해 솔루션 설계자는 단일 위치에서 모든 구성원 계정에 걸쳐 스택 세트의 배포를 관리할 수 있습니다. &lt;br /&gt;
서비스 관리 권한이 사용되며, 이를 통해 CloudFormation 서비스가 스택 세트를 모든 멤버 계정에 배포할 수 있습니다. &lt;br /&gt;
배포 옵션이 조직에 배포되도록 설정되고 자동 배포가 실행되므로 스택 세트가 관리 계정에 생성되는 즉시 모든 멤버 계정에 자동으로 배포됩니다.&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-39-️&quot;&gt;Prob. 39 ❌⭕️&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company wants to migrate its workloads from on premises to AWS. The workloads run on Linux and Windows. The company has a large on-premises infrastructure that consists of physical machines and VMs that host numerous applications.&lt;/p&gt;

&lt;p&gt;The company must capture details about the system configuration, system performance, running processes, and network connections of its on-premises workloads. The company also must divide the on-premises applications into groups for AWS migrations. The company needs recommendations for Amazon EC2 instance types so that the company can run its workloads on AWS in the most cost-effective manner.&lt;/p&gt;

&lt;p&gt;Which combination of steps should a solutions architect take to meet these requirements? (Choose three.)&lt;/p&gt;

&lt;p&gt;A. Assess the existing applications by installing AWS Application Discovery Agent on the physical machines and VMs.&lt;/p&gt;

&lt;p&gt;B. Assess the existing applications by installing AWS Systems Manager Agent on the physical machines and VMs.&lt;/p&gt;

&lt;p&gt;C. Group servers into applications for migration by using AWS Systems Manager Application Manager.&lt;/p&gt;

&lt;p&gt;D. Group servers into applications for migration by using AWS Migration Hub.&lt;/p&gt;

&lt;p&gt;E. Generate recommended instance types and associated costs by using AWS Migration Hub.&lt;/p&gt;

&lt;p&gt;F. Import data about server sizes into AWS Trusted Advisor. Follow the recommendations for cost optimization.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : A, D, E&lt;/p&gt;

    &lt;p&gt;1차 시도 : B, C, F&lt;br /&gt;
1차 시도 : A, D, E&lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;해당 상황이 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AWS Discovery Agent&lt;/code&gt; + &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AWS Migration Hub&lt;/code&gt; 를 이용하기 딱 좋은 상황이다.&lt;/p&gt;

    &lt;p&gt;Falls under the domain “Accelerate Workload Migration and Modernization”&lt;br /&gt;
promoting MigrationHub&lt;br /&gt;
Step 1 - Identify the apps&lt;br /&gt;
Step 2 - Group them&lt;br /&gt;
Step 3 - Before hand, find out what instance types would need to be in when
actual migration happens&lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;For OnPremises migrations, first phase is Discovery which can be done with Discovery agent , A&lt;/p&gt;

    &lt;p&gt;I wont go with Trusted Advisor although it advises how cost can be advised because- This applies for already aws available environment. &lt;br /&gt;
Here, about to get migrated into AWS and Architects need to discover lot of info before hand to plan alot. So I choose E between E and F. &lt;br /&gt;
My answer - A,D,E&lt;/p&gt;

    &lt;p&gt;참고 링크 - &lt;a href=&quot;https://aws.amazon.com/ko/blogs/korea/aws-migration-hub-plan-track-enterprise-application-migration/&quot;&gt;AWS 한국 블로그&lt;/a&gt;&lt;/p&gt;
  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-40-️&quot;&gt;Prob. 40 ❌⭕️&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company is hosting an image-processing service on AWS in a VPC. The VPC extends across two Availability Zones. Each Availability Zone contains one public subnet and one private subnet.&lt;/p&gt;

&lt;p&gt;The service runs on Amazon EC2 instances in the private subnets. An Application Load Balancer in the public subnets is in front of the service. The service needs to communicate with the internet and does so through two NAT gateways. The service uses Amazon S3 for image storage. The EC2 instances retrieve approximately 1 ТВ of data from an S3 bucket each day.&lt;/p&gt;

&lt;p&gt;The company has promoted the service as highly secure. A solutions architect must reduce cloud expenditures as much as possible without compromising the service’s security posture or increasing the time spent on ongoing operations.&lt;/p&gt;

&lt;p&gt;Which solution will meet these requirements?&lt;/p&gt;

&lt;p&gt;A. Replace the NAT gateways with NAT instances. In the VPC route table, create a route from the private subnets to the NAT instances.&lt;/p&gt;

&lt;p&gt;B. Move the EC2 instances to the public subnets. Remove the NAT gateways.&lt;/p&gt;

&lt;p&gt;C. Set up an S3 gateway VPC endpoint in the VPC. Attach an endpoint policy to the endpoint to allow the required actions on the S3 bucket.&lt;/p&gt;

&lt;p&gt;D. Attach an Amazon Elastic File System (Amazon EFS) volume to the EC2 instances. Host the images on the EFS volume.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : C&lt;/p&gt;

    &lt;p&gt;1차 시도 : D&lt;br /&gt;
1차 시도 : C&lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;The only reason for C is - Gateway endpoints are not Billed and so cost effective.&lt;br /&gt;
&lt;a href=&quot;https://docs.aws.amazon.com/AmazonS3/latest/userguide/privatelink-interface-endpoints.html#types-of-vpc-endpoints-for-s3&quot;&gt;Link&lt;/a&gt; &lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;B는 프라이빗에 있던걸 퍼블릭으로 꺼내는 것이므로 보안상 적합하지 않을 것이다.&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;hr /&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Ref
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;https://www.examtopics.com/exams/amazon/aws-certified-solutions-architect-professional-sap-c02/view/8/&quot;&gt;ExamTopics&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Tue, 21 Mar 2023 21:00:00 +0900</pubDate>
        <link>https://hjy.today/study/AWS-_SAP-C02_ExamTopics_31~40.html</link>
        <guid isPermaLink="true">https://hjy.today/study/AWS-_SAP-C02_ExamTopics_31~40.html</guid>
        
        <category>aws</category>
        
        <category>sap-c02</category>
        
        
        <category>study</category>
        
      </item>
    
      <item>
        <title>[AWS] Organizations 이해</title>
        <description>&lt;p&gt;AWS &lt;strong&gt;Organizations&lt;/strong&gt;를 이해해보자.&lt;/p&gt;

&lt;!--more--&gt;

&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#1-organizations-개요&quot; id=&quot;markdown-toc-1-organizations-개요&quot;&gt;1. Organizations 개요&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#2-구성-요소&quot; id=&quot;markdown-toc-2-구성-요소&quot;&gt;2. 구성 요소&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#i-organization조직&quot; id=&quot;markdown-toc-i-organization조직&quot;&gt;I. Organization(조직)&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#ii-root루트&quot; id=&quot;markdown-toc-ii-root루트&quot;&gt;II. Root(루트)&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#iii-organizational-unitou&quot; id=&quot;markdown-toc-iii-organizational-unitou&quot;&gt;III. Organizational unit(OU)&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#iv-account계정&quot; id=&quot;markdown-toc-iv-account계정&quot;&gt;IV. Account(계정)&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#3-기능&quot; id=&quot;markdown-toc-3-기능&quot;&gt;3. 기능&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#i-invitation초대&quot; id=&quot;markdown-toc-i-invitation초대&quot;&gt;I. Invitation(초대)&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#ii-handshake핸드셰이크&quot; id=&quot;markdown-toc-ii-handshake핸드셰이크&quot;&gt;II. HandShake(핸드셰이크)&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#iii-available-feature-sets사용-가능한-기능-세트&quot; id=&quot;markdown-toc-iii-available-feature-sets사용-가능한-기능-세트&quot;&gt;III. Available feature sets(사용 가능한 기능 세트)&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#iv-scp서비스-제어-정책&quot; id=&quot;markdown-toc-iv-scp서비스-제어-정책&quot;&gt;IV. SCP(서비스 제어 정책)&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#v-allow-lists허용-목록-vs-deny-lists거부-목록&quot; id=&quot;markdown-toc-v-allow-lists허용-목록-vs-deny-lists거부-목록&quot;&gt;V. Allow lists(허용 목록) vs deny lists(거부 목록)&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#vi-ai-services-opt-out-policy인공지능-서비스-옵트아웃-정책&quot; id=&quot;markdown-toc-vi-ai-services-opt-out-policy인공지능-서비스-옵트아웃-정책&quot;&gt;VI. AI services opt-out policy(인공지능 서비스 옵트아웃 정책)&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#vii-backup-policy백업-정책&quot; id=&quot;markdown-toc-vii-backup-policy백업-정책&quot;&gt;VII. Backup policy(백업 정책)&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#viii-tag-policy태그-정책&quot; id=&quot;markdown-toc-viii-tag-policy태그-정책&quot;&gt;VIII. Tag policy(태그 정책)&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h1 id=&quot;1-organizations-개요&quot;&gt;1. Organizations 개요&lt;/h1&gt;
&lt;hr /&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;AWS Organizations&lt;/strong&gt;는 생성한 여러 AWS 계정을 조직에 통합하고, 중앙에서 관리할 수 있게 해주는 계정 관리 서비스입니다. AWS Organizations의 계정 관리 및 통합 결제 기능을 활용하면 기업의 에산, 보안 및 규정 준수 요구 사항을 보다 잘 충족할 수 있습니다. 조직의 관리자로서 조직에서 계정을 생성하고 기존 계정을 조직에 초대할 수 있습니다.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;즉, AWS의 계정을 조직 단위로 관리할 수 있게 해주는 서비스라고 할 수 있다.&lt;/p&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h1 id=&quot;2-구성-요소&quot;&gt;2. 구성 요소&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_AWS/2023-03-20-[AWS]_Organizations_이해/1.png&quot; alt=&quot;1&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;i-organization조직&quot;&gt;I. Organization(조직)&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;가장 큰 단위로 AWS의 계정들을 단일 개체로서 통합 관리할 수 있도록 한다.&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AWS Organizations Console&lt;/code&gt; 로 조직 내 모든 계정을 중앙에서 확인 및 관리할 수 있다.&lt;/p&gt;

&lt;p&gt;조직은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Management Account(관리 계정)&lt;/code&gt; 하나와 0개 이상의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Member Account(멤버 계정)&lt;/code&gt; 을 갖는다.&lt;br /&gt;
즉, 관리 계정은 필수적이다.&lt;/p&gt;

&lt;p&gt;조직의 제일 위에는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Root&lt;/code&gt; , 아래로는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Organization Unit(OU)&lt;/code&gt; 가 있는 트리 계층 구조로 계정을 조직할 수 있다.&lt;br /&gt;
각 계정은 루트에 바로 위치하거나, 계층 구조 내의 OU 중 하나에 배치할 수 있다.&lt;/p&gt;

&lt;p&gt;조직은 사용자가 설정하는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;feature set(기능 모음)&lt;/code&gt; 으로 결정되는 다양한 기능을 가질 수 있다.&lt;/p&gt;

&lt;h2 id=&quot;ii-root루트&quot;&gt;II. Root(루트)&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;조직의 모든 계정에 대한 상위 컨테이너이다.&lt;/p&gt;

&lt;p&gt;정책을 루트에 적용하면, 해당 정책은 조직의 모든 OU와 계정에 적용된다.&lt;/p&gt;

&lt;p&gt;참고로, 루트는 하나만 존재할 수 있다(you can have only one root).&lt;br /&gt;
조직을 생성하면, AWS Organizations가 자동으로 생성해준다.&lt;/p&gt;

&lt;h2 id=&quot;iii-organizational-unitou&quot;&gt;III. Organizational unit(OU)&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;루트에 속하는 계정들을 감싸는 컨테이너이다.&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;OU는 다른 OU를 포함할 수 있다.&lt;br /&gt;
때문에 사용자는 위쪽에는 루트가, 아래쪽에는 OU 브랜치가, 맨 끝에는 리프에 해당하는 계정이 있는 upside-down 형태의 트리 구조를 만들 수 있다.&lt;/p&gt;

&lt;p&gt;정책을 계층 구조 내의 노드 하나에 연결하면, 정책은 아래쪽으로 내려오면서 모든 브랜치(OU)와 리프(계정)에 적용된다.&lt;/p&gt;

&lt;p&gt;각 OU는 상위 OU를 하나만 가질 수 있으며, 현재 하나의 계정은 한 개의 OU에만 속할 수 있다.&lt;/p&gt;

&lt;h2 id=&quot;iv-account계정&quot;&gt;IV. Account(계정)&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;Oragnizations의 계정은 말 그대로의 AWS 리소스를 포함하는 표준 계정이자 자격 증명이다.&lt;/p&gt;

&lt;p&gt;참고로, 여기서 말하는 계정은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;사용자 계정&lt;/code&gt; 이 아니다.&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AWS Account(계정)&lt;/code&gt; 과 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;사용자 계정&lt;/code&gt; 은 엄연히 다른 것으로, 사용자 계정은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;IAM&lt;/code&gt; 으로 만들어지는 자격 증명을 뜻한다.&lt;br /&gt;
따라서 하나의 AWS 계정은 많은 사용자 계정과 역할을 포함하는 큰 개념이다.&lt;/p&gt;

&lt;p&gt;앞서 말했듯이 조직에는 두 가지 유형의 계정이 있다.
하나는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;관리 계정&lt;/code&gt; , 또 하나는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;멤버 계정&lt;/code&gt; 이다.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;관리 계정
    &lt;ul&gt;
      &lt;li&gt;관리 계정은 조직을 만들 때 사용하는 계정이다&lt;/li&gt;
      &lt;li&gt;조직의 관리 계정에서 수행할 수 있는 사항은 다음과 같다
        &lt;ul&gt;
          &lt;li&gt;조직내에 계정 생성&lt;/li&gt;
          &lt;li&gt;기존의 다른 계정을 조직에 초대&lt;/li&gt;
          &lt;li&gt;조직에서 계정 제거&lt;/li&gt;
          &lt;li&gt;초대 관리&lt;/li&gt;
          &lt;li&gt;조직 내 개체(루트, OU 또는 계정)에 정책 적용&lt;/li&gt;
          &lt;li&gt;지원되는 AWS 서비스들을 통합하여 조직 내 모든 계정에 서비스들을 효과적으로 제공&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;관리 계정은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;payer account&lt;/code&gt; 로서 멤버 계정에서 발생한 모든 요금을 지불해야 한다.&lt;/li&gt;
      &lt;li&gt;&lt;strong&gt;조직의 관리 계정은 변경될 수 없다(중요)&lt;/strong&gt;.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;멤버 계정
    &lt;ul&gt;
      &lt;li&gt;멤버 계정은 조직의 나머지 모든 계정들이다&lt;/li&gt;
      &lt;li&gt;하나의 계정은 하나의 조직에만 속할 수 있다&lt;/li&gt;
      &lt;li&gt;멤버 계정에 정책을 적용하면 해당 계정에만 정책이 적용된다&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;3-기능&quot;&gt;3. 기능&lt;/h1&gt;
&lt;hr /&gt;

&lt;h2 id=&quot;i-invitation초대&quot;&gt;I. Invitation(초대)&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;말 그대로 다른 계정에 조직에 대한 가입을 요청하는 과정이다.&lt;/p&gt;

&lt;p&gt;초대는 조직의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;관리 계정&lt;/code&gt;에서만 발행할 수 있다.&lt;br /&gt;
초대는 계정 ID 또는 초대된 계정과 연결된 이메일 주소로 전달된다.&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;초대받은 계정이 초대를 수락하면, 해당 계정은 조직의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;멤버 계정&lt;/code&gt;이 된다.&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;만약 조직이 모든 멤버를 대상으로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;통합 결제(consolidated billing)&lt;/code&gt; 지원에서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;모든 기능(all features)&lt;/code&gt; 지원으로 바뀌는 일을 승인하게 될 경우, 모든 멤버 계정에 초대가 가게 된다.&lt;/p&gt;

&lt;p&gt;초대는 계정 사이에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;핸드셰이크(Handshake)&lt;/code&gt; 를 함으로서 이루어지며, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AWS Organizations Console&lt;/code&gt; 에서는 보이지 않을 수 있으나 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AWS CLI&lt;/code&gt; 또는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AWS Organizations API&lt;/code&gt; 를 사용할 때는 반드시 핸드셰이크로 직접 작업해야 한다.&lt;/p&gt;

&lt;h2 id=&quot;ii-handshake핸드셰이크&quot;&gt;II. HandShake(핸드셰이크)&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;두 대상간에 정보를 교환하는 다양한 단계로 구성된 과정이다.&lt;/p&gt;

&lt;p&gt;AWS Organizations에서 핸드셰이크가 주로 사용되는 경우는 위 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;초대&lt;/code&gt; 를 위한 기본 작업을 구현할 때이다.&lt;br /&gt;
핸드셰이크 메세지는 핸드셰이크 개시자와 받는 사람간에 전달되고 응답되며, 현재 상태가 어떠한지를 알 수 있게 해준다.&lt;br /&gt;
또한 위에서 말했듯 핸드셰이크는 조직이 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;통합 결제&lt;/code&gt; 에서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;모든 기능&lt;/code&gt; 을 지원하도록 변경될 때도 사용되며, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;콘솔&lt;/code&gt;을 사용할 떄는 아니지만 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CLI&lt;/code&gt;나 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;API&lt;/code&gt; 를 사용할 때는 직접 핸드셰이크를 사용해야 한다.&lt;/p&gt;

&lt;h2 id=&quot;iii-available-feature-sets사용-가능한-기능-세트&quot;&gt;III. Available feature sets(사용 가능한 기능 세트)&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;기능 세트에는 두 가지가 있다.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;all features(모든 기능)
    &lt;ul&gt;
      &lt;li&gt;AWS Organizations가 사용할 수 있는 기본 기능 세트이다&lt;/li&gt;
      &lt;li&gt;통합 결제의 모든 기능과 조직 내 계정에 대한 더 많은 제어를 제공하는 고급 기능을 함께 제공한다
        &lt;ul&gt;
          &lt;li&gt;예를 들어 모든 기능을 활성화 하면 조직의 관리 계정은 멤버 계정이 하는 일을 완전히 제어할 수 있다&lt;/li&gt;
          &lt;li&gt;관리 계정은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SCP&lt;/code&gt; 를 적용하여 계정의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;사용자(루트 사용자 포함)&lt;/code&gt;와 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Role&lt;/code&gt; 이 액세스할 수 있는 서비스와 작업을 제한할 수 있다&lt;/li&gt;
          &lt;li&gt;관리 계정이 멤버 계정을 조직에서 나가지 못하도록 할 수도 있다&lt;/li&gt;
          &lt;li&gt;지원되는 AWS 서비스들을 통합하여 조직의 모든 계정에 기능을 제공할 수 있도록 할 수 있다&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;모든 기능을 활성화한 상태로 조직을 만드는 것도 되고, 통합 결제 기능만 제공하는 조직에서 모든 기능을 제공하도록 바꿀 수도 있다
        &lt;ul&gt;
          &lt;li&gt;상술했듯 이 경우 기존에 초대된 모든 멤버 계정이 다시 한 번 초대를 승인하여 수락하여야 한다&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;consolidated billing(통합 결제)
    &lt;ul&gt;
      &lt;li&gt;이 기능 세트는 공유 결제 기능은 제공하지만 추가적인 고급 기능은 제공하지 않는다
        &lt;ul&gt;
          &lt;li&gt;예를 들어 AWS 서비스들을 통합하여 모든 계정에 적용하거나, 정책을 사용하여 다른 계정의 사용자 및 역할이 수행할 수 있는 작업을 제한할 수 없다.&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;iv-scp서비스-제어-정책&quot;&gt;IV. SCP(서비스 제어 정책)&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;SCP를 적용하면 대상의 계정 내 사용자, 역할이 사용할 수 있는 서비스와 작업을 지정할 수 있다.&lt;/p&gt;

&lt;p&gt;SCP는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;IAM 권한 정책(IAM permissions)&lt;/code&gt;과 비슷하나, 특정 허가를 부여하지 않는다.&lt;br /&gt;
대신, SCP는 조직, OU, 계정에 대한 최대 권한을 지정한다.&lt;br /&gt;
무슨 말인가 하면, SCP는 필터로서 역할을 거르기만 할 수 있고, 상위 계층에 적용된 SCP를 하위 계층에 적용된 SCP가 거스를 수 없다.&lt;br /&gt;
즉, 상위 계층에서 허가하지 않는 작업을 하위 계층에서 허가하여 사용할 수 없다는 뜻이다.&lt;/p&gt;

&lt;h2 id=&quot;v-allow-lists허용-목록-vs-deny-lists거부-목록&quot;&gt;V. Allow lists(허용 목록) vs deny lists(거부 목록)&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;중요한 개념이니 꼭 숙지하자.&lt;br /&gt;
허용 목록과 거부 목록은 SCP에 추가 적용하여 계정에 사용 가능한 권한을 필터링 할 수 있다.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Allow lists(허용 목록)
    &lt;ul&gt;
      &lt;li&gt;허용되는 액세스를 명시적으로 지정한다
        &lt;ul&gt;
          &lt;li&gt;즉, 다른 모든 액세스는 묵시적으로 모두 차단된다&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;기본적으로 AWS Organizaitons는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FullAWSAccess&lt;/code&gt; 라는 AWS 관리형 정책을 모든 루트, OU, 계정에 적용시킨다
        &lt;ul&gt;
          &lt;li&gt;따라서 모든 계정은 처음부터 모든 서비스와 작업에 접근할 수 있다.&lt;/li&gt;
          &lt;li&gt;때문에 허용 목록을 지정하려면, 허용 목록을 정리한 SCP로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FullAWSAccess&lt;/code&gt; 를 &lt;strong&gt;교체&lt;/strong&gt;한다(중요)
            &lt;ul&gt;
              &lt;li&gt;해당 SCP는 IAM 보다 상위로 적용되기 때문에, 이렇게 하면 IAM 정책이 모든 작업을 허용한다 하더라도 SCP가 허용하는 리소스에만 접근할 수 있다&lt;/li&gt;
            &lt;/ul&gt;
          &lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;SCP는 허가를 부여하지 않음에 명심
        &lt;ul&gt;
          &lt;li&gt;필터링만 하기 때문에 하위 계층에서 SCP로 허용 목록을 작성하더라도 상위 계층에서 차단한 리소스에는 접근할 수 없다&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Deny lists(거부 목록)
    &lt;ul&gt;
      &lt;li&gt;허용되지 않는 액세스를 명시적으로 지정한다
        &lt;ul&gt;
          &lt;li&gt;즉, 다른 모든 액세스는 묵시적으로 모두 허용된다&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;상술했듯 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FullAWSAccess&lt;/code&gt; 가 기본으로 적용되므로, 거부 목록을 적용할 때는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FullAWSAccess&lt;/code&gt; 를 SCP로 교체할 필요 없이 그대로 두고 거부할 목록만을 정리한 SCP를 추가로 연결하면 된다
        &lt;ul&gt;
          &lt;li&gt;IAM 정책보다 상위에 존재하기 때문에 거부 목록에 오른 리소스는 IAM 정책으로 허용한다 해도 접근할 수 없다&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;vi-ai-services-opt-out-policy인공지능-서비스-옵트아웃-정책&quot;&gt;VI. AI services opt-out policy(인공지능 서비스 옵트아웃 정책)&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;조직의 모든 계정에서 AWS AI 서비스에 대한 옵트아웃 설정을 표준화 하는데 동무을 주는 정책 유형이다.&lt;/p&gt;

&lt;p&gt;특정 AWS AI 서비스는 Amazon AI 서비스 및 기술의 개발과 지속적인 개선을 위해 해당 서비스에서 처리한 고객 컨텐츠를 저장하고 사용할 수 있다.&lt;br /&gt;
AWS 고객은 AI 서비스 옵트아웃 정책을 사용하여 서비스 개선을 위해 자신의 콘텐츠가 저장, 사용되지 않도록 옵트아웃 할 수 있다.&lt;/p&gt;

&lt;h2 id=&quot;vii-backup-policy백업-정책&quot;&gt;VII. Backup policy(백업 정책)&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;조직의 모든 계정에서 리소스에 대한 백업 전략을 표준화하고 구현하는데 도움을 주는 정책 유형이다.&lt;/p&gt;

&lt;p&gt;백업 정책을 사용하면 리소스에 대한 백업 계획을 구성하고 배포할 수 있다.&lt;/p&gt;

&lt;h2 id=&quot;viii-tag-policy태그-정책&quot;&gt;VIII. Tag policy(태그 정책)&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;조직의 모든 계정에서 리소스 전반의 태그를 표준화 하는데 도움을 주는 정책 유형이다.&lt;/p&gt;

&lt;p&gt;태그 정책을 사용하면 특정 리소스에 대한 태그 지정 규칙을 지정할 수 있다.&lt;/p&gt;

&lt;p&gt;태그는 사용자 또는 AWS 리소스에 적용되는 커스텀 속성 레이블이다.
각 태그는 두 가지로 구성된다.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Tag key(태그 키)
    &lt;ul&gt;
      &lt;li&gt;예) &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CostCenter&lt;/code&gt; , &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Environment&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Project&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;대소문자 구별, 최대 128자&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Tag value(태그 값)
    &lt;ul&gt;
      &lt;li&gt;예) &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;111122223333&lt;/code&gt; , &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Production&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;선택적으로 기입할 수 있으며, 생략할 경우 빈 문자열로 취급되지만 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Null&lt;/code&gt; 로 설정할 수는 없다&lt;/li&gt;
      &lt;li&gt;대소문자 구별, 최대 256자&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Ref
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;https://docs.aws.amazon.com/ko_kr/organizations/latest/userguide/orgs_getting-started_concepts.html&quot;&gt;AWS Docs&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Mon, 20 Mar 2023 21:30:00 +0900</pubDate>
        <link>https://hjy.today/study/AWS-_Organizations_%EC%9D%B4%ED%95%B4.html</link>
        <guid isPermaLink="true">https://hjy.today/study/AWS-_Organizations_%EC%9D%B4%ED%95%B4.html</guid>
        
        <category>aws</category>
        
        <category>aws-base</category>
        
        
        <category>study</category>
        
      </item>
    
      <item>
        <title>[AWS] SAP-C02 ExamTopics 21~30</title>
        <description>&lt;p&gt;SAP-C02 기출 21~30번 문제를 풀어보자.&lt;br /&gt;
1차 5/10&lt;br /&gt;
2차 4/10&lt;br /&gt;&lt;/p&gt;

&lt;!--more--&gt;

&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-21-&quot; id=&quot;markdown-toc-prob-21-&quot;&gt;Prob. 21 ❓❌&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-22-&quot; id=&quot;markdown-toc-prob-22-&quot;&gt;Prob. 22 ❌❌&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-23-&quot; id=&quot;markdown-toc-prob-23-&quot;&gt;Prob. 23 ⭕❌&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-24-&quot; id=&quot;markdown-toc-prob-24-&quot;&gt;Prob. 24 ⭕⭕&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-25-&quot; id=&quot;markdown-toc-prob-25-&quot;&gt;Prob. 25 ⭕⭕&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-26-&quot; id=&quot;markdown-toc-prob-26-&quot;&gt;Prob. 26 ⭕⭕&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-27-&quot; id=&quot;markdown-toc-prob-27-&quot;&gt;Prob. 27 ❌❌&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-28-&quot; id=&quot;markdown-toc-prob-28-&quot;&gt;Prob. 28 ❌❌&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-29-&quot; id=&quot;markdown-toc-prob-29-&quot;&gt;Prob. 29 ❌❌&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-30-&quot; id=&quot;markdown-toc-prob-30-&quot;&gt;Prob. 30 ⭕⭕&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-21-&quot;&gt;Prob. 21 ❓❌&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company is using an on-premises Active Directory service for user authentication. The company wants to use the same authentication service to sign in to the company’s AWS accounts, which are using AWS Organizations. AWS Site-to-Site VPN connectivity already exists between the on-premises environment and all the company’s AWS accounts.
The company’s security policy requires conditional access to the accounts based on user groups and roles. User identities must be managed in a single location.
Which solution will meet these requirements?&lt;/p&gt;

&lt;p&gt;A. Configure AWS IAM Identity Center (AWS Single Sign-On) to connect to Active Directory by using SAML 2.0. Enable automatic provisioning by using the System for Cross-domain Identity Management (SCIM) v2.0 protocol. Grant access to the AWS accounts by using attribute-based access controls (ABACs).&lt;/p&gt;

&lt;p&gt;B. Configure AWS IAM Identity Center (AWS Single Sign-On) by using IAM Identity Center as an identity source. Enable automatic provisioning by using the System for Cross-domain Identity Management (SCIM) v2.0 protocol. Grant access to the AWS accounts by using IAM Identity Center permission sets.&lt;/p&gt;

&lt;p&gt;C. In one of the company’s AWS accounts, configure AWS Identity and Access Management (IAM) to use a SAML 2.0 identity provider. Provision IAM users that are mapped to the federated users. Grant access that corresponds to appropriate groups in Active Directory. Grant access to the required AWS accounts by using cross-account IAM users.&lt;/p&gt;

&lt;p&gt;D. In one of the company’s AWS accounts, configure AWS Identity and Access Management (IAM) to use an OpenID Connect (OIDC) identity provider. Provision IAM roles that grant access to the AWS account for the federated users that correspond to appropriate groups in Active Directory. Grant access to the required AWS accounts by using cross-account IAM roles.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : A&lt;/p&gt;

    &lt;p&gt;1차 시도 : B &lt;br /&gt;
2차 시도 : B &lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;AWS SSO(Single Sign-On)는 여러 AWS 계정 및 비즈니스 애플리케이션에 대한 액세스를 관리하도록 설계되었으며, 사용자가 Active Directory의 자격 증명을 포함하여 기존 자격 증명을 사용하여 한 번 로그인할 수 있도록 합니다. SAML 2.0을 사용하여 Active Directory에 연결하도록 AWS SSO를 구성하면 사용자 ID를 단일 위치에서 관리할 수 있습니다. 또한 SCIM(System for Cross-Domain Identity Management) v2.0 프로토콜을 사용하여 자동 프로비저닝을 사용하도록 설정할 수 있습니다. 이렇게 하면 Active Directory의 변경 사항에 따라 AWS SSO에서 사용자를 생성하고 업데이트할 수 있습니다.&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-22-&quot;&gt;Prob. 22 ❌❌&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A software company has deployed an application that consumes a REST API by using Amazon API Gateway, AWS Lambda functions, and an Amazon DynamoDB table. The application is showing an increase in the number of errors during PUT requests. Most of the PUT calls come from a small number of clients that are authenticated with specific API keys.
A solutions architect has identified that a large number of the PUT requests originate from one client. The API is noncritical, and clients can tolerate retries of unsuccessful calls. However, the errors are displayed to customers and are causing damage to the API’s reputation.
What should the solutions architect recommend to improve the customer experience?&lt;/p&gt;

&lt;p&gt;A. Implement retry logic with exponential backoff and irregular variation in the client application. Ensure that the errors are caught and handled with descriptive error messages.&lt;/p&gt;

&lt;p&gt;B. Implement API throttling through a usage plan at the API Gateway level. Ensure that the client application handles code 429 replies without error.&lt;/p&gt;

&lt;p&gt;C. Turn on API caching to enhance responsiveness for the production stage. Run 10-minute load tests. Verify that the cache capacity is appropriate for the workload.&lt;/p&gt;

&lt;p&gt;D. Implement reserved concurrency at the Lambda function level to provide the resources that are needed during sudden increases in traffic.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : B&lt;/p&gt;

    &lt;p&gt;1차 시도 : A &lt;br /&gt;
2차 시도 : A &lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;API 쓰로틀링은 API에 대한 요청 속도를 제어하는 데 사용할 수 있는 기술입니다. 이 기능은 적은 수의 클라이언트가 많은 수의 요청을 수행하여 오류를 발생시키는 상황에서 유용할 수 있습니다. 솔루션 설계자는 API 게이트웨이 수준에서 사용 계획을 통해 API 쓰로틀링을 구현하여 클라이언트가 수행할 수 있는 요청 수를 제한할 수 있으므로 오류 수를 줄이는 데 도움이 됩니다. 클라이언트 애플리케이션이 코드 429 응답을 오류 없이 처리하는 것이 중요합니다. 이는 고객에게 표시되는 오류 수를 줄여 고객 환경을 개선하는 데 도움이 됩니다. 또한 오류로 인해 API의 평판이 손상되는 것을 방지합니다.&lt;/p&gt;

    &lt;p&gt;클라이언트 애플리케이션의 기하급수적인 백오프 및 불규칙한 변동을 이용한 리트라이 로직이나 프로덕션 단계에 대한 응답성을 높이기 위해 API 캐싱을 설정하는 등의 다른 솔루션이 고객 환경을 개선하고 오류를 줄이는 데 도움이 될 수 있다는 점에 유의해야 합니다, 그러나 소수의 클라이언트에서 대량의 요청이 발생하는 문제의 근본 원인을 해결하지는 못합니다. 예약된 동시성을 람다 함수 수준에서 구현하면 트래픽이 갑자기 증가할 때 필요한 리소스를 제공할 수 있지만 클라이언트가 많은 수의 요청을 수행하고 오류를 발생시키는 문제를 해결하지는 못합니다.&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-23-&quot;&gt;Prob. 23 ⭕❌&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company is running a data-intensive application on AWS. The application runs on a cluster of hundreds of Amazon EC2 instances. A shared file system also runs on several EC2 instances that store 200 TB of data. The application reads and modifies the data on the shared file system and generates a report. The job runs once monthly, reads a subset of the files from the shared file system, and takes about 72 hours to complete. The compute instances scale in an Auto Scaling group, but the instances that host the shared file system run continuously. The compute and storage instances are all in the same AWS Region.
A solutions architect needs to reduce costs by replacing the shared file system instances. The file system must provide high performance access to the needed data for the duration of the 72-hour run.
Which solution will provide the LARGEST overall cost reduction while meeting these requirements?&lt;/p&gt;

&lt;p&gt;A. Migrate the data from the existing shared file system to an Amazon S3 bucket that uses the S3 Intelligent-Tiering storage class. Before the job runs each month, use Amazon FSx for Lustre to create a new file system with the data from Amazon S3 by using lazy loading. Use the new file system as the shared storage for the duration of the job. Delete the file system when the job is complete.&lt;/p&gt;

&lt;p&gt;B. Migrate the data from the existing shared file system to a large Amazon Elastic Block Store (Amazon EBS) volume with Multi-Attach enabled. Attach the EBS volume to each of the instances by using a user data script in the Auto Scaling group launch template. Use the EBS volume as the shared storage for the duration of the job. Detach the EBS volume when the job is complete.&lt;/p&gt;

&lt;p&gt;C. Migrate the data from the existing shared file system to an Amazon S3 bucket that uses the S3 Standard storage class. Before the job runs each month, use Amazon FSx for Lustre to create a new file system with the data from Amazon S3 by using batch loading. Use the new file system as the shared storage for the duration of the job. Delete the file system when the job is complete.&lt;/p&gt;

&lt;p&gt;D. Migrate the data from the existing shared file system to an Amazon S3 bucket. Before the job runs each month, use AWS Storage Gateway to create a file gateway with the data from Amazon S3. Use the file gateway as the shared storage for the job. Delete the file gateway when the job is complete.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : A&lt;/p&gt;

    &lt;p&gt;1차 시도 : A &lt;br /&gt;
2차 시도 : C &lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;A: Lazy loading is cost-effective because only a subset of data is used at every job&lt;/p&gt;

    &lt;p&gt;B: There are hundreds of EC2 instances using the volume which is not possible (one EBS volume is limited to 16 nitro instances attached)&lt;/p&gt;

    &lt;p&gt;C: Batching would load too much data&lt;/p&gt;

    &lt;p&gt;D: storage gateway is used for on premises data access, I don’t know is you can install a gateway in AWS, but Amazon would never advise this&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-24-&quot;&gt;Prob. 24 ⭕⭕&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company is developing a new service that will be accessed using TCP on a static port. A solutions architect must ensure that the service is highly available, has redundancy across Availability Zones, and is accessible using the DNS name my.service.com, which is publicly accessible. The service must use fixed address assignments so other companies can add the addresses to their allow lists.
Assuming that resources are deployed in multiple Availability Zones in a single Region, which solution will meet these requirements?&lt;/p&gt;

&lt;p&gt;A. Create Amazon EC2 instances with an Elastic IP address for each instance. Create a Network Load Balancer (NLB) and expose the static TCP port. Register EC2 instances with the NLB. Create a new name server record set named my.service.com, and assign the Elastic IP addresses of the EC2 instances to the record set. Provide the Elastic IP addresses of the EC2 instances to the other companies to add to their allow lists.&lt;/p&gt;

&lt;p&gt;B. Create an Amazon ECS cluster and a service definition for the application. Create and assign public IP addresses for the ECS cluster. Create a Network Load Balancer (NLB) and expose the TCP port. Create a target group and assign the ECS cluster name to the NLCreate a new A record set named my.service.com, and assign the public IP addresses of the ECS cluster to the record set. Provide the public IP addresses of the ECS cluster to the other companies to add to their allow lists.&lt;/p&gt;

&lt;p&gt;C. Create Amazon EC2 instances for the service. Create one Elastic IP address for each Availability Zone. Create a Network Load Balancer (NLB) and expose the assigned TCP port. Assign the Elastic IP addresses to the NLB for each Availability Zone. Create a target group and register the EC2 instances with the NLB. Create a new A (alias) record set named my.service.com, and assign the NLB DNS name to the record set.&lt;/p&gt;

&lt;p&gt;D. Create an Amazon ECS cluster and a service definition for the application. Create and assign public IP address for each host in the cluster. Create an Application Load Balancer (ALB) and expose the static TCP port. Create a target group and assign the ECS service definition name to the ALB. Create a new CNAME record set and associate the public IP addresses to the record set. Provide the Elastic IP addresses of the Amazon EC2 instances to the other companies to add to their allow lists.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : C&lt;/p&gt;

    &lt;p&gt;1차 시도 : C &lt;br /&gt;
2차 시도 : C &lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;Non http port like TCP should hint to NLB immediately.(ALB does not fit here) Sharing IP address of EC2 is not apt whether it is from individual EC2 instances or those from ECS cluster.this eliminates A,B.D, infact the NLB’s address which stays in front of / associates to ec2 instances need to be shared. So, only solution is C&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-25-&quot;&gt;Prob. 25 ⭕⭕&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company uses an on-premises data analytics platform. The system is highly available in a fully redundant configuration across 12 servers in the company’s data center.
The system runs scheduled jobs, both hourly and daily, in addition to one-time requests from users. Scheduled jobs can take between 20 minutes and 2 hours to finish running and have tight SLAs. The scheduled jobs account for 65% of the system usage. User jobs typically finish running in less than 5 minutes and have no SLA. The user jobs account for 35% of system usage. During system failures, scheduled jobs must continue to meet SLAs. However, user jobs can be delayed.
A solutions architect needs to move the system to Amazon EC2 instances and adopt a consumption-based model to reduce costs with no long-term commitments. The solution must maintain high availability and must not affect the SLAs.
Which solution will meet these requirements MOST cost-effectively?&lt;/p&gt;

&lt;p&gt;A. Split the 12 instances across two Availability Zones in the chosen AWS Region. Run two instances in each Availability Zone as On-Demand Instances with Capacity Reservations. Run four instances in each Availability Zone as Spot Instances.&lt;/p&gt;

&lt;p&gt;B. Split the 12 instances across three Availability Zones in the chosen AWS Region. In one of the Availability Zones, run all four instances as On-Demand Instances with Capacity Reservations. Run the remaining instances as Spot Instances.&lt;/p&gt;

&lt;p&gt;C. Split the 12 instances across three Availability Zones in the chosen AWS Region. Run two instances in each Availability Zone as On-Demand Instances with a Savings Plan. Run two instances in each Availability Zone as Spot Instances.&lt;/p&gt;

&lt;p&gt;D. Split the 12 instances across three Availability Zones in the chosen AWS Region. Run three instances in each Availability Zone as On-Demand Instances with Capacity Reservations. Run one instance in each Availability Zone as a Spot Instance.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : D&lt;/p&gt;

    &lt;p&gt;1차 시도 : D &lt;br /&gt;
2차 시도 : D &lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;D because of the 65% / 35% proportion. C seems to be good but with only 50% instances available we break the SLA&lt;/p&gt;

    &lt;p&gt;D has no long term commitment (e.g. saving plans) and has 75% on demand instances / 25% spot instances which is near the requirements&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-26-&quot;&gt;Prob. 26 ⭕⭕&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A security engineer determined that an existing application retrieves credentials to an Amazon RDS for MySQL database from an encrypted file in Amazon S3. For the next version of the application, the security engineer wants to implement the following application design changes to improve security:
The database must use strong, randomly generated passwords stored in a secure AWS managed service.
The application resources must be deployed through AWS CloudFormation.
The application must rotate credentials for the database every 90 days.
A solutions architect will generate a CloudFormation template to deploy the application.
Which resources specified in the CloudFormation template will meet the security engineer’s requirements with the LEAST amount of operational overhead?&lt;/p&gt;

&lt;p&gt;A. Generate the database password as a secret resource using AWS Secrets Manager. Create an AWS Lambda function resource to rotate the database password. Specify a Secrets Manager RotationSchedule resource to rotate the database password every 90 days.&lt;/p&gt;

&lt;p&gt;B. Generate the database password as a SecureString parameter type using AWS Systems Manager Parameter Store. Create an AWS Lambda function resource to rotate the database password. Specify a Parameter Store RotationSchedule resource to rotate the database password every 90 days.&lt;/p&gt;

&lt;p&gt;C. Generate the database password as a secret resource using AWS Secrets Manager. Create an AWS Lambda function resource to rotate the database password. Create an Amazon EventBridge scheduled rule resource to trigger the Lambda function password rotation every 90 days.&lt;/p&gt;

&lt;p&gt;D. Generate the database password as a SecureString parameter type using AWS Systems Manager Parameter Store. Specify an AWS AppSync DataSource resource to automatically rotate the database password every 90 days.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : A&lt;/p&gt;

    &lt;p&gt;1차 시도 : A &lt;br /&gt;
2차 시도 : A &lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;Secrets manager는 암호 순환만 지원할 수 있으며 parameter store는 지원하지 않습니다. parameter store는 이름이 나타내는 대로 다른 곳에서 참조하거나 참조하는 위치일 뿐입니다. B,D가 제거됩니다.이벤트 브리지 규칙이 알려진 90일 트리거를 캡처할 필요가 없기 때문에 C가 잘못되었습니다. Secrets manager에서 비밀을 구성할 때는 순환 예약을 이미 사용할 수 있습니다. 그러면 옵션 A가 올바른 상태로 유지됩니다.&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-27-&quot;&gt;Prob. 27 ❌❌&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company is storing data in several Amazon DynamoDB tables. A solutions architect must use a serverless architecture to make the data accessible publicly through a simple API over HTTPS. The solution must scale automatically in response to demand.
Which solutions meet these requirements? (Choose two.)&lt;/p&gt;

&lt;p&gt;A. Create an Amazon API Gateway REST API. Configure this API with direct integrations to DynamoDB by using API Gateway’s AWS integration type.&lt;/p&gt;

&lt;p&gt;B. Create an Amazon API Gateway HTTP API. Configure this API with direct integrations to Dynamo DB by using API Gateway’s AWS integration type.&lt;/p&gt;

&lt;p&gt;C. Create an Amazon API Gateway HTTP API. Configure this API with integrations to AWS Lambda functions that return data from the DynamoDB tables.&lt;/p&gt;

&lt;p&gt;D. Create an accelerator in AWS Global Accelerator. Configure this accelerator with AWS Lambda@Edge function integrations that return data from the DynamoDB tables.&lt;/p&gt;

&lt;p&gt;E. Create a Network Load Balancer. Configure listener rules to forward requests to the appropriate AWS Lambda functions.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : A, C&lt;/p&gt;

    &lt;p&gt;1차 시도 : C, E &lt;br /&gt;
2차 시도 : C, E &lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;Option B: HTTP APIs do not currently support integrations with DynamoDB, and therefore this solution would not work.&lt;/p&gt;

    &lt;p&gt;Option D: AWS Global Accelerator and AWS Lambda@Edge, which both involve infrastructure management.&lt;/p&gt;

    &lt;p&gt;Option E: NLB does not meet the requirement of being serverless&lt;/p&gt;

    &lt;p&gt;Api gateway REST APis support direct integration with DynamoDb&lt;/p&gt;

    &lt;p&gt;The same can be achieved with HTTP APIs using a lambda between the two&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-28-&quot;&gt;Prob. 28 ❌❌&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company has registered 10 new domain names. The company uses the domains for online marketing. The company needs a solution that will redirect online visitors to a specific URL for each domain. All domains and target URLs are defined in a JSON document. All DNS records are managed by Amazon Route 53.
A solutions architect must implement a redirect service that accepts HTTP and HTTPS requests.
Which combination of steps should the solutions architect take to meet these requirements with the LEAST amount of operational effort? (Choose three.)&lt;/p&gt;

&lt;p&gt;A. Create a dynamic webpage that runs on an Amazon EC2 instance. Configure the webpage to use the JSON document in combination with the event message to look up and respond with a redirect URL.&lt;/p&gt;

&lt;p&gt;B. Create an Application Load Balancer that includes HTTP and HTTPS listeners.&lt;/p&gt;

&lt;p&gt;C. Create an AWS Lambda function that uses the JSON document in combination with the event message to look up and respond with a redirect URL.&lt;/p&gt;

&lt;p&gt;D. Use an Amazon API Gateway API with a custom domain to publish an AWS Lambda function.&lt;/p&gt;

&lt;p&gt;E. Create an Amazon CloudFront distribution. Deploy a Lambda@Edge function.&lt;/p&gt;

&lt;p&gt;F. Create an SSL certificate by using AWS Certificate Manager (ACM). Include the domains as Subject Alternative Names.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : C, E, F&lt;/p&gt;

    &lt;p&gt;1차 시도 : C, D, E &lt;br /&gt;
2차 시도 : B, D, E &lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;C: 솔루션 설계자는 AWS 람다 기능을 생성하여 JSON 문서를 사용하여 각 도메인의 대상 URL을 검색하고 적절한 리디렉션 URL로 응답할 수 있습니다. 이러한 방식으로, 솔루션은 리디렉션을 처리하기 위해 웹 서버에 의존할 필요가 없으므로 운영 작업이 줄어듭니다.&lt;/p&gt;

    &lt;p&gt;E: 솔루션 설계자는 Amazon CloudFront 배포판을 생성하여 각 도메인에 대한 대상 URL을 검색하고 적절한 리디렉션 URL로 응답할 수 있는 Lambda@Edge 기능을 배포할 수 있습니다. 이러한 방식으로 CloudFront는 리디렉션을 처리할 수 있으므로 운영 노력을 줄일 수 있습니다.&lt;/p&gt;

    &lt;p&gt;F: ACM을 사용하여 SSL 인증서를 만들고 도메인을 주체 대체 이름으로 포함함으로써 솔루션 설계자는 리디렉션 서비스가 회사에서 필요로 하는 HTTP 및 HTTPS 요청을 모두 처리할 수 있도록 보장할 수 있습니다.&lt;/p&gt;

    &lt;p&gt;A와 B는 리디렉션을 처리하기 위해 웹 서버를 구성하고 유지 관리해야 하기 때문에 올바른 답이 아닙니다.&lt;/p&gt;

    &lt;p&gt;D는 API Gateway API를 생성해야 하기 때문에 올바른 대답이 아니며, 이는 운영 노력을 증가시킵니다.&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-29-&quot;&gt;Prob. 29 ❌❌&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company that has multiple AWS accounts is using AWS Organizations. The company’s AWS accounts host VPCs, Amazon EC2 instances, and containers.
The company’s compliance team has deployed a security tool in each VPC where the company has deployments. The security tools run on EC2 instances and send information to the AWS account that is dedicated for the compliance team. The company has tagged all the compliance-related resources with a key of “costCenter” and a value or “compliance”.
The company wants to identify the cost of the security tools that are running on the EC2 instances so that the company can charge the compliance team’s AWS account. The cost calculation must be as accurate as possible.
What should a solutions architect do to meet these requirements?&lt;/p&gt;

&lt;p&gt;A. In the management account of the organization, activate the costCenter user-defined tag. Configure monthly AWS Cost and Usage Reports to save to an Amazon S3 bucket in the management account. Use the tag breakdown in the report to obtain the total cost for the costCenter tagged resources.&lt;/p&gt;

&lt;p&gt;B. In the member accounts of the organization, activate the costCenter user-defined tag. Configure monthly AWS Cost and Usage Reports to save to an Amazon S3 bucket in the management account. Schedule a monthly AWS Lambda function to retrieve the reports and calculate the total cost for the costCenter tagged resources.&lt;/p&gt;

&lt;p&gt;C. In the member accounts of the organization activate the costCenter user-defined tag. From the management account, schedule a monthly AWS Cost and Usage Report. Use the tag breakdown in the report to calculate the total cost for the costCenter tagged resources.&lt;/p&gt;

&lt;p&gt;D. Create a custom report in the organization view in AWS Trusted Advisor. Configure the report to generate a monthly billing summary for the costCenter tagged resources in the compliance team’s AWS account.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : A&lt;/p&gt;

    &lt;p&gt;1차 시도 : C &lt;br /&gt;
2차 시도 : C &lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;지불을 위한 커스텀 태그는 관리 계정에 의해서만 활성화할 수 있다는 말이 있다.&lt;br /&gt;
-&amp;gt; &lt;a href=&quot;https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/custom-tags.html&quot;&gt;https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/custom-tags.html&lt;/a&gt; 해당 링크 참고.
지불을 위한 태그는 Management Account 또는 Organization의 Member로 속하지 않은 Single Account만 접근할 수 있다.&lt;/p&gt;

    &lt;p&gt;&lt;del&gt;사실 이게 아니더라도&lt;/del&gt; C처럼 일일히 모든 계정에 태그를 적용하는 것 보다는 관리 계정에 적용하여 한 번에 모든 멤버 계정이 영향을 받도록 하는것이 나아 보인다.&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-30-&quot;&gt;Prob. 30 ⭕⭕&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company has 50 AWS accounts that are members of an organization in AWS Organizations. Each account contains multiple VPCs. The company wants to use AWS Transit Gateway to establish connectivity between the VPCs in each member account. Each time a new member account is created, the company wants to automate the process of creating a new VPC and a transit gateway attachment.
Which combination of steps will meet these requirements? (Choose two.)&lt;/p&gt;

&lt;p&gt;A. From the management account, share the transit gateway with member accounts by using AWS Resource Access Manager.&lt;/p&gt;

&lt;p&gt;B. From the management account, share the transit gateway with member accounts by using an AWS Organizations SCP.&lt;/p&gt;

&lt;p&gt;C. Launch an AWS CloudFormation stack set from the management account that automatically creates a new VPC and a VPC transit gateway attachment in a member account. Associate the attachment with the transit gateway in the management account by using the transit gateway ID.&lt;/p&gt;

&lt;p&gt;D. Launch an AWS CloudFormation stack set from the management account that automatically creates a new VPC and a peering transit gateway attachment in a member account. Share the attachment with the transit gateway in the management account by using a transit gateway service-linked role.&lt;/p&gt;

&lt;p&gt;E. From the management account, share the transit gateway with member accounts by using AWS Service Catalog.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : A, C&lt;/p&gt;

    &lt;p&gt;1차 시도 : A, C &lt;br /&gt;
2차 시도 : A, C &lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;A : Resource Access Manager를 사용하여 관리 계정에서 transit gateway를 member accounts가 공유할 수 있도록 구현한다.&lt;br /&gt;
C : transit gateway ID를 통해 관리 계정에서 transit gateway를 연결하는것이 맞아 보인다.&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;hr /&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Ref
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;https://www.examtopics.com/exams/amazon/aws-certified-solutions-architect-professional-sap-c02/view/6/&quot;&gt;ExamTopics&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Sun, 19 Mar 2023 21:30:00 +0900</pubDate>
        <link>https://hjy.today/study/AWS-_SAP-C02_ExamTopics_21~30.html</link>
        <guid isPermaLink="true">https://hjy.today/study/AWS-_SAP-C02_ExamTopics_21~30.html</guid>
        
        <category>aws</category>
        
        <category>sap-c02</category>
        
        
        <category>study</category>
        
      </item>
    
      <item>
        <title>[AWS] SAP-C02 ExamTopics 11~20</title>
        <description>&lt;p&gt;SAP-C02 기출 11~20번 문제를 풀어보자.&lt;br /&gt;
1차 3/10&lt;br /&gt;
2차 4/10&lt;br /&gt;&lt;/p&gt;

&lt;!--more--&gt;

&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-11-&quot; id=&quot;markdown-toc-prob-11-&quot;&gt;Prob. 11 ❌❌&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-12-&quot; id=&quot;markdown-toc-prob-12-&quot;&gt;Prob. 12 ❌⭕&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-13-&quot; id=&quot;markdown-toc-prob-13-&quot;&gt;Prob. 13 ❓❌&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-14-&quot; id=&quot;markdown-toc-prob-14-&quot;&gt;Prob. 14 ❓❌&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-15-&quot; id=&quot;markdown-toc-prob-15-&quot;&gt;Prob. 15 ❌⭕&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-16-&quot; id=&quot;markdown-toc-prob-16-&quot;&gt;Prob. 16 ⭕❌&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-17-&quot; id=&quot;markdown-toc-prob-17-&quot;&gt;Prob. 17 ❌❌&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-18-&quot; id=&quot;markdown-toc-prob-18-&quot;&gt;Prob. 18 ⭕⭕&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-19-&quot; id=&quot;markdown-toc-prob-19-&quot;&gt;Prob. 19 ⭕❌&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-20-&quot; id=&quot;markdown-toc-prob-20-&quot;&gt;Prob. 20 ❌⭕&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-11-&quot;&gt;Prob. 11 ❌❌&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company has many AWS accounts and uses AWS Organizations to manage all of them. A solutions architect must implement a solution that the company can use to share a common network across multiple accounts.
The company’s infrastructure team has a dedicated infrastructure account that has a VPC. The infrastructure team must use this account to manage the network. Individual accounts cannot have the ability to manage their own networks. However, individual accounts must be able to create AWS resources within subnets.
Which combination of actions should the solutions architect perform to meet these requirements? (Choose two.)&lt;/p&gt;

&lt;p&gt;A. Create a transit gateway in the infrastructure account.&lt;/p&gt;

&lt;p&gt;B. Enable resource sharing from the AWS Organizations management account.&lt;/p&gt;

&lt;p&gt;C. Create VPCs in each AWS account within the organization in AWS Organizations. Configure the VPCs to share the same CIDR range and subnets as the VPC in the infrastructure account. Peer the VPCs in each individual account with the VPC in the infrastructure account.&lt;/p&gt;

&lt;p&gt;D. Create a resource share in AWS Resource Access Manager in the infrastructure account. Select the specific AWS Organizations OU that will use the shared network. Select each subnet to associate with the resource share.&lt;/p&gt;

&lt;p&gt;E. Create a resource share in AWS Resource Access Manager in the infrastructure account. Select the specific AWS Organizations OU that will use the shared network. Select each prefix list to associate with the resource share.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : B, D&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;B는 조직이 계정 간에 리소스를 공유할 수 있도록 지원하기 때문에 필요합니다.&lt;br /&gt;
D는 인프라 계정이 조직의 다른 계정과 특정 서브넷을 공유할 수 있게 해주기 때문에 다른 계정이 자체 네트워크를 관리하지 않고도 해당 서브넷 내에 리소스를 생성할 수 있습니다.&lt;/p&gt;

    &lt;p&gt;1차 시도 : A, D &lt;br /&gt;
2차 시도 : B, E &lt;br /&gt;&lt;/p&gt;
  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-12-&quot;&gt;Prob. 12 ❌⭕&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company wants to use a third-party software-as-a-service (SaaS) application. The third-party SaaS application is consumed through several API calls. The third-party SaaS application also runs on AWS inside a VPC.
The company will consume the third-party SaaS application from inside a VPC. The company has internal security policies that mandate the use of private connectivity that does not traverse the internet. No resources that run in the company VPC are allowed to be accessed from outside the company’s VPC. All permissions must conform to the principles of least privilege.
Which solution meets these requirements?&lt;/p&gt;

&lt;p&gt;A. Create an AWS PrivateLink interface VPC endpoint. Connect this endpoint to the endpoint service that the third-party SaaS application provides. Create a security group to limit the access to the endpoint. Associate the security group with the endpoint.&lt;/p&gt;

&lt;p&gt;B. Create an AWS Site-to-Site VPN connection between the third-party SaaS application and the company VPC. Configure network ACLs to limit access across the VPN tunnels.&lt;/p&gt;

&lt;p&gt;C. Create a VPC peering connection between the third-party SaaS application and the company VPC. Update route tables by adding the needed routes for the peering connection.&lt;/p&gt;

&lt;p&gt;D. Create an AWS PrivateLink endpoint service. Ask the third-party SaaS provider to create an interface VPC endpoint for this endpoint service. Grant permissions for the endpoint service to the specific account of the third-party SaaS provider.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : A&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;이 솔루션은 트래픽이 인터넷을 통과하지 않고 회사의 VPC와 타사 SaaS 애플리케이션 VPC 간에 안전하고 개인적인 연결을 만드는 AWS PrivateLink를 사용합니다. 보안 그룹을 사용하고 엔드포인트 서비스에 대한 액세스를 제한하는 것은 최소 권한의 원칙을 준수합니다&lt;/p&gt;

    &lt;p&gt;1차 시도 : C &lt;br /&gt;
2차 시도 : A &lt;br /&gt;&lt;/p&gt;
  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-13-&quot;&gt;Prob. 13 ❓❌&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company needs to implement a patching process for its servers. The on-premises servers and Amazon EC2 instances use a variety of tools to perform patching. Management requires a single report showing the patch status of all the servers and instances.
Which set of actions should a solutions architect take to meet these requirements?&lt;/p&gt;

&lt;p&gt;A. Use AWS Systems Manager to manage patches on the on-premises servers and EC2 instances. Use Systems Manager to generate patch compliance reports.&lt;/p&gt;

&lt;p&gt;B. Use AWS OpsWorks to manage patches on the on-premises servers and EC2 instances. Use Amazon QuickSight integration with OpsWorks to generate patch compliance reports.&lt;/p&gt;

&lt;p&gt;C. Use an Amazon EventBridge rule to apply patches by scheduling an AWS Systems Manager patch remediation job. Use Amazon Inspector to generate patch compliance reports.&lt;/p&gt;

&lt;p&gt;D. Use AWS OpsWorks to manage patches on the on-premises servers and EC2 instances. Use AWS X-Ray to post the patch status to AWS Systems Manager OpsCenter to generate patch compliance reports.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : A&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;A가 맞습니다. AWS 시스템 매니저는 사내 서버와 EC2 인스턴스 모두에서 패치를 관리하고 패치 준수 보고서를 생성할 수 있습니다. AWS OpsWorks 및 Amazon Inspector는 패치 관리를 위해 특별히 설계되지 않았으므로 이 사용 사례에 가장 적합한 선택은 아닙니다. Amazon EventBridge 규칙 및 AWS X-Ray를 사용하여 패치 준수 보고서를 생성하는 것은 패치 관리 보고용으로 설계되지 않았기 때문에 실용적인 솔루션이 아닙니다.&lt;/p&gt;

    &lt;p&gt;1차 시도 : ? &lt;br /&gt;
2차 시도 : D &lt;br /&gt;&lt;/p&gt;
  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-14-&quot;&gt;Prob. 14 ❓❌&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company is running an application on several Amazon EC2 instances in an Auto Scaling group behind an Application Load Balancer. The load on the application varies throughout the day, and EC2 instances are scaled in and out on a regular basis. Log files from the EC2 instances are copied to a central Amazon S3 bucket every 15 minutes. The security team discovers that log files are missing from some of the terminated EC2 instances.
Which set of actions will ensure that log files are copied to the central S3 bucket from the terminated EC2 instances?&lt;/p&gt;

&lt;p&gt;A. Create a script to copy log files to Amazon S3, and store the script in a file on the EC2 instance. Create an Auto Scaling lifecycle hook and an Amazon EventBridge rule to detect lifecycle events from the Auto Scaling group. Invoke an AWS Lambda function on the autoscaling:EC2_INSTANCE_TERMINATING transition to send ABANDON to the Auto Scaling group to prevent termination, run the script to copy the log files, and terminate the instance using the AWS SDK.&lt;/p&gt;

&lt;p&gt;B. Create an AWS Systems Manager document with a script to copy log files to Amazon S3. Create an Auto Scaling lifecycle hook and an Amazon EventBridge rule to detect lifecycle events from the Auto Scaling group. Invoke an AWS Lambda function on the autoscaling:EC2_INSTANCE_TERMINATING transition to call the AWS Systems Manager API SendCommand operation to run the document to copy the log files and send CONTINUE to the Auto Scaling group to terminate the instance.&lt;/p&gt;

&lt;p&gt;C. Change the log delivery rate to every 5 minutes. Create a script to copy log files to Amazon S3, and add the script to EC2 instance user data. Create an Amazon EventBridge rule to detect EC2 instance termination. Invoke an AWS Lambda function from the EventBridge rule that uses the AWS CLI to run the user-data script to copy the log files and terminate the instance.&lt;/p&gt;

&lt;p&gt;D. Create an AWS Systems Manager document with a script to copy log files to Amazon S3. Create an Auto Scaling lifecycle hook that publishes a message to an Amazon Simple Notification Service (Amazon SNS) topic. From the SNS notification, call the AWS Systems Manager API SendCommand operation to run the document to copy the log files and send ABANDON to the Auto Scaling group to terminate the instance.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : B&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;이 접근 방식은 자동 스케일링 수명 주기 후크를 사용하여 인스턴스가 종료되기 전에 로그 파일을 S3에 복사하는 스크립트를 실행하여 종료된 인스턴스에서 모든 로그 파일이 복사되도록 합니다.&lt;/p&gt;

    &lt;p&gt;즉 이 문제에서 중점으로 물어보는건, 종료되는 EC2로부터 어떻게 로그 파일을 복사하느냐는 것이다.&lt;/p&gt;

    &lt;p&gt;&lt;a href=&quot;https://aws.amazon.com/ko/blogs/infrastructure-and-automation/run-code-before-terminating-an-ec2-auto-scaling-instance/&quot;&gt;Run code before terminating an EC2 Auto Scaling instance&lt;/a&gt; 해당 링크를 참고하자.&lt;/p&gt;

    &lt;p&gt;즉 순서는 이렇다.&lt;/p&gt;

    &lt;ol&gt;
      &lt;li&gt;S3에 로그 파일을 복사해줄 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;System Manager&lt;/code&gt; 문서를 만든다.&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Auto Scailing lifecycle hook&lt;/code&gt;을 만든다.
        &lt;ul&gt;
          &lt;li&gt;&lt;a href=&quot;https://docs.aws.amazon.com/autoscaling/ec2/userguide/lifecycle-hooks.html&quot;&gt;lifecycle hook&lt;/a&gt;은 Auto Scaling group에 속하는 인스턴스들의 라이프사이클(terminate, scale out 등) 상태 변화에 이벤트들에 대한 액션을 취할 수 있도록 해준다. 해당 액션이 완료될 때 까지의 시간(기본 1시간)도 제공한 후, 완료되면 예정된 단계로 넘어가게 된다.&lt;/li&gt;
          &lt;li&gt;해당 액션은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CloudWatch&lt;/code&gt; , &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;EventBridge&lt;/code&gt; 등으로 감지할 수 있다.&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;해당 라이프사이클 훅을 감지할 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;EventBridge&lt;/code&gt; 규칙을 설정한다.&lt;/li&gt;
      &lt;li&gt;EventBridge가 감지하면 이를 받아줄 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Lambda function&lt;/code&gt; 을 만들고, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;System Manager&lt;/code&gt; 문서를 실행하도록 한다.&lt;/li&gt;
    &lt;/ol&gt;

    &lt;p&gt;이렇게 하면, 라이프사이클 훅에 따라 인스턴스는 종료되기 직전에 멈추게 되고, 그 동안 람다 함수 - 시스템 매니저를 통해 로그 파일을 S3로 복사, 완료되면 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CONTINUE&lt;/code&gt; 신호를 통해 인스턴스를 종료하는 과정을 거치게 된다.&lt;/p&gt;

    &lt;p&gt;1차 시도 : D &lt;br /&gt;
2차 시도 : A &lt;br /&gt;&lt;/p&gt;
  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-15-&quot;&gt;Prob. 15 ❌⭕&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company is using multiple AWS accounts. The DNS records are stored in a private hosted zone for Amazon Route 53 in Account A. The company’s applications and databases are running in Account B.
A solutions architect will deploy a two-tier application in a new VPC. To simplify the configuration, the db.example.com CNAME record set for the Amazon RDS endpoint was created in a private hosted zone for Amazon Route 53.
During deployment, the application failed to start. Troubleshooting revealed that db.example.com is not resolvable on the Amazon EC2 instance. The solutions architect confirmed that the record set was created correctly in Route 53.
Which combination of steps should the solutions architect take to resolve this issue? (Choose two.)&lt;/p&gt;

&lt;p&gt;A. Deploy the database on a separate EC2 instance in the new VPC. Create a record set for the instance’s private IP in the private hosted zone.&lt;/p&gt;

&lt;p&gt;B. Use SSH to connect to the application tier EC2 instance. Add an RDS endpoint IP address to the /etc/resolv.conf file.&lt;/p&gt;

&lt;p&gt;C. Create an authorization to associate the private hosted zone in Account A with the new VPC in Account B.&lt;/p&gt;

&lt;p&gt;D. Create a private hosted zone for the example com domain in Account B. Configure Route 53 replication between AWS accounts.&lt;/p&gt;

&lt;p&gt;E. Associate a new VPC in Account B with a hosted zone in Account A. Delete the association authorization in Account A.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : C, E&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;&lt;a href=&quot;https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/hosted-zone-private-associate-vpcs-different-accounts.html&quot;&gt;Associating an Amazon VPC and a private hosted zone that you created with different AWS accounts&lt;/a&gt;&lt;/p&gt;

    &lt;p&gt;현재 A 계정의 프라이빗 호스팅 존에 Route 53이 있고,&lt;br /&gt;
B 계정의 새 VPC에 2티어 어플리케이션을 만들었다.&lt;br /&gt;
DB의 CNAME이 A계정의 Route 53에 만들어졌으나, 배포에 실패한 상황이다.&lt;/p&gt;

    &lt;p&gt;당연히 Route53과 새 VPC가 연결이 되어있지 않으니 발생한 일이기 때문에, 연결을 해줘야 하므로&lt;/p&gt;

    &lt;ol&gt;
      &lt;li&gt;호스팅 존을 가진 계정(A)에서 VPC의 접근을 승인한다.&lt;/li&gt;
      &lt;li&gt;VPC를 가진 계정(B)에서 A의 호스팅 존에 접근한다.&lt;/li&gt;
      &lt;li&gt;A에 있는 B에 대한 접근 승인을 삭제한다.
        &lt;ul&gt;
          &lt;li&gt;삭제해도 이미 연결된 상태에는 아무런 영향이 없다.&lt;/li&gt;
          &lt;li&gt;삭제해야 미래에 VPC가 호스팅 존에 재접근 하는 것을 방지할 수 있다.&lt;/li&gt;
          &lt;li&gt;만약 재접근이 필요하다면, 1번과 2번을 다시 수행한다.&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ol&gt;

    &lt;p&gt;1차 시도 : B, C &lt;br /&gt;
2차 시도 : C, E &lt;br /&gt;&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-16-&quot;&gt;Prob. 16 ⭕❌&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company used Amazon EC2 instances to deploy a web fleet to host a blog site. The EC2 instances are behind an Application Load Balancer (ALB) and are configured in an Auto Scaling group. The web application stores all blog content on an Amazon EFS volume.
The company recently added a feature for bloggers to add video to their posts, attracting 10 times the previous user traffic. At peak times of day, users report buffering and timeout issues while attempting to reach the site or watch videos.
Which is the MOST cost-efficient and scalable deployment that will resolve the issues for users?&lt;/p&gt;

&lt;p&gt;A. Reconfigure Amazon EFS to enable maximum I/O.&lt;/p&gt;

&lt;p&gt;B. Update the blog site to use instance store volumes for storage. Copy the site contents to the volumes at launch and to Amazon S3 at shutdown.&lt;/p&gt;

&lt;p&gt;C. Configure an Amazon CloudFront distribution. Point the distribution to an S3 bucket, and migrate the videos from EFS to Amazon S3.&lt;/p&gt;

&lt;p&gt;D. Set up an Amazon CloudFront distribution for all site contents, and point the distribution at the ALB.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : C&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;CloudFront로 배포하면 사용자의 근처에 있는 엣지 로케이션에 캐시하여 버퍼링과 타임아웃을 줄일 수 있다.&lt;/p&gt;

    &lt;p&gt;1차 시도 : C&lt;br /&gt;
2차 시도 : D&lt;br /&gt;&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-17-&quot;&gt;Prob. 17 ❌❌&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company with global offices has a single 1 Gbps AWS Direct Connect connection to a single AWS Region. The company’s on-premises network uses the connection to communicate with the company’s resources in the AWS Cloud. The connection has a single private virtual interface that connects to a single VPC.
A solutions architect must implement a solution that adds a redundant Direct Connect connection in the same Region. The solution also must provide connectivity to other Regions through the same pair of Direct Connect connections as the company expands into other Regions.
Which solution meets these requirements?&lt;/p&gt;

&lt;p&gt;A. Provision a Direct Connect gateway. Delete the existing private virtual interface from the existing connection. Create the second Direct Connect connection. Create a new private virtual interface on each connection, and connect both private virtual interfaces to the Direct Connect gateway. Connect the Direct Connect gateway to the single VPC.&lt;/p&gt;

&lt;p&gt;B. Keep the existing private virtual interface. Create the second Direct Connect connection. Create a new private virtual interface on the new connection, and connect the new private virtual interface to the single VPC.&lt;/p&gt;

&lt;p&gt;C. Keep the existing private virtual interface. Create the second Direct Connect connection. Create a new public virtual interface on the new connection, and connect the new public virtual interface to the single VPC.&lt;/p&gt;

&lt;p&gt;D. Provision a transit gateway. Delete the existing private virtual interface from the existing connection. Create the second Direct Connect connection. Create a new private virtual interface on each connection, and connect both private virtual interfaces to the transit gateway. Associate the transit gateway with the single VPC.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : A&lt;/p&gt;

    &lt;p&gt;1차 시도 : C &lt;br /&gt;
2차 시도 : D &lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Direct Connect Gateway&lt;/code&gt; 를 사용하는것이 올바른 정답이라고 한다.&lt;/p&gt;

    &lt;p&gt;D의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Transit Gateway&lt;/code&gt; 의 경우, 리전별 서비스이기 때문에 하나의 TGW로는 다른 리전간의 접속이 불가능하다. 다른 리전간의 접속이 필요한 경우 다른 리전에 있는 TGW를 통해서 접속해야 하므로 옳지 않다.&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-18-&quot;&gt;Prob. 18 ⭕⭕&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company has a web application that allows users to upload short videos. The videos are stored on Amazon EBS volumes and analyzed by custom recognition software for categorization.
The website contains static content that has variable traffic with peaks in certain months. The architecture consists of Amazon EC2 instances running in an Auto Scaling group for the web application and EC2 instances running in an Auto Scaling group to process an Amazon SQS queue. The company wants to re-architect the application to reduce operational overhead using AWS managed services where possible and remove dependencies on third-party software.
Which solution meets these requirements?&lt;/p&gt;

&lt;p&gt;A. Use Amazon ECS containers for the web application and Spot instances for the Auto Scaling group that processes the SQS queue. Replace the custom software with Amazon Rekognition to categorize the videos.&lt;/p&gt;

&lt;p&gt;B. Store the uploaded videos in Amazon EFS and mount the file system to the EC2 instances for the web application. Process the SQS queue with an AWS Lambda function that calls the Amazon Rekognition API to categorize the videos.&lt;/p&gt;

&lt;p&gt;C. Host the web application in Amazon S3. Store the uploaded videos in Amazon S3. Use S3 event notification to publish events to the SQS queue. Process the SQS queue with an AWS Lambda function that calls the Amazon Rekognition API to categorize the videos.&lt;/p&gt;

&lt;p&gt;D. Use AWS Elastic Beanstalk to launch EC2 instances in an Auto Scaling group for the web application and launch a worker environment to process the SQS queue. Replace the custom software with Amazon Rekognition to categorize the videos.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : C&lt;/p&gt;

    &lt;p&gt;1차 시도 : C &lt;br /&gt;
2차 시도 : C &lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;문제에 AWS의 관리형 서비스를 이용하라는 문구가 있으므로, S3, SQS, Lambda, Rekognition를 활용하는것이 좋아보인다.&lt;br /&gt;
또한 Amazon Rekognition API 로 비디오 컨텐츠 또한 카테고라이징 할 수 있다.&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-19-&quot;&gt;Prob. 19 ⭕❌&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company has a serverless application comprised of Amazon CloudFront, Amazon API Gateway, and AWS Lambda functions. The current deployment process of the application code is to create a new version number of the Lambda function and run an AWS CLI script to update. If the new function version has errors, another CLI script reverts by deploying the previous working version of the function. The company would like to decrease the time to deploy new versions of the application logic provided by the Lambda functions, and also reduce the time to detect and revert when errors are identified.
How can this be accomplished?&lt;/p&gt;

&lt;p&gt;A. Create and deploy nested AWS CloudFormation stacks with the parent stack consisting of the AWS CloudFront distribution and API Gateway, and the child stack containing the Lambda function. For changes to Lambda, create an AWS CloudFormation change set and deploy; if errors are triggered, revert the AWS CloudFormation change set to the previous version.&lt;/p&gt;

&lt;p&gt;B. Use AWS SAM and built-in AWS CodeDeploy to deploy the new Lambda version, gradually shift traffic to the new version, and use pre-traffic and post-traffic test functions to verify code. Rollback if Amazon CloudWatch alarms are triggered.&lt;/p&gt;

&lt;p&gt;C. Refactor the AWS CLI scripts into a single script that deploys the new Lambda version. When deployment is completed, the script tests execute. If errors are detected, revert to the previous Lambda version.&lt;/p&gt;

&lt;p&gt;D. Create and deploy an AWS CloudFormation stack that consists of a new API Gateway endpoint that references the new Lambda version. Change the CloudFront origin to the new API Gateway endpoint, monitor errors and if detected, change the AWS CloudFront origin to the previous API Gateway endpoint.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : B&lt;/p&gt;

    &lt;p&gt;1차 시도 : B &lt;br /&gt;
2차 시도 : D &lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;AWS SAM(Serverless Application Model)은 서버리스 애플리케이션을 구축, 테스트 및 배포하는 데 도움이 되는 프레임워크입니다. 클라우드 포메이션을 사용하므로 클라우드 포메이션 템플릿을 생성, 업데이트 및 배포하는 프로세스를 단순화할 수 있습니다. CodeDeploy는 사내 인스턴스 및 람다 함수를 포함하여 모든 인스턴스에 대한 코드 배포를 자동화하는 서비스입니다. AWS SAM을 사용하면 내장된 CodeDeploy를 사용하여 새 버전의 Lambda 함수를 배포하고, 트래픽을 점차 새 버전으로 이동하며, 사전 트래픽 및 사후 트래픽 테스트 기능을 사용하여 코드를 확인할 수 있습니다. 또한 CloudWatch 경보를 정의하여 문제가 발생할 경우 롤백을 트리거할 수 있습니다. 이를 통해 배포 프로세스를 보다 빠르고 효율적으로 수행할 수 있을 뿐만 아니라 오류가 식별될 때 보다 안정적인 롤백 프로세스를 수행할 수 있습니다. 이렇게 하면 배포 속도를 높이고 오류가 식별될 때 검색하고 복구하는 시간을 줄일 수 있습니다.&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-20-&quot;&gt;Prob. 20 ❌⭕&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;A company is planning to store a large number of archived documents and make the documents available to employees through the corporate intranet. Employees will access the system by connecting through a client VPN service that is attached to a VPC. The data must not be accessible to the public.
The documents that the company is storing are copies of data that is held on physical media elsewhere. The number of requests will be low. Availability and speed of retrieval are not concerns of the company.
Which solution will meet these requirements at the LOWEST cost?&lt;/p&gt;

&lt;p&gt;A. Create an Amazon S3 bucket. Configure the S3 bucket to use the S3 One Zone-Infrequent Access (S3 One Zone-IA) storage class as default. Configure the S3 bucket for website hosting. Create an S3 interface endpoint. Configure the S3 bucket to allow access only through that endpoint.&lt;/p&gt;

&lt;p&gt;B. Launch an Amazon EC2 instance that runs a web server. Attach an Amazon Elastic File System (Amazon EFS) file system to store the archived data in the EFS One Zone-Infrequent Access (EFS One Zone-IA) storage class Configure the instance security groups to allow access only from private networks.&lt;/p&gt;

&lt;p&gt;C. Launch an Amazon EC2 instance that runs a web server Attach an Amazon Elastic Block Store (Amazon EBS) volume to store the archived data. Use the Cold HDD (sc1) volume type. Configure the instance security groups to allow access only from private networks.&lt;/p&gt;

&lt;p&gt;D. Create an Amazon S3 bucket. Configure the S3 bucket to use the S3 Glacier Deep Archive storage class as default. Configure the S3 bucket for website hosting. Create an S3 interface endpoint. Configure the S3 bucket to allow access only through that endpoint.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : A&lt;/p&gt;

    &lt;p&gt;1차 시도 : D &lt;br /&gt;
2차 시도 : A &lt;br /&gt;&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;A와 D를 고민을 많이 했지만, 답은 A가 맞는 것 같다.&lt;/p&gt;

    &lt;p&gt;일단 AWS에서 Glacier를 아무리 조회 빈도가 낮다지만 조회를 위한 서비스에 권장하지는 않을 것 같고,&lt;br /&gt;
Glacier의 경우 web hosting이 불가하다는 글이 있다.&lt;/p&gt;

  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;hr /&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Ref
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;https://www.examtopics.com/exams/amazon/aws-certified-solutions-architect-professional-sap-c02/view/3/&quot;&gt;ExamTopics&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Wed, 15 Mar 2023 21:30:00 +0900</pubDate>
        <link>https://hjy.today/study/AWS-_SAP-C02_ExamTopics_11~20.html</link>
        <guid isPermaLink="true">https://hjy.today/study/AWS-_SAP-C02_ExamTopics_11~20.html</guid>
        
        <category>aws</category>
        
        <category>sap-c02</category>
        
        
        <category>study</category>
        
      </item>
    
      <item>
        <title>[AWS] SAP-C02 ExamTopics 1~10</title>
        <description>&lt;p&gt;SAP-C02 기출 1~10번 문제를 풀어보자.&lt;br /&gt;
1차 5/10&lt;br /&gt;&lt;/p&gt;

&lt;!--more--&gt;

&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-1-&quot; id=&quot;markdown-toc-prob-1-&quot;&gt;Prob. 1 ⭕⭕⭕&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-2-&quot; id=&quot;markdown-toc-prob-2-&quot;&gt;Prob. 2 ❌⭕⭕&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-3-&quot; id=&quot;markdown-toc-prob-3-&quot;&gt;Prob. 3 ❓⭕⭕&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-4-&quot; id=&quot;markdown-toc-prob-4-&quot;&gt;Prob. 4 ⭕⭕⭕&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-5-&quot; id=&quot;markdown-toc-prob-5-&quot;&gt;Prob. 5 ⭕❌⭕&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-6-&quot; id=&quot;markdown-toc-prob-6-&quot;&gt;Prob. 6 ❌⭕⭕&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-7-&quot; id=&quot;markdown-toc-prob-7-&quot;&gt;Prob. 7 ❌❌⭕&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-8-&quot; id=&quot;markdown-toc-prob-8-&quot;&gt;Prob. 8 ⭕⭕⭕&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-9-&quot; id=&quot;markdown-toc-prob-9-&quot;&gt;Prob. 9 ⭕❌&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#prob-10-&quot; id=&quot;markdown-toc-prob-10-&quot;&gt;Prob. 10 ❌❌&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-1-&quot;&gt;Prob. 1 ⭕⭕⭕&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;기업은 하이브리드 DNS 솔루션을 설계해야 합니다. 이 솔루션은 VPC에 저장된 리소스에 대해 cloud.example.com 도메인에 대해 Amazon Route 53 프라이빗 호스팅 영역을 사용합니다.&lt;br /&gt;
회사의 DNS 확인 요구 사항은 다음과 같습니다:&lt;br /&gt;
온프레미스 시스템은 cloud.example.com를 해결하고 연결할 수 있어야 합니다.&lt;br /&gt;
모든 VPC가 cloud.example.com을 해결할 수 있어야 합니다.&lt;br /&gt;
사내 회사 네트워크와 AWS Transit Gateway 간에 AWS Direct Connect 연결이 이미 있습니다.&lt;br /&gt;
최고의 성능으로 이러한 요구사항을 충족하려면 어떤 아키텍처를 사용해야 합니까?&lt;/p&gt;

&lt;p&gt;A. 프라이빗 호스팅 영역을 모든 VPC에 연결합니다. 공유 서비스 VPC에 Route 53 인바운드 해결사를 만듭니다. 모든 VPC를 Transit Gateway에 연결하고 인바운드 해결사를 가리키는 cloud.example.com의 사내 DNS 서버에 전달 규칙을 생성합니다.&lt;/p&gt;

&lt;p&gt;B. 프라이빗 호스트 영역을 모든 VPC에 연결합니다. 공유 서비스 VPC에 Amazon EC2 조건부 전달자를 배포합니다. 모든 VPC를 Transit Gateway에 연결하고 조건부 전달자를 가리키는 cloud.example.com의 사내 DNS 서버에 전달 규칙을 생성합니다.&lt;/p&gt;

&lt;p&gt;C. 프라이빗 호스트 영역을 공유 서비스 VPC에 연결합니다. 공유 서비스 VPC에서 Route 53 아웃바운드 해결사를 생성합니다. 모든 VPC를 Transit Gateway에 연결하고 아웃바운드 해결사를 가리키는 cloud.example.com의 사내 DNS 서버에 전달 규칙을 생성합니다.&lt;/p&gt;

&lt;p&gt;D. 프라이빗 호스트 영역을 공유 서비스 VPC에 연결합니다. 공유 서비스 VPC에 Route 53 인바운드 해결사를 만듭니다. 공유 서비스 VPC를 Transit Gateway에 연결하고 인바운드 해결사를 가리키는 cloud.example.com의 온프레미스 DNS 서버에 전달 규칙을 생성합니다.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;원문 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
A company needs to architect a hybrid DNS solution. This solution will use an Amazon Route 53 private hosted zone for the domain cloud.example.com for the resources stored within VPCs.&lt;br /&gt;
The company has the following DNS resolution requirements:&lt;br /&gt;
On-premises systems should be able to resolve and connect to cloud.example.com.&lt;br /&gt;
All VPCs should be able to resolve cloud.example.com.&lt;br /&gt;
There is already an AWS Direct Connect connection between the on-premises corporate network and AWS Transit Gateway.&lt;br /&gt;
Which architecture should the company use to meet these requirements with the HIGHEST performance?&lt;/p&gt;

    &lt;p&gt;A. Associate the private hosted zone to all the VPCs. Create a Route 53 inbound resolver in the shared services VPC. Attach all VPCs to the transit gateway and create forwarding rules in the on-premises DNS server for cloud.example.com that point to the inbound resolver.&lt;/p&gt;

    &lt;p&gt;B. Associate the private hosted zone to all the VPCs. Deploy an Amazon EC2 conditional forwarder in the shared services VPC. Attach all VPCs to the transit gateway and create forwarding rules in the on-premises DNS server for cloud.example.com that point to the conditional forwarder.&lt;/p&gt;

    &lt;p&gt;C. Associate the private hosted zone to the shared services VPC. Create a Route 53 outbound resolver in the shared services VPC. Attach all VPCs to the transit gateway and create forwarding rules in the on-premises DNS server for cloud.example.com that point to the outbound resolver.&lt;/p&gt;

    &lt;p&gt;D. Associate the private hosted zone to the shared services VPC. Create a Route 53 inbound resolver in the shared services VPC. Attach the shared services VPC to the transit gateway and create forwarding rules in the on-premises DNS server for cloud.example.com that point to the inbound resolver.&lt;/p&gt;
  &lt;/div&gt;
&lt;/details&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : A&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;A : 정답&lt;/p&gt;

    &lt;p&gt;B : &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;EC2 conditional fowarder&lt;/code&gt;는 최고의 성능을 만족시키지 못한다.&lt;/p&gt;

    &lt;p&gt;C : 모든 VPC가 프라이빗 호스트 영역에 연결되어야 하므로 틀렸다.&lt;/p&gt;

    &lt;p&gt;D : 모든 VPC가 프라이빗 호스트 영역에 연결되어야 하므로 틀렸다.&lt;/p&gt;

    &lt;p&gt;1차 시도 : A &lt;br /&gt;
2차 시도 : A &lt;br /&gt;
3차 시도 : A &lt;br /&gt;&lt;/p&gt;
  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-2-&quot;&gt;Prob. 2 ❌⭕⭕&lt;/h2&gt;
&lt;hr /&gt;
&lt;p&gt;A사는 REST 기반 API를 통해 여러 고객에게 날씨 데이터를 제공하고 있습니다. 이 API는 Amazon API Gateway에서 호스팅하며 각 API 작업에 대해 서로 다른 AWS 람다 기능과 통합됩니다. 이 회사는 DNS에 Amazon Route 53을 사용하고 weather.example.com의 리소스 레코드를 만들었습니다. 이 회사는 API에 대한 데이터를 Amazon DynamoDB 테이블에 저장합니다. 이 회사는 API가 다른 AWS 리전으로 페일오버할 수 있는 솔루션이 필요합니다.&lt;br /&gt;
이러한 요구사항을 충족하는 솔루션은 무엇입니까?&lt;/p&gt;

&lt;p&gt;A. 새 리전에 새 람다 기능 세트를 배포합니다. 두 리전의 람다 함수가 있는 에지에 최적화된 API 끝점을 대상으로 사용하도록 API Gateway API를 업데이트합니다. DynamoDB 테이블을 글로벌 테이블로 변환합니다.&lt;/p&gt;

&lt;p&gt;B. 새 API Gateway API 및 람다 기능을 다른 지역에 배포합니다. Route 53 DNS 레코드를 다중값 응답으로 변경합니다. 두 API Gateway API를 모두 응답에 추가합니다. 대상 상태 모니터링을 사용합니다. DynamoDB 테이블을 글로벌 테이블로 변환합니다.&lt;/p&gt;

&lt;p&gt;C. 새 API Gateway API 및 람다 기능을 다른 지역에 배포합니다. Route 53 DNS 레코드를 페일오버 레코드로 변경합니다. 대상 상태 모니터링을 사용합니다. DynamoDB 테이블을 글로벌 테이블로 변환합니다.&lt;/p&gt;

&lt;p&gt;D. 새 영역에 새 API Gateway API를 배포합니다. 람다 기능을 전역 기능으로 변경합니다. Route 53 DNS 레코드를 다중값 응답으로 변경합니다. 두 API Gateway API를 모두 응답에 추가합니다. 대상 상태 모니터링을 사용합니다. DynamoDB 테이블을 글로벌 테이블로 변환합니다.&lt;/p&gt;

&lt;details&gt;
&lt;summary&gt;원문 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
A company is providing weather data over a REST-based API to several customers. The API is hosted by Amazon API Gateway and is integrated with different AWS Lambda functions for each API operation. The company uses Amazon Route 53 for DNS and has created a resource record of weather.example.com. The company stores data for the API in Amazon DynamoDB tables. The company needs a solution that will give the API the ability to fail over to a different AWS Region.&lt;br /&gt;
Which solution will meet these requirements?&lt;/p&gt;

    &lt;p&gt;A. Deploy a new set of Lambda functions in a new Region. Update the API Gateway API to use an edge-optimized API endpoint with Lambda functions from both Regions as targets. Convert the DynamoDB tables to global tables.&lt;/p&gt;

    &lt;p&gt;B. Deploy a new API Gateway API and Lambda functions in another Region. Change the Route 53 DNS record to a multivalue answer. Add both API Gateway APIs to the answer. Enable target health monitoring. Convert the DynamoDB tables to global tables.&lt;/p&gt;

    &lt;p&gt;C. Deploy a new API Gateway API and Lambda functions in another Region. Change the Route 53 DNS record to a failover record. Enable target health monitoring. Convert the DynamoDB tables to global tables.&lt;/p&gt;

    &lt;p&gt;D. Deploy a new API Gateway API in a new Region. Change the Lambda functions to global functions. Change the Route 53 DNS record to a multivalue answer. Add both API Gateway APIs to the answer. Enable target health monitoring. Convert the DynamoDB tables to global tables.&lt;/p&gt;
  &lt;/div&gt;
&lt;/details&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : C&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;This solution involves deploying a new API Gateway API and Lambda functions in another region. &lt;br /&gt;
The company should also convert the DynamoDB tables to global tables to enable cross-region replication of the data. &lt;br /&gt;
Then, the company should change the Route 53 DNS record to a failover record and enable target health monitoring to automatically route traffic to the new region in the event of a failure or outage in the primary region.&lt;/p&gt;

    &lt;p&gt;1차 시도 : B &lt;br /&gt;
2차 시도 : C &lt;br /&gt;
3차 시도 : C &lt;br /&gt;&lt;/p&gt;
  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-3-&quot;&gt;Prob. 3 ❓⭕⭕&lt;/h2&gt;
&lt;hr /&gt;
&lt;p&gt;A사는 운영이라는 단일 OU와 함께 AWS 조직을 사용하여 여러 계정을 관리합니다. 모든 계정은 운영 OU의 구성원입니다. 관리자는 조직 루트에서 거부 목록 SCP를 사용하여 제한된 서비스에 대한 액세스를 관리합니다.&lt;br /&gt;
그 회사는 최근에 새로운 사업부를 인수했고 새로운 사업부의 기존 AWS 계정을 조직에 초대했습니다. 새 사업부의 관리자는 회사 정책에 맞게 기존 AWS Config 규칙을 업데이트할 수 없다는 것을 알게 되었습니다.&lt;br /&gt;
관리자가 추가적인 장기 유지보수 없이 변경을 수행하고 현재 정책을 계속 적용할 수 있는 옵션은 무엇입니까?&lt;/p&gt;

&lt;p&gt;A. AWS Config에 대한 액세스를 제한하는 조직의 루트 SCP를 제거합니다. 회사의 표준 AWS 구성 규칙에 대한 AWS 서비스 카탈로그 제품을 생성하고 새 계정을 포함하여 조직 전체에 배포합니다.&lt;/p&gt;

&lt;p&gt;B. 새 계정에 대해 Onboarding이라는 임시 OU를 생성합니다. SCP를 Onboarding OU에 적용하여 AWS 구성 작업을 허용합니다. AWS 구성 조정이 완료되면 새 계정을 운영 OU로 이동합니다.&lt;/p&gt;

&lt;p&gt;C. 조직의 루트 SCP를 거부 목록 SCP에서 변환하여 목록 SCP가 필요한 서비스만 허용하도록 합니다. 새 계정의 주체에 대해서만 AWS 구성 작업을 허용하는 SCP를 조직의 루트에 임시로 적용합니다.&lt;/p&gt;

&lt;p&gt;D. 새 계정에 대해 Onboarding이라는 임시 OU를 생성합니다. SCP를 Onboarding OU에 적용하여 AWS 구성 작업을 허용합니다. 조직의 루트 SCP를 운영 OU로 이동합니다. AWS 구성 조정이 완료되면 새 계정을 운영 OU로 이동합니다.&lt;/p&gt;
&lt;details&gt;
&lt;summary&gt;원문 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
A company uses AWS Organizations with a single OU named Production to manage multiple accounts. All accounts are members of the Production OU. Administrators use deny list SCPs in the root of the organization to manage access to restricted services.&lt;br /&gt;
The company recently acquired a new business unit and invited the new unit’s existing AWS account to the organization. Once onboarded, the administrators of the new business unit discovered that they are not able to update existing AWS Config rules to meet the company’s policies.&lt;br /&gt;
Which option will allow administrators to make changes and continue to enforce the current policies without introducing additional long-term maintenance?&lt;/p&gt;

    &lt;p&gt;A. Remove the organization’s root SCPs that limit access to AWS Config. Create AWS Service Catalog products for the company’s standard AWS Config rules and deploy them throughout the organization, including the new account.&lt;/p&gt;

    &lt;p&gt;B. Create a temporary OU named Onboarding for the new account. Apply an SCP to the Onboarding OU to allow AWS Config actions. Move the new account to the Production OU when adjustments to AWS Config are complete.&lt;/p&gt;

    &lt;p&gt;C. Convert the organization’s root SCPs from deny list SCPs to allow list SCPs to allow the required services only. Temporarily apply an SCP to the organization’s root that allows AWS Config actions for principals only in the new account.&lt;/p&gt;

    &lt;p&gt;D. Create a temporary OU named Onboarding for the new account. Apply an SCP to the Onboarding OU to allow AWS Config actions. Move the organization’s root SCP to the Production OU. Move the new account to the Production OU when adjustments to AWS Config are complete.&lt;/p&gt;
  &lt;/div&gt;
&lt;/details&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : D&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;An SCP at a lower level can’t add a permission after it is blocked by an SCP at a higher level. SCPs can only filter; they never add permissions.&lt;br /&gt;
SO you need to create a new OU for the new account assign an SCP, and move the root SCP to Production OU. Then move the new account to production OU when AWS config is done.&lt;/p&gt;

    &lt;p&gt;Not A: too much overhead and maintenance.&lt;br /&gt;
Not B: SCP at Root will still deny Config to the temporary OU.&lt;br /&gt;
Not C: Too much overhead to create allow list.&lt;/p&gt;

    &lt;p&gt;Please note Question Constraint: Which option will allow administrators to make changes and continue to enforce the current policies without introducing additional long-term maintenance?&lt;br /&gt;
Strategies for using SCPs&lt;br /&gt;
You can configure the service control policies (SCPs) in your organization to work as either of the following:&lt;br /&gt;
A deny list – actions are allowed by default, and you specify what services and actions are prohibited&lt;br /&gt;
An allow list – actions are prohibited by default, and you specify what services and actions are allowed.&lt;/p&gt;

    &lt;p&gt;즉 SCP는 필터의 역할, 즉 제한하거나 열어주거나만 할 수 있지 상위 레벨에서의 접근 제한에 대한 허가는 할 수 없다.&lt;br /&gt;
문제에서는 새 유닛(비지니스)가 들어왔지만, 해당 유닛의 관리자는 AWS Config를 업데이트 할 수 없는 상황이다.&lt;br /&gt;
A의 경우는 기존에 존재하는 SCP를 제거하는 것이기 때문에, 너무 많은 수고가 들게 된다.&lt;br /&gt;
B의 경우는 아직 루트 SCP가 건재하기 때문에, 새로운 onboarding OU에 SCP로 허가하더라도 막힐 것이다.&lt;br /&gt;
C의 경우는 deny list로 사용하던걸 allow list로 바꾸면 하나하나 다시 지정해줘야 하므로 너무 많은 수고가 들게 된다.&lt;br /&gt;
D의 경우, B와 비슷하지만 루트 SCP가 Production OU로 넘어가기 때문에 onboarding OU로의 효력을 잃게 되므로, onboarding OU는 AWS Config의 업데이트가 가능하게 된다.&lt;/p&gt;

    &lt;p&gt;1차 시도 : 모름 &lt;br /&gt;
2차 시도 : D &lt;br /&gt;
3차 시도 : D &lt;br /&gt;&lt;/p&gt;
  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-4-&quot;&gt;Prob. 4 ⭕⭕⭕&lt;/h2&gt;
&lt;hr /&gt;
&lt;p&gt;A사는 사내 데이터 센터에서 2계층 웹 기반 애플리케이션을 실행하고 있습니다. 응용 프로그램 계층은 상태 저장 응용 프로그램을 실행하는 단일 서버로 구성됩니다. 애플리케이션이 Postgre에 연결됩니다별도의 서버에서 실행 중인 SQL 데이터베이스입니다. 애플리케이션의 사용자 기반이 크게 증가할 것으로 예상되어 회사는 애플리케이션과 데이터베이스를 AWS로 마이그레이션하고 있습니다. 솔루션은 Amazon Aurora Postgre를 사용합니다SQL, Amazon EC2 자동 스케일링 및 Elastic Load Balancing이 있습니다.&lt;br /&gt;
애플리케이션 및 데이터베이스 계층을 확장할 수 있는 일관된 사용자 환경을 제공하는 솔루션은 무엇입니까?&lt;/p&gt;

&lt;p&gt;A. Aurora 복제본에 대해 Aurora 자동 스케일링을 활성화합니다. 최소 미결 요청 라우팅 알고리즘과 스틱 세션을 사용하도록 설정된 네트워크 로드 밸런서를 사용합니다.&lt;/p&gt;

&lt;p&gt;B. Aurora 작성자에 대해 Aurora 자동 스케일링을 활성화합니다. 라운드 로빈 라우팅 알고리즘과 스틱 세션을 사용하도록 설정된 상태에서 애플리케이션 로드 밸런서를 사용합니다.&lt;/p&gt;

&lt;p&gt;C. Aurora 복제본에 대해 Aurora 자동 스케일링을 사용합니다. 라운드 로빈 라우팅 및 스틱 세션을 사용하도록 설정된 상태에서 애플리케이션 로드 밸런서를 사용합니다.&lt;/p&gt;

&lt;p&gt;D. Aurora 작성자에 대해 Aurora Scaling을 활성화합니다. 최소 미결 요청 라우팅 알고리즘과 스틱 세션을 사용하도록 설정된 네트워크 로드 밸런서를 사용합니다.&lt;/p&gt;
&lt;details&gt;
&lt;summary&gt;원문 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
A company is running a two-tier web-based application in an on-premises data center. The application layer consists of a single server running a stateful application. The application connects to a PostgreSQL database running on a separate server. The application’s user base is expected to grow significantly, so the company is migrating the application and database to AWS. The solution will use Amazon Aurora PostgreSQL, Amazon EC2 Auto Scaling, and Elastic Load Balancing.&lt;br /&gt;
Which solution will provide a consistent user experience that will allow the application and database tiers to scale?&lt;/p&gt;

    &lt;p&gt;A. Enable Aurora Auto Scaling for Aurora Replicas. Use a Network Load Balancer with the least outstanding requests routing algorithm and sticky sessions enabled.&lt;/p&gt;

    &lt;p&gt;B. Enable Aurora Auto Scaling for Aurora writers. Use an Application Load Balancer with the round robin routing algorithm and sticky sessions enabled.&lt;/p&gt;

    &lt;p&gt;C. Enable Aurora Auto Scaling for Aurora Replicas. Use an Application Load Balancer with the round robin routing and sticky sessions enabled.&lt;/p&gt;

    &lt;p&gt;D. Enable Aurora Scaling for Aurora writers. Use a Network Load Balancer with the least outstanding requests routing algorithm and sticky sessions enabled.&lt;/p&gt;
  &lt;/div&gt;
&lt;/details&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : C&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;ul&gt;
      &lt;li&gt;Aurora writers is a distractor.&lt;/li&gt;
      &lt;li&gt;Single master mode only has read replica - with Aurora replicas.&lt;/li&gt;
      &lt;li&gt;Multi master mode, not in the options&lt;/li&gt;
      &lt;li&gt;NLB does not support round robin and least outstanding algorithm&lt;/li&gt;
    &lt;/ul&gt;

    &lt;p&gt;로드밸런싱 알고리즘에는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Round Robin&lt;/code&gt; 방식과 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Least Outstanding&lt;/code&gt; 방식이 있다.&lt;br /&gt;
라운드 로빈은 EC2 인스턴스에 요청을 순서대로 할당하는 방식이고, Least Outstanding은 라운드 로빈의 개선판 느낌으로 부하가 가장 적은 인스턴스에 요청을 할당한다.&lt;/p&gt;

    &lt;p&gt;1차 시도 : C &lt;br /&gt;
2차 시도 : C &lt;br /&gt;
3차 시도 : C &lt;br /&gt;&lt;/p&gt;
  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-5-&quot;&gt;Prob. 5 ⭕❌⭕&lt;/h2&gt;
&lt;hr /&gt;
&lt;p&gt;회사는 사내에서 호스팅하는 응용프로그램에서 메타데이터를 수집하기 위해 서비스를 사용합니다. TV 및 인터넷 라디오와 같은 소비자 장치가 애플리케이션에 액세스합니다. 대부분의 오래된 장치는 특정 HTTP 헤더를 지원하지 않으며 이러한 헤더가 응답에 있으면 오류가 발생합니다. 회사는 지원되지 않는 헤더를 이전 장치로 전송된 응답에서 제거하도록 사내 로드 밸런서를 구성했습니다. 이 헤더는 사용자 에이전트 헤더로 식별됩니다.&lt;br /&gt;
이 회사는 서비스를 AWS로 마이그레이션하고 서버리스 기술을 채택하며 이전 장치를 지원하는 기능을 유지하기를 원합니다. 이 회사는 이미 애플리케이션을 일련의 AWS 람다 기능으로 마이그레이션했습니다.&lt;br /&gt;
이러한 요구사항을 충족하는 솔루션은 무엇입니까?&lt;/p&gt;

&lt;p&gt;A. 메타데이터 서비스에 대한 Amazon CloudFront 배포를 생성합니다. ALB(애플리케이션 로드 밸런서)를 생성합니다. 요청을 ALB로 전달하도록 CloudFront 배포를 구성합니다. 각 요청 유형에 대해 올바른 람다 기능을 호출하도록 ALB를 구성합니다. CloudFront 함수를 생성하여 사용자-에이전트 헤더 값을 기준으로 문제가 있는 헤더를 제거합니다.&lt;/p&gt;

&lt;p&gt;B. 메타데이터 서비스에 대한 Amazon API Gateway REST API를 생성합니다. 각 요청 유형에 대해 올바른 람다 함수를 호출하도록 API Gateway를 구성합니다. 사용자-에이전트 헤더 값을 기준으로 문제가 있는 헤더를 제거하도록 기본 게이트웨이 응답을 수정합니다.&lt;/p&gt;

&lt;p&gt;C. 메타데이터 서비스에 대한 Amazon API Gateway HTTP API를 생성합니다. 각 요청 유형에 대해 올바른 람다 함수를 호출하도록 API Gateway를 구성합니다. 사용자 에이전트 값을 기준으로 문제가 있는 헤더를 제거하는 응답 매핑 템플릿을 만듭니다. 응답 데이터 매핑을 HTTP API와 연결합니다.&lt;/p&gt;

&lt;p&gt;D. 메타데이터 서비스에 대한 Amazon CloudFront 배포를 생성합니다. ALB(애플리케이션 로드 밸런서)를 생성합니다. 요청을 ALB로 전달하도록 CloudFront 배포를 구성합니다. 각 요청 유형에 대해 올바른 람다 기능을 호출하도록 ALB를 구성합니다. User-Agent 헤더 값을 기반으로 뷰어 요청에 응답하여 문제가 있는 헤더를 제거하는 Lambda@Edge 함수를 만듭니다.&lt;/p&gt;
&lt;details&gt;
&lt;summary&gt;원문 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
A company uses a service to collect metadata from applications that the company hosts on premises. Consumer devices such as TVs and internet radios access the applications. Many older devices do not support certain HTTP headers and exhibit errors when these headers are present in responses. The company has configured an on-premises load balancer to remove the unsupported headers from responses sent to older devices, which the company identified by the User-Agent headers.&lt;br /&gt;
The company wants to migrate the service to AWS, adopt serverless technologies, and retain the ability to support the older devices. The company has already migrated the applications into a set of AWS Lambda functions.&lt;br /&gt;
Which solution will meet these requirements?&lt;/p&gt;

    &lt;p&gt;A. Create an Amazon CloudFront distribution for the metadata service. Create an Application Load Balancer (ALB). Configure the CloudFront distribution to forward requests to the ALB. Configure the ALB to invoke the correct Lambda function for each type of request. Create a CloudFront function to remove the problematic headers based on the value of the User-Agent header.&lt;/p&gt;

    &lt;p&gt;B. Create an Amazon API Gateway REST API for the metadata service. Configure API Gateway to invoke the correct Lambda function for each type of request. Modify the default gateway responses to remove the problematic headers based on the value of the User-Agent header.&lt;/p&gt;

    &lt;p&gt;C. Create an Amazon API Gateway HTTP API for the metadata service. Configure API Gateway to invoke the correct Lambda function for each type of request. Create a response mapping template to remove the problematic headers based on the value of the User-Agent. Associate the response data mapping with the HTTP API.&lt;/p&gt;

    &lt;p&gt;D. Create an Amazon CloudFront distribution for the metadata service. Create an Application Load Balancer (ALB). Configure the CloudFront distribution to forward requests to the ALB. Configure the ALB to invoke the correct Lambda function for each type of request. Create a Lambda@Edge function that will remove the problematic headers in response to viewer requests based on the value of the User-Agent header.&lt;/p&gt;
  &lt;/div&gt;
&lt;/details&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : A&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;A, D 중 답에 대한 의견이 분분하나, CloudFront의 주된 기능으로서의 역할을 봤을 때 A가 더 적절해보인다.&lt;/p&gt;

    &lt;p&gt;1차 시도 : A &lt;br /&gt;
2차 시도 : D &lt;br /&gt;
3차 시도 : A &lt;br /&gt;&lt;/p&gt;
  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-6-&quot;&gt;Prob. 6 ❌⭕⭕&lt;/h2&gt;
&lt;hr /&gt;
&lt;p&gt;소매업체는 비즈니스 파트너인 다른 회사에 일련의 데이터 파일을 제공해야 합니다. 이 파일들은 소매 회사에 속한 A 계정의 Amazon S3 버킷에 저장됩니다. 비즈니스 파트너 회사는 IAM 사용자 중 한 명인 User_DataProcessor가 자신의 AWS 계정(계정 B)에서 파일에 액세스하기를 원합니다.&lt;br /&gt;
User_DataProcessor가 S3 버킷에 성공적으로 액세스할 수 있도록 하기 위해 기업이 취해야 할 단계의 조합은 무엇입니까? (두 가지를 선택하십시오.)&lt;/p&gt;

&lt;p&gt;A. 계정 A에서 S3 버킷에 대한 CORS(교차 오리진 리소스 공유) 기능을 설정합니다.&lt;/p&gt;

&lt;p&gt;B. 계정 A에서 S3 버킷 정책을 다음과 같이 설정하십시오:&lt;br /&gt;
&lt;img src=&quot;/assets/img/study_AWS/2023-03-14-[AWS]_SAP-C02_ExamTopics_1~10/1.png&quot; alt=&quot;1&quot; /&gt;&lt;/p&gt;

&lt;p&gt;C. 계정 A에서 S3 버킷 정책을 다음과 같이 설정하십시오:&lt;br /&gt;
&lt;img src=&quot;/assets/img/study_AWS/2023-03-14-[AWS]_SAP-C02_ExamTopics_1~10/2.png&quot; alt=&quot;2&quot; /&gt;&lt;/p&gt;

&lt;p&gt;D. 계정 B에서 User_DataProcessor의 사용 권한을 다음과 같이 설정하십시오:&lt;br /&gt;
&lt;img src=&quot;/assets/img/study_AWS/2023-03-14-[AWS]_SAP-C02_ExamTopics_1~10/3.png&quot; alt=&quot;3&quot; /&gt;&lt;/p&gt;

&lt;p&gt;E. 계정 B에서 User_DataProcessor의 사용 권한을 다음과 같이 설정하십시오:&lt;br /&gt;
&lt;img src=&quot;/assets/img/study_AWS/2023-03-14-[AWS]_SAP-C02_ExamTopics_1~10/4.png&quot; alt=&quot;4&quot; /&gt;&lt;/p&gt;
&lt;details&gt;
&lt;summary&gt;원문 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
A retail company needs to provide a series of data files to another company, which is its business partner. These files are saved in an Amazon S3 bucket under Account A, which belongs to the retail company. The business partner company wants one of its IAM users, User_DataProcessor, to access the files from its own AWS account (Account B).&lt;br /&gt;
Which combination of steps must the companies take so that User_DataProcessor can access the S3 bucket successfully? (Choose two.)&lt;/p&gt;

    &lt;p&gt;A. Turn on the cross-origin resource sharing (CORS) feature for the S3 bucket in Account A.&lt;/p&gt;

    &lt;p&gt;B. In Account A, set the S3 bucket policy to the following:&lt;br /&gt;
&lt;img src=&quot;/assets/img/study_AWS/2023-03-14-[AWS]_SAP-C02_ExamTopics_1~10/1.png&quot; alt=&quot;1_1&quot; /&gt;&lt;/p&gt;

    &lt;p&gt;C. In Account A, set the S3 bucket policy to the following:&lt;br /&gt;
&lt;img src=&quot;/assets/img/study_AWS/2023-03-14-[AWS]_SAP-C02_ExamTopics_1~10/2.png&quot; alt=&quot;2_1&quot; /&gt;&lt;/p&gt;

    &lt;p&gt;D. In Account B, set the permissions of User_DataProcessor to the following:&lt;br /&gt;
&lt;img src=&quot;/assets/img/study_AWS/2023-03-14-[AWS]_SAP-C02_ExamTopics_1~10/3.png&quot; alt=&quot;3_1&quot; /&gt;&lt;/p&gt;

    &lt;p&gt;E. In Account B, set the permissions of User_DataProcessor to the following:&lt;br /&gt;
&lt;img src=&quot;/assets/img/study_AWS/2023-03-14-[AWS]_SAP-C02_ExamTopics_1~10/4.png&quot; alt=&quot;4_1&quot; /&gt;&lt;/p&gt;
  &lt;/div&gt;
&lt;/details&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : C, D&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;열어주는 쪽에서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;principal&lt;/code&gt;로 다른 계정이 접근 가능하도록 열어줘야 하고&lt;br /&gt;
접근하는 쪽에서 접근할 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;resource&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;action&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;effect&lt;/code&gt; 를 설정해야 한다.&lt;/p&gt;

    &lt;p&gt;참고로, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CORS&lt;/code&gt; 는 다른 도메인으로부터 웹 브라우저가 리소스에 접근하려 할 때 설정하는 것이다.&lt;/p&gt;

    &lt;p&gt;1차 시도 : C, E &lt;br /&gt;
2차 시도 : C, D &lt;br /&gt;
3차 시도 : C, D &lt;br /&gt;&lt;/p&gt;
  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-7-&quot;&gt;Prob. 7 ❌❌⭕&lt;/h2&gt;
&lt;hr /&gt;
&lt;p&gt;A사는 Amazon EC2 인스턴스에서 전통적인 웹 애플리케이션을 실행하고 있습니다. 회사는 응용 프로그램을 컨테이너에서 실행되는 마이크로 서비스로 리팩터링해야 합니다. 애플리케이션의 별도 버전은 프로덕션 환경과 테스트 환경의 두 가지로 구분됩니다. 응용 프로그램의 로드는 가변적이지만 최소 로드와 최대 로드가 알려져 있습니다. 솔루션 설계자는 운영 복잡성을 최소화하는 서버리스 아키텍처로 업데이트된 애플리케이션을 설계해야 합니다.&lt;br /&gt;
이러한 요구사항을 가장 경제적으로 충족하는 솔루션은 무엇입니까?&lt;/p&gt;

&lt;p&gt;A. 컨테이너 이미지를 AWS Lambda as functions에 업로드합니다. 예상 피크 부하를 처리하기 위해 관련 람다 함수에 대한 동시성 한계를 구성합니다. Amazon API Gateway 내에서 두 개의 개별 Lambda 통합을 구성합니다. 하나는 프로덕션용이고 다른 하나는 테스트용입니다.&lt;/p&gt;

&lt;p&gt;B. 컨테이너 이미지를 Amazon Elastic Container Registry(Amazon ECR)에 업로드합니다. Fargate 시작 유형을 사용하여 두 개의 자동 확장 Amazon ECS(Elastic Container Service) 클러스터를 구성하여 예상 로드를 처리합니다. ECR 이미지에서 작업을 배포합니다. 트래픽을 ECS 클러스터로 유도하도록 두 개의 개별 애플리케이션 로드 밸런서를 구성합니다.&lt;/p&gt;

&lt;p&gt;C. 컨테이너 이미지를 Amazon Elastic Container Registry(Amazon ECR)에 업로드합니다. Fargate 시작 유형을 사용하여 두 개의 자동 확장 Amazon EKS(Elastic Kubernetes Service) 클러스터를 구성하여 예상 로드를 처리합니다. ECR 이미지에서 작업을 배포합니다. 트래픽을 EKS 클러스터로 전달하도록 두 개의 개별 애플리케이션 로드 밸런서를 구성합니다.&lt;/p&gt;

&lt;p&gt;D. 컨테이너 이미지를 AWS Elastic Beanstalk에 업로드합니다. Elastic Beanstalk에서 프로덕션 및 테스트를 위한 별도의 환경 및 배포를 생성합니다. 트래픽을 Elastic Beanstalk 배포로 유도하도록 두 개의 개별 애플리케이션 로드 밸런서를 구성합니다.&lt;/p&gt;
&lt;details&gt;
&lt;summary&gt;원문 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
A company is running a traditional web application on Amazon EC2 instances. The company needs to refactor the application as microservices that run on containers. Separate versions of the application exist in two distinct environments: production and testing. Load for the application is variable, but the minimum load and the maximum load are known. A solutions architect needs to design the updated application with a serverless architecture that minimizes operational complexity.&lt;br /&gt;
Which solution will meet these requirements MOST cost-effectively?&lt;/p&gt;

    &lt;p&gt;A. Upload the container images to AWS Lambda as functions. Configure a concurrency limit for the associated Lambda functions to handle the expected peak load. Configure two separate Lambda integrations within Amazon API Gateway: one for production and one for testing.&lt;/p&gt;

    &lt;p&gt;B. Upload the container images to Amazon Elastic Container Registry (Amazon ECR). Configure two auto scaled Amazon Elastic Container Service (Amazon ECS) clusters with the Fargate launch type to handle the expected load. Deploy tasks from the ECR images. Configure two separate Application Load Balancers to direct traffic to the ECS clusters.&lt;/p&gt;

    &lt;p&gt;C. Upload the container images to Amazon Elastic Container Registry (Amazon ECR). Configure two auto scaled Amazon Elastic Kubernetes Service (Amazon EKS) clusters with the Fargate launch type to handle the expected load. Deploy tasks from the ECR images. Configure two separate Application Load Balancers to direct traffic to the EKS clusters.&lt;/p&gt;

    &lt;p&gt;D. Upload the container images to AWS Elastic Beanstalk. In Elastic Beanstalk, create separate environments and deployments for production and testing. Configure two separate Application Load Balancers to direct traffic to the Elastic Beanstalk deployments.&lt;/p&gt;
  &lt;/div&gt;
&lt;/details&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : B&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;A와 B 왔다갔다 하는듯.&lt;/p&gt;

    &lt;p&gt;이 옵션은 ECS 클러스터에 대한 Fargate 시작 유형을 활용하여 서버리스 아키텍처를 사용해야 하는 요구 사항을 충족합니다. 이 유형을 사용하면 예상 부하에 따라 컨테이너를 자동으로 확장할 수 있습니다. 또한 각 환경에 대해 별도의 ECS 클러스터 및 애플리케이션 로드 밸런싱 장치를 구성하여 운영 및 테스트를 위한 별도의 배포를 허용합니다. 또한 이 옵션은 컨테이너 오케스트레이션 및 확장에 ECS 및 Fargate를 활용하여 운영 복잡성을 최소화합니다.&lt;/p&gt;

    &lt;p&gt;1차 시도 : C &lt;br /&gt;
2차 시도 : A &lt;br /&gt;
3차 시도 : B &lt;br /&gt;&lt;/p&gt;
  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-8-&quot;&gt;Prob. 8 ⭕⭕⭕&lt;/h2&gt;
&lt;hr /&gt;
&lt;p&gt;A사는 ALB(Application Load Balancer) 뒤에 있는 일련의 Amazon EC2 인스턴스에서 실행되는 다중 계층 웹 애플리케이션을 보유하고 있습니다. 인스턴스가 자동 스케일링 그룹에 있습니다. ALB 및 자동 스케일링 그룹은 백업 AWS 영역에서 복제됩니다. 자동 스케일링 그룹의 최소값과 최대값은 0으로 설정됩니다. Amazon RDS Multi-AZ DB 인스턴스는 애플리케이션의 데이터를 저장합니다. DB 인스턴스에 백업 영역에 읽기 복제본이 있습니다. 애플리케이션은 Amazon Route 53 레코드를 사용하여 최종 사용자에게 끝점을 제공합니다.&lt;br /&gt;
이 회사는 애플리케이션에서 백업 영역으로 자동으로 페일오버할 수 있는 기능을 제공하여 RTO를 15분 이내로 줄여야 합니다. 이 회사는 액티브-액티브 전략을 위한 충분한 예산을 가지고 있지 않습니다.&lt;br /&gt;
솔루션 설계자는 이러한 요구사항을 충족하기 위해 무엇을 권장해야 합니까?&lt;/p&gt;

&lt;p&gt;A. 두 ALB 간의 트래픽을 로드 밸런싱하는 지연 시간 기반 라우팅 정책으로 응용 프로그램의 Route 53 레코드를 재구성합니다. 백업 영역에 AWS 람다 기능을 생성하여 읽기 복제본을 승격하고 자동 스케일링 그룹 값을 수정합니다. 기본 영역의 ALB에 대한 HTTP Code_Target_5XX_Count 메트릭을 기반으로 Amazon CloudWatch 경보를 생성합니다. Lambda 기능을 호출하도록 CloudWatch 알람을 구성합니다.&lt;/p&gt;

&lt;p&gt;B. 백업 영역에서 AWS 람다 기능을 생성하여 읽기 복제본을 승격하고 자동 스케일링 그룹 값을 수정합니다. 웹 애플리케이션을 모니터링하고 상태 점검 상태가 비정상일 때 Amazon Simple Notification Service(Amazon SNS) 알림을 람다 기능으로 전송하는 상태 점검으로 Route 53을 구성합니다. 상태 점검 실패 시 백업 영역의 ALB로 트래픽을 라우팅하는 페일오버 정책으로 응용 프로그램의 Route 53 레코드를 업데이트합니다.&lt;/p&gt;

&lt;p&gt;C. 백업 영역의 자동 스케일링 그룹이 기본 영역의 자동 스케일링 그룹과 동일한 값을 갖도록 구성합니다. 두 ALB 간의 트래픽을 로드 밸런싱하는 지연 시간 기반 라우팅 정책을 사용하여 응용 프로그램의 Route 53 레코드를 재구성합니다. 읽은 복제본을 제거합니다. 읽기 복제본을 독립 실행형 RDS DB 인스턴스로 바꿉니다. 스냅샷과 Amazon S3를 사용하여 RDS DB 인스턴스 간에 교차 영역 복제를 구성합니다.&lt;/p&gt;

&lt;p&gt;D. AWS Global Accelerator에서 두 ALB를 동일한 가중치 대상으로 엔드포인트를 구성합니다. 백업 영역에 AWS 람다 기능을 생성하여 읽기 복제본을 승격하고 자동 스케일링 그룹 값을 수정합니다. 기본 영역의 ALB에 대한 HTTP Code_Target_5XX_Count 메트릭을 기반으로 Amazon CloudWatch 경보를 생성합니다. Lambda 기능을 호출하도록 CloudWatch 알람을 구성합니다.&lt;/p&gt;
&lt;details&gt;
&lt;summary&gt;원문 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
A company has a multi-tier web application that runs on a fleet of Amazon EC2 instances behind an Application Load Balancer (ALB). The instances are in an Auto Scaling group. The ALB and the Auto Scaling group are replicated in a backup AWS Region. The minimum value and the maximum value for the Auto Scaling group are set to zero. An Amazon RDS Multi-AZ DB instance stores the application’s data. The DB instance has a read replica in the backup Region. The application presents an endpoint to end users by using an Amazon Route 53 record.&lt;br /&gt;
The company needs to reduce its RTO to less than 15 minutes by giving the application the ability to automatically fail over to the backup Region. The company does not have a large enough budget for an active-active strategy.
What should a solutions architect recommend to meet these requirements?&lt;/p&gt;

    &lt;p&gt;A. Reconfigure the application’s Route 53 record with a latency-based routing policy that load balances traffic between the two ALBs. Create an AWS Lambda function in the backup Region to promote the read replica and modify the Auto Scaling group values. Create an Amazon CloudWatch alarm that is based on the HTTPCode_Target_5XX_Count metric for the ALB in the primary Region. Configure the CloudWatch alarm to invoke the Lambda function.&lt;/p&gt;

    &lt;p&gt;B. Create an AWS Lambda function in the backup Region to promote the read replica and modify the Auto Scaling group values. Configure Route 53 with a health check that monitors the web application and sends an Amazon Simple Notification Service (Amazon SNS) notification to the Lambda function when the health check status is unhealthy. Update the application’s Route 53 record with a failover policy that routes traffic to the ALB in the backup Region when a health check failure occurs.&lt;/p&gt;

    &lt;p&gt;C. Configure the Auto Scaling group in the backup Region to have the same values as the Auto Scaling group in the primary Region. Reconfigure the application’s Route 53 record with a latency-based routing policy that load balances traffic between the two ALBs. Remove the read replica. Replace the read replica with a standalone RDS DB instance. Configure Cross-Region Replication between the RDS DB instances by using snapshots and Amazon S3.&lt;/p&gt;

    &lt;p&gt;D. Configure an endpoint in AWS Global Accelerator with the two ALBs as equal weighted targets. Create an AWS Lambda function in the backup Region to promote the read replica and modify the Auto Scaling group values. Create an Amazon CloudWatch alarm that is based on the HTTPCode_Target_5XX_Count metric for the ALB in the primary Region. Configure the CloudWatch alarm to invoke the Lambda function.&lt;/p&gt;
  &lt;/div&gt;
&lt;/details&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : B&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;B는 RTO를 15분 이내로 줄이고 액티브-액티브 전략을 위한 큰 예산이 없다는 회사의 요구 사항을 충족하기 때문에 맞습니다.&lt;/p&gt;

    &lt;p&gt;이 솔루션에서는 백업 영역에 AWS 람다 기능을 생성하여 읽기 복제본을 승격하고 자동 스케일링 그룹 값을 수정합니다. Route 53은 웹 애플리케이션을 모니터링하고 상태 점검 상태가 비정상일 때 Amazon SNS 알림을 람다 기능으로 전송하는 상태 점검으로 구성됩니다. 또한 Route 53 레코드는 상태 점검 실패 시 백업 영역의 ALB로 트래픽을 라우팅하는 페일오버 정책으로 업데이트됩니다. 이렇게 하면 기본 영역이 중단되면 페일오버 정책이 트리거되고 트래픽이 백업 영역으로 이동되므로 복구 시간이 빠릅니다.&lt;/p&gt;

    &lt;p&gt;1차 시도 : B &lt;br /&gt;
2차 시도 : B &lt;br /&gt;
3차 시도 : B &lt;br /&gt;&lt;/p&gt;
  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-9-&quot;&gt;Prob. 9 ⭕❌&lt;/h2&gt;
&lt;hr /&gt;
&lt;p&gt;한 회사에서 중요한 애플리케이션을 단일 Amazon EC2 인스턴스에 호스팅하고 있습니다. 애플리케이션은 메모리 내 데이터스토어에 Amazon ElastiCache for Redis 단일 노드 클러스터를 사용합니다. 애플리케이션은 관계형 데이터베이스에 Amazon RDS for Maria DB 인스턴스를 사용합니다. 애플리케이션이 작동하려면 인프라의 각 부분이 정상이고 활성 상태여야 합니다.&lt;br /&gt;
솔루션 설계자는 최소한의 다운타임으로 인프라가 장애로부터 자동으로 복구될 수 있도록 애플리케이션 아키텍처를 개선해야 합니다.&lt;br /&gt;
다음 중 이러한 요구 사항을 충족하는 단계의 조합은 무엇입니까? (세 개를 선택하십시오.)&lt;/p&gt;

&lt;p&gt;A. Elastic Load Balancer를 사용하여 여러 EC2 인스턴스에 트래픽을 분산합니다. EC2 인스턴스가 최소 용량이 두 인스턴스인 자동 스케일링 그룹에 속하는지 확인합니다.&lt;/p&gt;

&lt;p&gt;B. Elastic Load Balancer를 사용하여 여러 EC2 인스턴스에 트래픽을 분산합니다. EC2 인스턴스가 무제한 모드로 구성되어 있는지 확인합니다.&lt;/p&gt;

&lt;p&gt;C. 동일한 가용성 영역에 읽기 복제본을 작성하도록 DB 인스턴스를 수정합니다. 읽기 복제본을 장애 시나리오의 기본 DB 인스턴스로 승격합니다.&lt;/p&gt;

&lt;p&gt;D. DB 인스턴스를 수정하여 두 개의 가용성 영역에 걸쳐 확장되는 Multi-AZ 배포를 만듭니다.&lt;/p&gt;

&lt;p&gt;E. Redis용 ElastiCache 클러스터에 대한 복제 그룹을 생성합니다. 인스턴스의 최소 용량이 두 개인 자동 스케일링 그룹을 사용하도록 클러스터를 구성합니다.&lt;/p&gt;

&lt;p&gt;F. Redis용 ElastiCache 클러스터에 대한 복제 그룹을 만듭니다. 클러스터에서 Multi-AZ를 사용하도록 설정합니다.&lt;/p&gt;
&lt;details&gt;
&lt;summary&gt;원문 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
A company is hosting a critical application on a single Amazon EC2 instance. The application uses an Amazon ElastiCache for Redis single-node cluster for an in-memory data store. The application uses an Amazon RDS for MariaDB DB instance for a relational database. For the application to function, each piece of the infrastructure must be healthy and must be in an active state.&lt;br /&gt;
A solutions architect needs to improve the application’s architecture so that the infrastructure can automatically recover from failure with the least possible downtime.&lt;br /&gt;
Which combination of steps will meet these requirements? (Choose three.)&lt;/p&gt;

    &lt;p&gt;A. Use an Elastic Load Balancer to distribute traffic across multiple EC2 instances. Ensure that the EC2 instances are part of an Auto Scaling group that has a minimum capacity of two instances.&lt;/p&gt;

    &lt;p&gt;B. Use an Elastic Load Balancer to distribute traffic across multiple EC2 instances. Ensure that the EC2 instances are configured in unlimited mode.&lt;/p&gt;

    &lt;p&gt;C. Modify the DB instance to create a read replica in the same Availability Zone. Promote the read replica to be the primary DB instance in failure scenarios.&lt;/p&gt;

    &lt;p&gt;D. Modify the DB instance to create a Multi-AZ deployment that extends across two Availability Zones.&lt;/p&gt;

    &lt;p&gt;E. Create a replication group for the ElastiCache for Redis cluster. Configure the cluster to use an Auto Scaling group that has a minimum capacity of two instances.&lt;/p&gt;

    &lt;p&gt;F. Create a replication group for the ElastiCache for Redis cluster. Enable Multi-AZ on the cluster.&lt;/p&gt;
  &lt;/div&gt;
&lt;/details&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : A, D, F&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;A. ELB(Elastic Load Balancer)를 사용하여 여러 EC2 인스턴스에 트래픽을 분산하면 인스턴스 중 하나를 사용할 수 없게 되는 경우에도 애플리케이션을 사용할 수 있습니다. 인스턴스를 최소 용량이 두 개인 자동 스케일링 그룹의 일부로 구성하면 트래픽을 처리할 정상적인 인스턴스가 항상 하나 이상 있는지 확인할 수 있습니다.&lt;/p&gt;

    &lt;p&gt;D. DB 인스턴스를 수정하여 두 개의 가용성 영역에 걸쳐 확장되는 Multi-AZ 배포를 작성하면 장애가 발생한 경우에도 데이터베이스를 사용할 수 있습니다. 장애가 발생하면 트래픽이 자동으로 보조 가용성 영역으로 이동하여 다운타임이 줄어듭니다.&lt;/p&gt;

    &lt;p&gt;F. Redis용 ElastiCache 클러스터에 대한 복제 그룹을 만들고 Multi-AZ를 활성화하면 장애가 발생한 경우에도 메모리 내 데이터 저장소를 사용할 수 있습니다. 이렇게 하면 트래픽이 자동으로 보조 가용성 영역으로 이동하여 다운타임을 줄일 수 있습니다.&lt;/p&gt;

    &lt;p&gt;1차 시도 : A, D, F &lt;br /&gt;
2차 시도 : A, D, E &lt;br /&gt;&lt;/p&gt;
  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;prob-10-&quot;&gt;Prob. 10 ❌❌&lt;/h2&gt;
&lt;hr /&gt;
&lt;p&gt;한 소매 회사가 AWS에서 전자 상거래 애플리케이션을 운영하고 있습니다. 애플리케이션은 ALB(Application Load Balancer) 뒤에 있는 Amazon EC2 인스턴스에서 실행됩니다. 이 회사에서는 Amazon RDS DB 인스턴스를 데이터베이스 백엔드로 사용합니다. Amazon CloudFront는 ALB를 가리키는 하나의 오리진으로 구성됩니다. 정적 콘텐츠가 캐시됩니다. 아마존 53번 도로는 모든 공공 구역을 유치하는 데 사용됩니다.&lt;br /&gt;
응용 프로그램을 업데이트한 후 ALB가 502 상태 코드(불량 게이트웨이) 오류를 반환하는 경우가 있습니다. 근본 원인은 ALB로 반환되는 잘못된 형식의 HTTP 헤더입니다. 솔루션 설계자가 오류가 발생한 직후 웹 페이지를 다시 로드하면 웹 페이지가 성공적으로 반환됩니다.
회사에서 문제를 해결하는 동안 솔루션 설계자는 방문자에게 표준 ALB 오류 페이지 대신 사용자 정의 오류 페이지를 제공해야 합니다.&lt;br /&gt;
최소한의 운영 오버헤드로 이 요구사항을 충족하는 단계의 조합은 무엇입니까? (두 개를 선택하십시오.)&lt;/p&gt;

&lt;p&gt;A. Amazon S3 버킷을 생성합니다. 정적 웹 페이지를 호스트하도록 S3 버킷을 구성합니다. 사용자 지정 오류 페이지를 Amazon S3에 업로드합니다.&lt;/p&gt;

&lt;p&gt;B. ALB 상태가 응답 Target을 확인하는 경우 Amazon CloudWatch 경보를 생성하여 AWS Lambda 함수를 호출합니다.실패한 상태 검사가 0보다 큽니다. 공용으로 액세스할 수 있는 웹 서버를 가리키도록 ALB에서 전달 규칙을 수정하도록 람다 기능을 구성합니다.&lt;/p&gt;

&lt;p&gt;C. 상태 점검을 추가하여 기존 Amazon Route 53 레코드를 수정합니다. 상태 검사가 실패할 경우 예비 대상을 구성합니다. 공개적으로 액세스할 수 있는 웹 페이지를 가리키도록 DNS 레코드를 수정합니다.&lt;/p&gt;

&lt;p&gt;D. ALB 상태 점검 응답 Elb인 경우 Amazon CloudWatch 경보를 생성하여 AWS 람다 함수를 호출합니다.내부 오류가 0보다 큽니다. ALB에서 전달 규칙이 액세스 가능한 공용 웹 서버를 가리키도록 람다 기능을 구성합니다.&lt;/p&gt;

&lt;p&gt;E. CloudFront 사용자 정의 오류 페이지를 구성하여 사용자 정의 오류 응답을 추가합니다. 공개적으로 액세스할 수 있는 웹 페이지를 가리키도록 DNS 레코드를 수정합니다.&lt;/p&gt;
&lt;details&gt;
&lt;summary&gt;원문 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
A retail company is operating its ecommerce application on AWS. The application runs on Amazon EC2 instances behind an Application Load Balancer (ALB). The company uses an Amazon RDS DB instance as the database backend. Amazon CloudFront is configured with one origin that points to the ALB. Static content is cached. Amazon Route 53 is used to host all public zones.&lt;br /&gt;
After an update of the application, the ALB occasionally returns a 502 status code (Bad Gateway) error. The root cause is malformed HTTP headers that are returned to the ALB. The webpage returns successfully when a solutions architect reloads the webpage immediately after the error occurs.&lt;br /&gt;
While the company is working on the problem, the solutions architect needs to provide a custom error page instead of the standard ALB error page to visitors.&lt;br /&gt;
Which combination of steps will meet this requirement with the LEAST amount of operational overhead? (Choose two.)&lt;/p&gt;

    &lt;p&gt;A. Create an Amazon S3 bucket. Configure the S3 bucket to host a static webpage. Upload the custom error pages to Amazon S3.&lt;/p&gt;

    &lt;p&gt;B. Create an Amazon CloudWatch alarm to invoke an AWS Lambda function if the ALB health check response Target.FailedHealthChecks is greater than 0. Configure the Lambda function to modify the forwarding rule at the ALB to point to a publicly accessible web server.&lt;/p&gt;

    &lt;p&gt;C. Modify the existing Amazon Route 53 records by adding health checks. Configure a fallback target if the health check fails. Modify DNS records to point to a publicly accessible webpage.&lt;/p&gt;

    &lt;p&gt;D. Create an Amazon CloudWatch alarm to invoke an AWS Lambda function if the ALB health check response Elb.InternalError is greater than 0. Configure the Lambda function to modify the forwarding rule at the ALB to point to a public accessible web server.&lt;/p&gt;

    &lt;p&gt;E. Add a custom error response by configuring a CloudFront custom error page. Modify DNS records to point to a publicly accessible web page.&lt;/p&gt;
  &lt;/div&gt;
&lt;/details&gt;

&lt;details&gt;
&lt;summary&gt;정답 및 해설 보기&lt;/summary&gt;
&lt;div&gt;
    &lt;p&gt;&lt;br /&gt;
Answer : A, E&lt;/p&gt;

    &lt;p&gt;해설 :&lt;/p&gt;

    &lt;p&gt;옵션 A를 사용하면 S3 버킷에서 호스팅할 수 있는 사용자 정의 오류 페이지를 생성할 수 있습니다. 옵션 E는 오류 페이지를 호스팅하는 S3 버킷을 가리킬 수 있는 CloudFront의 사용자 지정 오류 응답을 구성하는 방법을 제공합니다. 따라서 방문자는 애플리케이션 인프라를 수정하지 않고도 사용자 지정 오류 페이지를 볼 수 있습니다.&lt;/p&gt;

    &lt;p&gt;1차 시도 : B, E &lt;br /&gt;
2차 시도 : B, E &lt;br /&gt;&lt;/p&gt;
  &lt;/div&gt;
&lt;/details&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;hr /&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Ref
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;https://www.examtopics.com/exams/amazon/aws-certified-solutions-architect-professional-sap-c02/view/1/&quot;&gt;ExamTopics&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Tue, 14 Mar 2023 23:00:00 +0900</pubDate>
        <link>https://hjy.today/study/AWS-_SAP-C02_ExamTopics_1~10.html</link>
        <guid isPermaLink="true">https://hjy.today/study/AWS-_SAP-C02_ExamTopics_1~10.html</guid>
        
        <category>aws</category>
        
        <category>sap-c02</category>
        
        
        <category>study</category>
        
      </item>
    
      <item>
        <title>[ORACLE] 윈도우 콘솔에서 Oracle 접속</title>
        <description>&lt;p&gt;윈도우 콘솔로 Oracle에 접속해보자.&lt;/p&gt;

&lt;!--more--&gt;

&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#windows-콘솔에서-오라클-접속&quot; id=&quot;markdown-toc-windows-콘솔에서-오라클-접속&quot;&gt;Windows 콘솔에서 오라클 접속&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h1 id=&quot;windows-콘솔에서-오라클-접속&quot;&gt;Windows 콘솔에서 오라클 접속&lt;/h1&gt;
&lt;hr /&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;https://heoj10272.github.io/study/ORACLE-_%ED%99%98%EA%B2%BD_%EB%B3%80%EC%88%98_%ED%99%95%EC%9D%B8.html&quot;&gt;Oracle 환경 변수 확인&lt;/a&gt; 글에서처럼 환경 변수가 기본값으로 세팅되어 있을 경우&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; sqlplus / as sysdba
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;system&lt;/code&gt; 계정으로 접속&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; sqlplus system/[자신이 지정한 PW]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;나의 경우는 다음과 같다.&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; sqlplus system/password
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ol&gt;
</description>
        <pubDate>Mon, 13 Mar 2023 23:30:00 +0900</pubDate>
        <link>https://hjy.today/study/ORACLE-_%EC%9C%88%EB%8F%84%EC%9A%B0_%EC%BD%98%EC%86%94%EC%97%90%EC%84%9C_Oracle_%EC%A0%91%EC%86%8D.html</link>
        <guid isPermaLink="true">https://hjy.today/study/ORACLE-_%EC%9C%88%EB%8F%84%EC%9A%B0_%EC%BD%98%EC%86%94%EC%97%90%EC%84%9C_Oracle_%EC%A0%91%EC%86%8D.html</guid>
        
        <category>oracle</category>
        
        
        <category>study</category>
        
      </item>
    
      <item>
        <title>[ORACLE] 환경 변수 확인</title>
        <description>&lt;p&gt;Oracle 설치로 인한 오라클 관련 환경 변수를 확인해보자.&lt;/p&gt;

&lt;!--more--&gt;

&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#1-환경-변수-확인&quot; id=&quot;markdown-toc-1-환경-변수-확인&quot;&gt;1. 환경 변수 확인&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#2-실행-파일-path-경로-확인&quot; id=&quot;markdown-toc-2-실행-파일-path-경로-확인&quot;&gt;2. 실행 파일 %PATH% 경로 확인&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#3-oracle-사용자-인증-설정-확인&quot; id=&quot;markdown-toc-3-oracle-사용자-인증-설정-확인&quot;&gt;3. Oracle 사용자 인증 설정 확인&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#ref&quot; id=&quot;markdown-toc-ref&quot;&gt;Ref&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h1 id=&quot;1-환경-변수-확인&quot;&gt;1. 환경 변수 확인&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Oracle/2023-03-12-[ORACLE]_Oracle_19c_삭제/3.png&quot; alt=&quot;previous_3&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[Win]&lt;/code&gt; + &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[R]&lt;/code&gt; 또는 윈도우 검색에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;regedit&lt;/code&gt; 을 입력해서 레지스트리 편집기를 실행한다.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Oracle/2023-03-13-[ORACLE]_환경_변수_확인/1.png&quot; alt=&quot;1&quot; /&gt;&lt;/p&gt;

&lt;p&gt;레지스트리 편집기에서&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;컴퓨터\HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_OraDB19Home1&lt;/code&gt; 경로로 이동한 뒤 다음의 환경 변수를 확인할 수 있다.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;NLS_LANG&lt;/code&gt; : KOREAN_KOREA.KO16MSWIN949&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ORACLE_BASE&lt;/code&gt; : E:\app\oracle&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ORACLE_HOME&lt;/code&gt; : E:\app\oracle\product\19.3.0\dbhome_1&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ORACLE_SID&lt;/code&gt; : orcl&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;NLS_LANG&lt;/code&gt; 은 다음에 알아보도록 하자.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ORACLE_HOME&lt;/code&gt; 은 이전의 &lt;a href=&quot;https://heoj10272.github.io/study/ORACLE-_Oracle_19c_%EC%84%A4%EC%B9%98.html&quot;&gt;Oracle 19c 설치&lt;/a&gt; 글에서 설정한 &lt;strong&gt;Oracle 엔진이 설치되어 있는 위치&lt;/strong&gt;이다.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ORACLE_SID&lt;/code&gt; 는 &lt;strong&gt;데이터베이스 인스턴스 이름&lt;/strong&gt;이다.&lt;/p&gt;

&lt;h1 id=&quot;2-실행-파일-path-경로-확인&quot;&gt;2. 실행 파일 %PATH% 경로 확인&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;CMD를 키고, 환경 변수 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;%PATH%&lt;/code&gt; 값을 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;echo&lt;/code&gt; 명령으로 확인할 수 있다.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Oracle/2023-03-13-[ORACLE]_환경_변수_확인/2.png&quot; alt=&quot;2&quot; /&gt;&lt;/p&gt;

&lt;p&gt;위와 같이 환경 변수에 Oracle 실행파일 패스 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;E:\app\oracle\product\19.3.0\dbhome_1\bin;&lt;/code&gt; 가 지정되어 있는 것을 확인 할 수 있다.&lt;br /&gt;
이로 인해 Oracle 명령이 실행되는 경로에 존재하지 않아도 Oracle 명령을 실행 할 수 있는 것이다.&lt;/p&gt;

&lt;h1 id=&quot;3-oracle-사용자-인증-설정-확인&quot;&gt;3. Oracle 사용자 인증 설정 확인&lt;/h1&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;E:\app\oracle\product\19.3.0\dbhome_1\network\admin&lt;/code&gt; 경로로 이동한다.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Oracle/2023-03-13-[ORACLE]_환경_변수_확인/3.png&quot; alt=&quot;3&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sqlnet.ora&lt;/code&gt; 파일을 열어서 내용을 확인해보자.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Oracle/2023-03-13-[ORACLE]_환경_변수_확인/4.png&quot; alt=&quot;4&quot; /&gt;&lt;/p&gt;

&lt;p&gt;이 중에 8번째 줄을 주목해보자.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;SQLNET.AUTHENTICATION_SERVICES= (NTS)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;값이 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;NTS&lt;/code&gt;로 정의되어 있을 경우, 이는 Windows의 사용자 정보를 이용하여 Oracle 인스턴스에 대한 접속 여부를 현재 로그인 된 Windows의 사용자 권한으로 판단한다는 것을 의미한다.&lt;/p&gt;

&lt;p&gt;이 경우 현재 접속중인 사용자 계정이 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ORA_DBA&lt;/code&gt; 그룹에 속해있다면,&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sqlplus / as sysdba
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;위 명령을 통해 Oracle에 접속할 수 있다.&lt;/p&gt;

&lt;h1 id=&quot;ref&quot;&gt;Ref&lt;/h1&gt;
&lt;hr /&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.zinnunkebi.com/oracle-database-19-3-0-install/&quot;&gt;zinnunkebi blog&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Mon, 13 Mar 2023 23:20:00 +0900</pubDate>
        <link>https://hjy.today/study/ORACLE-_%ED%99%98%EA%B2%BD_%EB%B3%80%EC%88%98_%ED%99%95%EC%9D%B8.html</link>
        <guid isPermaLink="true">https://hjy.today/study/ORACLE-_%ED%99%98%EA%B2%BD_%EB%B3%80%EC%88%98_%ED%99%95%EC%9D%B8.html</guid>
        
        <category>oracle</category>
        
        
        <category>study</category>
        
      </item>
    
      <item>
        <title>[ORACLE] Oracle 19c 삭제</title>
        <description>&lt;p&gt;윈도우에 설치한 Oracle 19c를 삭제해보자.&lt;/p&gt;

&lt;!--more--&gt;

&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#1-oracle-관련-서비스-중지&quot; id=&quot;markdown-toc-1-oracle-관련-서비스-중지&quot;&gt;1. Oracle 관련 서비스 중지&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#2-oracle-관련-레지스트리-삭제&quot; id=&quot;markdown-toc-2-oracle-관련-레지스트리-삭제&quot;&gt;2. Oracle 관련 레지스트리 삭제&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#3-재부팅&quot; id=&quot;markdown-toc-3-재부팅&quot;&gt;3. 재부팅&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#4-oracle-관련-파일-삭제&quot; id=&quot;markdown-toc-4-oracle-관련-파일-삭제&quot;&gt;4. Oracle 관련 파일 삭제&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#ref&quot; id=&quot;markdown-toc-ref&quot;&gt;Ref&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;p&gt;Oracle 19c를 설치할 때 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;setup&lt;/code&gt; 파일을 관리자 권한으로 실행하지 않았다가 한 번 …&lt;br /&gt;
경로를 잘못 설정해서 다시 한 번 삭제를 하게 되었다.&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;deinstall.bat&lt;/code&gt; 파일이 있기는 하지만, 나의 경우는 잘 실행되지 않아 수동으로 삭제하는 방법을 기록하기로 했다.&lt;/p&gt;

&lt;h1 id=&quot;1-oracle-관련-서비스-중지&quot;&gt;1. Oracle 관련 서비스 중지&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Oracle/2023-03-12-[ORACLE]_Oracle_19c_삭제/1.png&quot; alt=&quot;1&quot; /&gt;&lt;/p&gt;

&lt;p&gt;먼저 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[서비스]&lt;/code&gt;를 윈도우에서 검색하여 실행해준다.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Oracle/2023-03-12-[ORACLE]_Oracle_19c_삭제/2.png&quot; alt=&quot;2&quot; /&gt;&lt;/p&gt;

&lt;p&gt;이후 Oracle로 시작하는 모든 서비스를 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;우클릭&lt;/code&gt; - &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[중지(O)]&lt;/code&gt; 를 클릭하여 중지한다.&lt;br /&gt;
금방 되는것도 있고, 약간 시간이 걸리는 것도 있다.&lt;/p&gt;

&lt;h1 id=&quot;2-oracle-관련-레지스트리-삭제&quot;&gt;2. Oracle 관련 레지스트리 삭제&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Oracle/2023-03-12-[ORACLE]_Oracle_19c_삭제/3.png&quot; alt=&quot;3&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[Win]&lt;/code&gt; + &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;R&lt;/code&gt; 또는 윈도우 검색에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;regedit&lt;/code&gt; 을 입력하여 레지스트리 편집기를 실행한다.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Oracle/2023-03-12-[ORACLE]_Oracle_19c_삭제/4.png&quot; alt=&quot;4&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HKEY_LOCAL_MACHINE/SOFTWARE/ORACLE&lt;/code&gt; 폴더 삭제&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Oracle/2023-03-12-[ORACLE]_Oracle_19c_삭제/5.png&quot; alt=&quot;5&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services&lt;/code&gt; 경로 내의 모든 Oracle 관련 폴더 삭제&lt;/p&gt;

&lt;p&gt;추가로, 다음의 경로 내에 있는 Oracle 관련 폴더도 있으면 삭제한다.&lt;br /&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Services&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HKEY_CLASSES_ROOT&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;나는 한 번 지웠어서 그런지 보이지 않는다…&lt;/p&gt;

&lt;h1 id=&quot;3-재부팅&quot;&gt;3. 재부팅&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;레지스트리까지 다 지웠으면, 재부팅을 한다.&lt;/p&gt;

&lt;h1 id=&quot;4-oracle-관련-파일-삭제&quot;&gt;4. Oracle 관련 파일 삭제&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;아래 경로를 하나씩 뒤져보면서 해당되는 파일들을 모두 삭제한다.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;C:\Oracle&lt;/code&gt; 또는 Oracle을 설치한 드라이브의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Oracle&lt;/code&gt; 폴더&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;C:\Program Files\Oracle&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;C:\Program Files (x86)\Oracle&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;C:\ProgramData\Microsoft\Windows\Start Menu\Programs\&lt;/code&gt; 폴더 내의 Oracle 관련 폴더&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;C:\Users&lt;/code&gt; 폴더 내의 Oracle 관련 폴더&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;이후 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;C:\Temp&lt;/code&gt; 폴더까지 비워준다.&lt;/p&gt;

&lt;p&gt;이제 삭제가 완료되었다.&lt;/p&gt;

&lt;h1 id=&quot;ref&quot;&gt;Ref&lt;/h1&gt;
&lt;hr /&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://oracle-base.com/articles/misc/manual-oracle-uninstall&quot;&gt;Oracle-Base&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Sun, 12 Mar 2023 22:20:00 +0900</pubDate>
        <link>https://hjy.today/study/ORACLE-_Oracle_19c_%EC%82%AD%EC%A0%9C.html</link>
        <guid isPermaLink="true">https://hjy.today/study/ORACLE-_Oracle_19c_%EC%82%AD%EC%A0%9C.html</guid>
        
        <category>oracle</category>
        
        
        <category>study</category>
        
      </item>
    
      <item>
        <title>[ORACLE] Oracle 19c 설치</title>
        <description>&lt;p&gt;윈도우에 Oracle 19c를 설치해보자.&lt;/p&gt;

&lt;!--more--&gt;

&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#1-oracle-설치-파일-다운&quot; id=&quot;markdown-toc-1-oracle-설치-파일-다운&quot;&gt;1. Oracle 설치 파일 다운&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#2-경로-설정&quot; id=&quot;markdown-toc-2-경로-설정&quot;&gt;2. 경로 설정&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#3-oracle-설치&quot; id=&quot;markdown-toc-3-oracle-설치&quot;&gt;3. Oracle 설치&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h1 id=&quot;1-oracle-설치-파일-다운&quot;&gt;1. Oracle 설치 파일 다운&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;&lt;a href=&quot;https://www.oracle.com/kr/database/technologies/oracle-database-software-downloads.html&quot;&gt;Oracle Database Software Downloads&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;위 링크로 들어가서 윈도우용 Oracle 설치 파일을 다운받자.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Oracle/2023-03-08-[ORACLE]_Oracle_19c_설치/1.png&quot; alt=&quot;1&quot; /&gt;&lt;/p&gt;

&lt;p&gt;표시한 부분의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ZIP&lt;/code&gt; 파일을 다운받으면 된다.&lt;br /&gt;
좀 오래 걸린다.&lt;br /&gt;&lt;/p&gt;

&lt;h1 id=&quot;2-경로-설정&quot;&gt;2. 경로 설정&lt;/h1&gt;

&lt;p&gt;Oracle을 설치할 기본 경로를 설정해야 한다.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;C:\app\oracle\product\19.3.0\dbhome_1&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;위와 같은 경로를 만들고, 이 안에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;WINDOWS.X64_193000_db_home.zip&lt;/code&gt; 압축파일을 풀어주자.&lt;br /&gt;
나는 저장공간 이슈로 C드라이브가 아닌 D드라이브에 설치했다.&lt;/p&gt;

&lt;h1 id=&quot;3-oracle-설치&quot;&gt;3. Oracle 설치&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Oracle/2023-03-08-[ORACLE]_Oracle_19c_설치/2.png&quot; alt=&quot;2&quot; /&gt;&lt;/p&gt;

&lt;p&gt;표시한 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;setup.exe&lt;/code&gt; 설치 파일을 &lt;strong&gt;관리자 권한으로&lt;/strong&gt; 실행하자.&lt;br /&gt;
권리자 권한으로 실행하지 않으면 설치 중간에 멈추는 현상이 발생한다(경험담).&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Oracle/2023-03-08-[ORACLE]_Oracle_19c_설치/3.png&quot; alt=&quot;3&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[단일 인스턴스 데이터베이스 생성 및 구성(C)]&lt;/code&gt; 선택&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Oracle/2023-03-08-[ORACLE]_Oracle_19c_설치/4.png&quot; alt=&quot;4&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[서버 클래스(S)]&lt;/code&gt; 선택&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Oracle/2023-03-08-[ORACLE]_Oracle_19c_설치/5.png&quot; alt=&quot;5&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[표준 설치(T)]&lt;/code&gt; 선택&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Oracle/2023-03-08-[ORACLE]_Oracle_19c_설치/6.png&quot; alt=&quot;6&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[가상 계정 사용(V)]&lt;/code&gt; 선택&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Oracle/2023-03-08-[ORACLE]_Oracle_19c_설치/7.png&quot; alt=&quot;7&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[Oracle Base(S)]&lt;/code&gt; 에서 오라클을 설치할 경로를 선택한다.&lt;br /&gt;
디폴트로 드라이브 루트 경로가 지정되어 있는데, 해당 경로에는 설치가 불가하므로 폴더를 하나 생성해서 지정해주자.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[비밀번호(P)]&lt;/code&gt; 에는 원하는 비밀번호를 입력한다.&lt;br /&gt;
반드시 메모해 놓도록 하자.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Oracle/2023-03-08-[ORACLE]_Oracle_19c_설치/8.png&quot; alt=&quot;8&quot; /&gt;&lt;/p&gt;

&lt;p&gt;이후 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[다음]&lt;/code&gt; 을 누르면 위와 같은 경고문이 뜨는데, 무시하고 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[예(Y)]&lt;/code&gt; 를 누르면 된다.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Oracle/2023-03-08-[ORACLE]_Oracle_19c_설치/9.png&quot; alt=&quot;9&quot; /&gt;&lt;/p&gt;

&lt;p&gt;요약을 확인하고, [설치(I)] 를 클릭&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Oracle/2023-03-08-[ORACLE]_Oracle_19c_설치/10.png&quot; alt=&quot;10&quot; /&gt;&lt;/p&gt;

&lt;p&gt;설치가 진행되는데, 상당히 오래 걸리니까 다른걸 하다가 다시 오자.&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Oracle/2023-03-08-[ORACLE]_Oracle_19c_설치/11.png&quot; alt=&quot;11&quot; /&gt;&lt;/p&gt;

&lt;p&gt;설치 완료.&lt;/p&gt;
</description>
        <pubDate>Wed, 08 Mar 2023 23:20:00 +0900</pubDate>
        <link>https://hjy.today/study/ORACLE-_Oracle_19c_%EC%84%A4%EC%B9%98.html</link>
        <guid isPermaLink="true">https://hjy.today/study/ORACLE-_Oracle_19c_%EC%84%A4%EC%B9%98.html</guid>
        
        <category>oracle</category>
        
        
        <category>study</category>
        
      </item>
    
      <item>
        <title>[DBeaver] 단축키</title>
        <description>&lt;!--more--&gt;

&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#단축키&quot; id=&quot;markdown-toc-단축키&quot;&gt;단축키&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h1 id=&quot;단축키&quot;&gt;단축키&lt;/h1&gt;
&lt;hr /&gt;

&lt;ul&gt;
  &lt;li&gt;해당 행 실행&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ctrl&lt;/code&gt; + &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Enter&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;전체 데이터 스캔&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ctrl&lt;/code&gt; + &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Alt&lt;/code&gt; + &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Shift&lt;/code&gt; + &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;A&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;실행 계획 보기&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ctrl&lt;/code&gt; + &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Shift&lt;/code&gt; + &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;E&lt;/code&gt;&lt;/p&gt;
</description>
        <pubDate>Mon, 09 Jan 2023 22:10:00 +0900</pubDate>
        <link>https://hjy.today/study/DBeaver-_%EB%8B%A8%EC%B6%95%ED%82%A4.html</link>
        <guid isPermaLink="true">https://hjy.today/study/DBeaver-_%EB%8B%A8%EC%B6%95%ED%82%A4.html</guid>
        
        <category>dbeaver</category>
        
        
        <category>study</category>
        
      </item>
    
      <item>
        <title>[Go] #4.3 자료형의 변환</title>
        <description>&lt;p&gt;강의 링크 : 
&lt;a href=&quot;https://edu.goorm.io/learn/lecture/2010/%ED%95%9C-%EB%88%88%EC%97%90-%EB%81%9D%EB%82%B4%EB%8A%94-%EA%B3%A0%EB%9E%AD-%EA%B8%B0%EC%B4%88/lesson/215148/%EC%9E%90%EB%A3%8C%ED%98%95%EC%9D%98-%EB%B3%80%ED%99%98&quot;&gt;한 눈에 끝내는 고랭 기초 #3 자료형 - 자료형의 변환&lt;/a&gt;&lt;/p&gt;

&lt;!--more--&gt;

&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#3-자료형의-변환&quot; id=&quot;markdown-toc-3-자료형의-변환&quot;&gt;3. 자료형의 변환&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h1 id=&quot;3-자료형의-변환&quot;&gt;3. 자료형의 변환&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;int&lt;/code&gt; 형으로 표현되어 있는 데이터 표현 방식을 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;float32&lt;/code&gt; 형으로 바꾸거나, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;int&lt;/code&gt; 형으로 표현되어 있는 데이터의 표현 방식을 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;uint&lt;/code&gt; 형으로 바꾸는 것이 바로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;자료형의 변환&lt;/code&gt; 이다.&lt;br /&gt;
즉, 자료형의 변환이라는 것은 데이터의 표현 방식을 바꾸는 것이다.&lt;br /&gt;
이러한 자료형의 변환은 다른 언어들을 비추어 보았을 때 크게 두 종류가 있다.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;자동 형 변환(묵시적 형 변환)&lt;/li&gt;
  &lt;li&gt;강제 형 변환(명시적 형 변환)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;이름에서 볼 수 있듯이 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;자동 형 변환&lt;/code&gt; 은 자동으로 발생하는 형 변환이고,&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;강제 형 변환&lt;/code&gt; 은 프로그래머가 형 변환을 명시해서 강제로 변환이 일어나게 하는 것이다.&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;그런데 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Go&lt;/code&gt; 언어에서는 형 변환을 할 때 변환을 명시적으로 지정해 주어야 한다.&lt;br /&gt;
예를 들어 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;float32&lt;/code&gt; 에서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;uint&lt;/code&gt; 로 변환할 때, 암묵적 변환은 일어나지 않으므로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;uint(변수이름)&lt;/code&gt; 과 같이 반드시 변환을 지정해 주어야 한다.&lt;br /&gt;
만약 명시적 지정이 없다면 런타임 에러가 발생한다.&lt;/p&gt;

&lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;fmt&quot;&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;func&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;changef&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;float32&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;float32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;//int형을 float32형으로 변환&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;changei&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;int8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;               &lt;span class=&quot;c1&quot;&gt;//int형을 int8형으로 변환&lt;/span&gt;

	&lt;span class=&quot;n&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;str&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;goorm&quot;&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;changestr&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;byte&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;//바이트 배열&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;str2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;changestr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;//바이트 배열을 다시 문자열로 변환&lt;/span&gt;

	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;changef&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;changei&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;changestr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;str2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// 실행 결과&lt;/span&gt;

&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;goorm&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;103&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;111&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;111&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;114&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;109&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;goorm&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;byte&lt;/code&gt; 형으로 형 변환이 이루어졌을 때 각 알파벳의 아스키코드가 배열 형식으로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;쉼표(,)&lt;/code&gt; 없이 출력됨에 주의.&lt;/p&gt;

&lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;fmt&quot;&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;func&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num2&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;
	
	&lt;span class=&quot;n&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;float32&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num2&lt;/span&gt;	
	
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;%f&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// 실행 결과&lt;/span&gt;

&lt;span class=&quot;cp&quot;&gt;# command-line-arguments
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;go&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cannot&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num2&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;float32&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;assignment&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;make&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;***&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cmd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Error&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;위 코드는 에러를 반환한다.&lt;br /&gt;
그 이유는, 연산식의 결괏값과 그것을 저장하려는 변수의 자료형이 다르기 때문이다.&lt;br /&gt;
위에서 언급했던 것처럼 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Go&lt;/code&gt; 언어는 자동으로 형 변환이 되지 않으므로, 에러가 발생한다.&lt;br /&gt;
연산의 결괏값의 자료형과 피연산자의 자료형이 일치해야하므로, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;num1&lt;/code&gt;과 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;num2&lt;/code&gt;를 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;float32&lt;/code&gt; 형으로 형 변환을 해야한다.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;var result float32 = float32(num1 / num2)&lt;/code&gt;
    &lt;ul&gt;
      &lt;li&gt;이렇게 하면 결과가 나오긴 하나 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0.000000&lt;/code&gt; 으로 의도와 다른 값이 나온다.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;var result float32 = float32(num1) / float32(num2)&lt;/code&gt;
    &lt;ul&gt;
      &lt;li&gt;이렇게 하면 결과가 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0.750000&lt;/code&gt; 으로 잘 나온다.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ol&gt;
</description>
        <pubDate>Fri, 30 Dec 2022 01:40:00 +0900</pubDate>
        <link>https://hjy.today/study/Go-_4.3_%EC%9E%90%EB%A3%8C%ED%98%95%EC%9D%98_%EB%B3%80%ED%99%98.html</link>
        <guid isPermaLink="true">https://hjy.today/study/Go-_4.3_%EC%9E%90%EB%A3%8C%ED%98%95%EC%9D%98_%EB%B3%80%ED%99%98.html</guid>
        
        <category>go</category>
        
        
        <category>study</category>
        
      </item>
    
      <item>
        <title>[Go] #4.2 문자열의 표현</title>
        <description>&lt;p&gt;강의 링크 : 
&lt;a href=&quot;https://edu.goorm.io/learn/lecture/2010/%ED%95%9C-%EB%88%88%EC%97%90-%EB%81%9D%EB%82%B4%EB%8A%94-%EA%B3%A0%EB%9E%AD-%EA%B8%B0%EC%B4%88/lesson/215147/%EB%AC%B8%EC%9E%90%EC%97%B4%EC%9D%98-%ED%91%9C%ED%98%84&quot;&gt;한 눈에 끝내는 고랭 기초 #3 자료형 - 문자열의 표현&lt;/a&gt;&lt;/p&gt;

&lt;!--more--&gt;

&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#2-문자열의-표현&quot; id=&quot;markdown-toc-2-문자열의-표현&quot;&gt;2. 문자열의 표현&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h1 id=&quot;2-문자열의-표현&quot;&gt;2. 문자열의 표현&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;여러 자료형 중에서도 특히 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Go&lt;/code&gt; 언어에서는 문자열을 표현하는 데 두 가지 방법이 있다.&lt;br /&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;첫 번째는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Back Quote(`)&lt;/code&gt; 을 이용한 방법이다. 모양이 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;인용부호(&apos;&apos;)&lt;/code&gt; 와 비슷해서 혼동할 수 있지만 다른 기호이다. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Back Quote&lt;/code&gt; 로 둘러 싸인 문자열은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Raw String Literal&lt;/code&gt; 이라고 부른다. 쉽게 말하면, 이 안에 있는 문자열은 어느 기호든 문자열 자체로 인식되는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Raw String&lt;/code&gt; 값이라는 것이다. 예를 들어, 개발자라면 익숙하게 알고 있는 이 이스케이프 시퀀스가 특별한 의미로 인식되지 않는다는 것이다. 개행의 의미를 가지고 있는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;\n&lt;/code&gt; 이 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Back Quote&lt;/code&gt; 안에 있으면 개행 기능이 되지 않고 문자열 자체로 출력된다.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;두 번째는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;이중인용부호(&quot;&quot;)&lt;/code&gt; 를 이용한 방법이다. 이중인용부호로 둘러싸인 문자열은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Interpreted String Literal&lt;/code&gt; 이라고 부른다. 쉽게 말해, 안에 있는 문자열에 이스케이프 시퀀스 같은 문자열들은 특별한 의미로 해석되어 그 기능을 수행한다는 것이다. 그리고 이중인용부호를 사용할 시에 복수라인에 걸쳐 쓸 수 없다. 코딩을 할 때 아무리 엔터를 치고 길게 쳐도 한 줄에 표현된다는 뜻이다. 하지만 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;\n&lt;/code&gt; 과 같은 기호가 있으면 개행의 의미로 해석되어 여러 라인에 걸쳐 쓸 수 있다.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;그리고 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;+&lt;/code&gt; 연산자는 숫자 뿐만이 아니라 문자열도 합할 수 있다고 했다.&lt;br /&gt;
따라서 두 방법 모두 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;+&lt;/code&gt; 연산자를 이용해서 결합해 표현할 수 있다.&lt;/p&gt;

&lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;fmt&quot;&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;func&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;c1&quot;&gt;// Raw String Literal. 복수라인.&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rawLiteral&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;`바로&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;실행해보면서&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;배우는&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Golang&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;`&lt;/span&gt;

	&lt;span class=&quot;c1&quot;&gt;// Interpreted String Literal&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;interLiteral&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;바로 실행해보면서 배우는 &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Golang&quot;&lt;/span&gt;

	&lt;span class=&quot;n&quot;&gt;plusString&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;구름 &quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;EDU&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Golang&quot;&lt;/span&gt;

	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rawLiteral&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;interLiteral&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plusString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// 실행 결과&lt;/span&gt;

&lt;span class=&quot;err&quot;&gt;바로&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;실행해보면서&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;배우는&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Golang&lt;/span&gt;

&lt;span class=&quot;err&quot;&gt;바로&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;실행해보면서&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;배우는&lt;/span&gt; 
&lt;span class=&quot;n&quot;&gt;Golang&lt;/span&gt;

&lt;span class=&quot;err&quot;&gt;구름&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;EDU&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;Golang&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
        <pubDate>Fri, 30 Dec 2022 01:00:00 +0900</pubDate>
        <link>https://hjy.today/study/Go-_4.2_%EB%AC%B8%EC%9E%90%EC%97%B4%EC%9D%98_%ED%91%9C%ED%98%84.html</link>
        <guid isPermaLink="true">https://hjy.today/study/Go-_4.2_%EB%AC%B8%EC%9E%90%EC%97%B4%EC%9D%98_%ED%91%9C%ED%98%84.html</guid>
        
        <category>go</category>
        
        
        <category>study</category>
        
      </item>
    
      <item>
        <title>[Go] #4.1 자료형의 종류와 특징</title>
        <description>&lt;p&gt;강의 링크 : 
&lt;a href=&quot;https://edu.goorm.io/learn/lecture/2010/%ED%95%9C-%EB%88%88%EC%97%90-%EB%81%9D%EB%82%B4%EB%8A%94-%EA%B3%A0%EB%9E%AD-%EA%B8%B0%EC%B4%88/lesson/174438/%EC%9E%90%EB%A3%8C%ED%98%95%EC%9D%98-%EC%A2%85%EB%A5%98%EC%99%80-%ED%8A%B9%EC%A7%95&quot;&gt;한 눈에 끝내는 고랭 기초 #3 자료형 - 자료형의 종류와 특징&lt;/a&gt;&lt;/p&gt;

&lt;!--more--&gt;

&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#1-자료형의-종류와-특징&quot; id=&quot;markdown-toc-1-자료형의-종류와-특징&quot;&gt;1. 자료형의 종류와 특징&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#i-몇-바이트인지는-어떻게-아는가&quot; id=&quot;markdown-toc-i-몇-바이트인지는-어떻게-아는가&quot;&gt;I. 몇 바이트인지는 어떻게 아는가?&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#ii-부울린boolean-타입&quot; id=&quot;markdown-toc-ii-부울린boolean-타입&quot;&gt;II. 부울린(Boolean) 타입&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#iii-정수-타입&quot; id=&quot;markdown-toc-iii-정수-타입&quot;&gt;III. 정수 타입&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#iv-실수-및-복소수-타입&quot; id=&quot;markdown-toc-iv-실수-및-복소수-타입&quot;&gt;IV. 실수 및 복소수 타입&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#v-문자열-타입&quot; id=&quot;markdown-toc-v-문자열-타입&quot;&gt;V. 문자열 타입&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#vi-기타-타입&quot; id=&quot;markdown-toc-vi-기타-타입&quot;&gt;VI. 기타 타입&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h1 id=&quot;1-자료형의-종류와-특징&quot;&gt;1. 자료형의 종류와 특징&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;변수는 데이터의 저장을 위해서 할당된 메모리 공간에 붙여진 이름이다.&lt;/p&gt;

&lt;p&gt;그런데 메모리 공간 할당에 앞서, 할당된 메모리에 정수를 저장할 것인지, 실수를 저장할 것인지가 결정되어야 한다.&lt;/p&gt;

&lt;p&gt;또한, 정수를 저장한다면 몇 바이트의 크기를 사용할 것인지도 정한 후에 할당하는 것이 좋다.&lt;/p&gt;

&lt;p&gt;이렇게 어떤 데이터를 저장할 지를 표현하는 것이 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;자료형&lt;/code&gt; 이다.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Go&lt;/code&gt; 에서 쓸 수 있는 자료형은 다음과 같다.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;부울린(bool) 타입&lt;/li&gt;
  &lt;li&gt;문자열 타입&lt;/li&gt;
  &lt;li&gt;정수형 타입&lt;/li&gt;
  &lt;li&gt;실수 타입&lt;/li&gt;
  &lt;li&gt;복소수 타입&lt;/li&gt;
  &lt;li&gt;기타 타입들&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Go&lt;/code&gt; 언어의 특징인 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;:=&lt;/code&gt; 용법을 활용한 자료형 추론이 가능하다.&lt;/p&gt;

&lt;p&gt;예를 들어 정수값은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;int&lt;/code&gt; , 실수 값은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;float32&lt;/code&gt; 로 자동 할당된다.&lt;/p&gt;

&lt;p&gt;이와 같은 자료형의 종류를 알아보자.&lt;/p&gt;

&lt;h2 id=&quot;i-몇-바이트인지는-어떻게-아는가&quot;&gt;I. 몇 바이트인지는 어떻게 아는가?&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;자료형은 데이터의 형이 무엇인지 알려주는 역할도 하지만, 메모리를 몇 바이트 할당할 것인지 정하는 것도 중요하다.&lt;/p&gt;

&lt;p&gt;이때 다른 언어에서 보통 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sizeof&lt;/code&gt; 함수를 사용하는데, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Go&lt;/code&gt; 언어에서도 동일한 함수를 사용할 수 있다.&lt;/p&gt;

&lt;p&gt;이를 위해 코드 상단에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;import &quot;unsafe&quot;&lt;/code&gt; 를 입력하면 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;unsafe.Sizeof(변수)&lt;/code&gt; 형태를 사용하여 선언한 자료형의 크기를 알 수 있다.&lt;/p&gt;

&lt;h2 id=&quot;ii-부울린boolean-타입&quot;&gt;II. 부울린(Boolean) 타입&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;보통 불, 불린, 불리언 등으로 부르는데, 구름에서는 부울린이라고 하나보다.&lt;/p&gt;

&lt;p&gt;살짝 궁금해져서 찾아봤더니, 원문이 수학자인 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;조지 불(George Boole)&lt;/code&gt;의 이름에서 유래하였다고 한다.&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~의&lt;/code&gt; 를 의미하는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-an&lt;/code&gt; 이 붙어 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Boolean&lt;/code&gt; 이 되어 버렸지만, 올바른 표기는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;불의 연산자(Boolean Operator)&lt;/code&gt; 이므로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;불&lt;/code&gt; 이라고 부르는게 맞다고 한다.&lt;br /&gt;
해당 글에서는 구름에서 채택한 용어인 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;부울린&lt;/code&gt;을 일단 따르도록 하겠다.&lt;/p&gt;

&lt;p&gt;부울린 타입은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;참/거짓&lt;/code&gt; 을 할당할 수 있는 자료형이다.&lt;br /&gt;
다른 언어에서는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0/1&lt;/code&gt; 혹은 0과 다른 숫자로 표현하여 참 거짓을 표현할 수 있지만, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Go&lt;/code&gt; 언어에서는 오로지 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;true/false&lt;/code&gt; 만 사용하여 할당할 수 있다.&lt;br /&gt;
그리고 부울린 타입은 1바이트로 할당된다.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;자료형&lt;/th&gt;
      &lt;th&gt;선언&lt;/th&gt;
      &lt;th&gt;크기(byte)&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;부울린&lt;/td&gt;
      &lt;td&gt;bool&lt;/td&gt;
      &lt;td&gt;1&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h2 id=&quot;iii-정수-타입&quot;&gt;III. 정수 타입&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;자료형을 선언할 때 가장 많이 쓰이는 정수형 타입이다.&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Go/2022-12-27-[Go]_4.1_자료형의_종류와_특징/1.png&quot; alt=&quot;1&quot; /&gt;&lt;/p&gt;

&lt;p&gt;이 중 눈에 띄는 것은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;uintptr&lt;/code&gt; 인데 이는 포인터의 비트 패턴을 할당할만한 크기의 자료형이다.&lt;br /&gt;
주로 포인터의 주소를 할당할 때 사용한다.&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Go&lt;/code&gt; 언어에서는 한눈에 자료형의 크기를 확인할 수 있게 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;int16&lt;/code&gt; , &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;int32&lt;/code&gt; 와 같은 형태로 표현하고, 뒤에 붙은 숫자는 비트를 의미한다.&lt;br /&gt;
즉, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;int32&lt;/code&gt; 는 32비트의 크기를 의미한다.&lt;/p&gt;

&lt;p&gt;그리고 앞에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;u&lt;/code&gt; 가 붙은 자료형은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;C&lt;/code&gt; 언어와 다른 언어들에서 쓰이는 0과 양의 정수만 표현하는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;unsigned&lt;/code&gt; 와 같다.&lt;br /&gt;
예를 들어 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;uint&lt;/code&gt; 는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;C&lt;/code&gt; 언어에서의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;unsigned int&lt;/code&gt; 와 같다.
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;unsigned&lt;/code&gt; 선언은 0과 양수만 표현하는 것이기 때문에 음수 표현 범위가 줄어든 만큼 양수 표현 범위가 두 배가 된다.&lt;/p&gt;

&lt;h2 id=&quot;iv-실수-및-복소수-타입&quot;&gt;IV. 실수 및 복소수 타입&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;실수형과 정수형 타입은 비교적 표현할 수 있는 값의 범위가 매우 넓다.&lt;br /&gt;
이러한 자료형의 중요한 선택 요소는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;정밀도&lt;/code&gt; 이다.&lt;br /&gt;
복소수 선언은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;3+4i&lt;/code&gt; 처럼 선언할 수 있다.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Go/2022-12-27-[Go]_4.1_자료형의_종류와_특징/2.png&quot; alt=&quot;2&quot; /&gt;&lt;/p&gt;

&lt;p&gt;복소수는 써 본 적이 없는 것 같은데, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Go&lt;/code&gt; 에서는 사용하게 될 지 의문이다.&lt;/p&gt;

&lt;h2 id=&quot;v-문자열-타입&quot;&gt;V. 문자열 타입&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;문자열 타입은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&quot;&quot;&lt;/code&gt; 와 같이 비어있을 수 있고, 다른 언어에서 표현되는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;null&lt;/code&gt; 과 같이 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Go&lt;/code&gt; 언어에서 사용되는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nil(널 포인터의 이름)&lt;/code&gt; 이 아닐 수 있다.&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;string&lt;/code&gt; 으로 선언한 문자열 타입은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;immutable(불변)&lt;/code&gt; 타입으로서 값을 수정할 수 없다.&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;예를 들어, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;var str string = &quot;hello&quot;&lt;/code&gt; 와 같이 선언하고 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;str[2] = &apos;a&apos;&lt;/code&gt; 로 수정이 불가능하다.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Go/2022-12-27-[Go]_4.1_자료형의_종류와_특징/3.png&quot; alt=&quot;3&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;vi-기타-타입&quot;&gt;VI. 기타 타입&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;기타 타입은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;byte&lt;/code&gt; 와 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rune&lt;/code&gt; 자료형이 있다.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;byte&lt;/code&gt; 는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;uint8&lt;/code&gt; 과 똑같은 자료형이라고 생각할 수 있다.&lt;br /&gt;
바이트 값을 8비트 부호 없는 정수 값과 구별하는데 사용된다.&lt;/p&gt;

&lt;p&gt;그리고 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rune&lt;/code&gt; 은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;int32&lt;/code&gt;와 똑같은 자료형이라고 볼 수 있다.&lt;br /&gt;
관례상 문자 값을 정수 값과 구별하기 위해 사용한다.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Go/2022-12-27-[Go]_4.1_자료형의_종류와_특징/4.png&quot; alt=&quot;4&quot; /&gt;&lt;/p&gt;
</description>
        <pubDate>Tue, 27 Dec 2022 20:30:00 +0900</pubDate>
        <link>https://hjy.today/study/Go-_4.1_%EC%9E%90%EB%A3%8C%ED%98%95%EC%9D%98_%EC%A2%85%EB%A5%98%EC%99%80_%ED%8A%B9%EC%A7%95.html</link>
        <guid isPermaLink="true">https://hjy.today/study/Go-_4.1_%EC%9E%90%EB%A3%8C%ED%98%95%EC%9D%98_%EC%A2%85%EB%A5%98%EC%99%80_%ED%8A%B9%EC%A7%95.html</guid>
        
        <category>go</category>
        
        
        <category>study</category>
        
      </item>
    
      <item>
        <title>[Go] #3.3 콘솔 입력 함수의 기본</title>
        <description>&lt;p&gt;강의 링크 : 
&lt;a href=&quot;https://edu.goorm.io/learn/lecture/2010/%ED%95%9C-%EB%88%88%EC%97%90-%EB%81%9D%EB%82%B4%EB%8A%94-%EA%B3%A0%EB%9E%AD-%EA%B8%B0%EC%B4%88/lesson/268847/%EC%BD%98%EC%86%94-%EC%9E%85%EB%A0%A5-%ED%95%A8%EC%88%98%EC%9D%98-%EA%B8%B0%EB%B3%B8&quot;&gt;한 눈에 끝내는 고랭 기초 #3 연산자 - 콘솔 입력 함수의 기본&lt;/a&gt;&lt;/p&gt;

&lt;!--more--&gt;

&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#3-콘솔-입력-함수의-기본&quot; id=&quot;markdown-toc-3-콘솔-입력-함수의-기본&quot;&gt;3. 콘솔 입력 함수의 기본&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h1 id=&quot;3-콘솔-입력-함수의-기본&quot;&gt;3. 콘솔 입력 함수의 기본&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;이전의 &lt;a href=&quot;https://heoj10272.github.io/study/Go-_2.1_%EC%BD%98%EC%86%94-%EC%B6%9C%EB%A0%A5-%ED%95%A8%EC%88%98%EC%9D%98-%EA%B8%B0%EB%B3%B8.html&quot;&gt;콘솔 출력 함수&lt;/a&gt;는 프로그램이 실행된 후에 결과값을 콘솔 화면에 출력해준다.&lt;br /&gt;
마찬가지로 콘솔 입력 함수는 프로그램 사용자가 값을 입력할 수 있다.&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;자세한건 추후에 다시 보고, 간단히 알아보도록 하자.&lt;/p&gt;

&lt;p&gt;기본적으로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;C&lt;/code&gt; 계열에서 사용하던 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;scanf&lt;/code&gt; 와 비슷한 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fmt&lt;/code&gt; 패키지의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Scanf&lt;/code&gt; , &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Scan&lt;/code&gt; , &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Scanln&lt;/code&gt; 을 사용하며, 이 중 주로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Scanln&lt;/code&gt; 을 사용한다.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Scanln&lt;/code&gt; 은 여러 값을 동시에 입력받을 수 있으며, 빈칸으로 값을 구분하고 엔터를 입력하면 입력이 종료된다.&lt;/p&gt;

&lt;p&gt;입력받는 변수에는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;amp;&lt;/code&gt; 연산자를 붙여서 입력받는다.&lt;/p&gt;

&lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;fmt&quot;&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;func&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num3&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;
	
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;정수 3개를 입력하세요 :&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Scanln&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// 실행결과&lt;/span&gt;

&lt;span class=&quot;err&quot;&gt;정수&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;개를&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;입력하세요&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;아주 익숙한 형태라 조금 반갑다.&lt;/p&gt;
</description>
        <pubDate>Tue, 27 Dec 2022 19:10:00 +0900</pubDate>
        <link>https://hjy.today/study/Go-_3.3_%EC%BD%98%EC%86%94_%EC%9E%85%EB%A0%A5_%ED%95%A8%EC%88%98%EC%9D%98_%EA%B8%B0%EB%B3%B8.html</link>
        <guid isPermaLink="true">https://hjy.today/study/Go-_3.3_%EC%BD%98%EC%86%94_%EC%9E%85%EB%A0%A5_%ED%95%A8%EC%88%98%EC%9D%98_%EA%B8%B0%EB%B3%B8.html</guid>
        
        <category>go</category>
        
        
        <category>study</category>
        
      </item>
    
      <item>
        <title>[Go] #3.2 연산자 우선순위</title>
        <description>&lt;p&gt;강의 링크 : 
&lt;a href=&quot;https://edu.goorm.io/learn/lecture/2010/%ED%95%9C-%EB%88%88%EC%97%90-%EB%81%9D%EB%82%B4%EB%8A%94-%EA%B3%A0%EB%9E%AD-%EA%B8%B0%EC%B4%88/lesson/174442/%EC%97%B0%EC%82%B0%EC%9E%90-%EC%9A%B0%EC%84%A0%EC%88%9C%EC%9C%84&quot;&gt;한 눈에 끝내는 고랭 기초 #3 연산자 - 연산자 우선순위&lt;/a&gt;&lt;/p&gt;

&lt;!--more--&gt;

&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#2-연산자-우선순위&quot; id=&quot;markdown-toc-2-연산자-우선순위&quot;&gt;2. 연산자 우선순위&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h1 id=&quot;2-연산자-우선순위&quot;&gt;2. 연산자 우선순위&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;기본적으로 상식으로 알고 있는 우선순위를 따른다.&lt;br /&gt;
간단하게 참고하고 넘어가자.&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Go/2022-12-27-[Go]_3.2_연산자_우선순위/1.png&quot; alt=&quot;2&quot; /&gt;&lt;/p&gt;
</description>
        <pubDate>Tue, 27 Dec 2022 19:00:00 +0900</pubDate>
        <link>https://hjy.today/study/Go-_3.2_%EC%97%B0%EC%82%B0%EC%9E%90_%EC%9A%B0%EC%84%A0%EC%88%9C%EC%9C%84.html</link>
        <guid isPermaLink="true">https://hjy.today/study/Go-_3.2_%EC%97%B0%EC%82%B0%EC%9E%90_%EC%9A%B0%EC%84%A0%EC%88%9C%EC%9C%84.html</guid>
        
        <category>go</category>
        
        
        <category>study</category>
        
      </item>
    
      <item>
        <title>[Go] #3.1 연산자 종류</title>
        <description>&lt;p&gt;강의 링크 : 
&lt;a href=&quot;https://edu.goorm.io/learn/lecture/2010/%ED%95%9C-%EB%88%88%EC%97%90-%EB%81%9D%EB%82%B4%EB%8A%94-%EA%B3%A0%EB%9E%AD-%EA%B8%B0%EC%B4%88/lesson/174441/%EC%97%B0%EC%82%B0%EC%9E%90-%EC%A2%85%EB%A5%98&quot;&gt;한 눈에 끝내는 고랭 기초 #3 연산자 - 연산자 종류&lt;/a&gt;&lt;/p&gt;

&lt;!--more--&gt;

&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#0-go-학습-재개&quot; id=&quot;markdown-toc-0-go-학습-재개&quot;&gt;0. Go 학습 재개&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#1-연산자-종류&quot; id=&quot;markdown-toc-1-연산자-종류&quot;&gt;1. 연산자 종류&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#i-수식-연산자&quot; id=&quot;markdown-toc-i-수식-연산자&quot;&gt;I. 수식 연산자&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#ii-증감-연산자&quot; id=&quot;markdown-toc-ii-증감-연산자&quot;&gt;II. 증감 연산자&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#iii-할당-연산자&quot; id=&quot;markdown-toc-iii-할당-연산자&quot;&gt;III. 할당 연산자&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#iv-논리-연산자&quot; id=&quot;markdown-toc-iv-논리-연산자&quot;&gt;IV. 논리 연산자&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#v-관계-연산자&quot; id=&quot;markdown-toc-v-관계-연산자&quot;&gt;V. 관계 연산자&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#vi-비트-연산자&quot; id=&quot;markdown-toc-vi-비트-연산자&quot;&gt;VI. 비트 연산자&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#vii-채널-연산자&quot; id=&quot;markdown-toc-vii-채널-연산자&quot;&gt;VII. 채널 연산자&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#viii-포인터-연산자&quot; id=&quot;markdown-toc-viii-포인터-연산자&quot;&gt;VIII. 포인터 연산자&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#마무리&quot; id=&quot;markdown-toc-마무리&quot;&gt;마무리&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h1 id=&quot;0-go-학습-재개&quot;&gt;0. Go 학습 재개&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;원래 스터디 당초 계획은 3일에 한 번씩 진도를 나가는 것이었으나 …&lt;br /&gt;
졸업 작품 + 취업 과제, 면접으로 인해 한 달이 쫙 밀려버렸다.&lt;br /&gt;
나 대신 스터디를 진행해준 스터디원의 양해에 감사하며 다시 열심히 해봐야겠다.&lt;/p&gt;

&lt;h1 id=&quot;1-연산자-종류&quot;&gt;1. 연산자 종류&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;어떤 언어를 배우든 그에 맞는 연산자가 존재한다.&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Go&lt;/code&gt; 에서의 여러가지 연산자에 대해서 알아보자.&lt;/p&gt;

&lt;h2 id=&quot;i-수식-연산자&quot;&gt;I. 수식 연산자&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;수식 연산자는 두 개의 피연산자를 요구하는 이항 연산자(binary operator)이다.&lt;br /&gt;
다른 언어들과 마찬가지로 기본적인 사칙연산, 나머지 값 반환 연산자가 있다.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;종류&lt;/th&gt;
      &lt;th&gt;기능&lt;/th&gt;
      &lt;th&gt;설명&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;+&lt;/td&gt;
      &lt;td&gt;피연산자의 값을 더한다.&lt;/td&gt;
      &lt;td&gt;값의 자료형은 정수, 실수, 복소수, 문자열입니다.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;-&lt;/td&gt;
      &lt;td&gt;왼쪽의 피연산자 값에서 오른쪽의 피연산자 값을 뺀다.&lt;/td&gt;
      &lt;td&gt;값의 자료형은 정수, 실수, 복소수입니다.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;*&lt;/td&gt;
      &lt;td&gt;피연산자의 값을 곱한다.&lt;/td&gt;
      &lt;td&gt;값의 자료형은 정수, 실수, 복소수입니다.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;/&lt;/td&gt;
      &lt;td&gt;왼쪽의 피연산자 값을 오른쪽의 피연산자 값으로 나눈다.&lt;/td&gt;
      &lt;td&gt;값의 자료형은 정수, 실수, 복소수입니다.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;%&lt;/td&gt;
      &lt;td&gt;왼쪽의 피연산자 값을 오른쪽의 피연산자 값으로 나눴을 때 얻게 되는 나머지 값을 반환한다.&lt;br /&gt;ex) num := 7 % 2&lt;br /&gt;(num = 1이 할당됨)&lt;/td&gt;
      &lt;td&gt;값의 자료형은 정수, 실수, 복소수입니다.&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;+&lt;/code&gt; 연산자는 문자열 결합도 가능함에 주의.&lt;/p&gt;

&lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;fmt&quot;&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;func&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;num1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;17&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;str1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;str2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Hello&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;goorm!&quot;&lt;/span&gt;
	
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;num1 + num2 =&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;str1 + str2 =&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;str1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;str2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;num1 - num2 =&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;num1 * num2 =&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;num1 / num2 =&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;num1 % num2 =&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// 실행결과&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;num1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;22&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;str1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;str2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Hellogoorm&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;num1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;12&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;num1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;85&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;num1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;num1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;ii-증감-연산자&quot;&gt;II. 증감 연산자&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;C++&lt;/code&gt;과 동일하지만, 주의할 점이 있다.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;증감 연산자를 사용함과 동시에 대입할 수 없다.
    &lt;ul&gt;
      &lt;li&gt;ex) num := count++ (X)&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;전위 연산을 할 수 없다.
    &lt;ul&gt;
      &lt;li&gt;ex) ++count (X)&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;종류&lt;/th&gt;
      &lt;th&gt;기능&lt;/th&gt;
      &lt;th&gt;설명&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;++&lt;/td&gt;
      &lt;td&gt;값을 1 증가시킨다.&lt;/td&gt;
      &lt;td&gt;값의 자료형은 정수, 실수, 복소수입니다.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;–&lt;/td&gt;
      &lt;td&gt;값을 1 감소시킨다.&lt;/td&gt;
      &lt;td&gt;값의 자료형은 정수, 실수, 복소수입니다.&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;fmt&quot;&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;func&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;count1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;count2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;10.4&lt;/span&gt;
	
	&lt;span class=&quot;n&quot;&gt;count1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;count2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;--&lt;/span&gt;
	
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;count1++ :&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;count1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;count2-- :&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;count2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// 실행결과&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;count1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;count2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;--&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;9.4&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;iii-할당-연산자&quot;&gt;III. 할당 연산자&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;할당 연산자는 값을 단순히 대입하는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;대입 연산자&lt;/code&gt;와 연산 후 값을 바로 대입시키는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;복합 대입 연산자&lt;/code&gt;가 있다.&lt;/p&gt;

&lt;p&gt;다른 언어와 거의 동일하다.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;종류&lt;/th&gt;
      &lt;th&gt;기능&lt;/th&gt;
      &lt;th&gt;설명&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;=&lt;/td&gt;
      &lt;td&gt;변수나 상수에 값을 대입한다.&lt;/td&gt;
      &lt;td&gt;변수는 변수끼리 대입이 가능합니다.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;:=&lt;/td&gt;
      &lt;td&gt;변수를 선언 및 대입한다.&lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;:=&lt;/td&gt;
      &lt;td&gt;변수를 선언 및 대입한다.&lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;+=&lt;/td&gt;
      &lt;td&gt;값을 더한 후 대입한다.&lt;/td&gt;
      &lt;td&gt;문자열일 경우 현재 변수에 문자열을 이어 붙인 다음 변수에 대입합니다.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;*=&lt;/td&gt;
      &lt;td&gt;값을 곱한 후 대입한다.&lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;/=&lt;/td&gt;
      &lt;td&gt;값을 나눈 후 대입한다.&lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;%=&lt;/td&gt;
      &lt;td&gt;값의 나눗셈 후 나머지를 대입한다.&lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&amp;amp;=&lt;/td&gt;
      &lt;td&gt;값의 AND 비트 연산 후 대입한다.&lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;|=&lt;/td&gt;
      &lt;td&gt;값의 OR 비트 연산 후 대입한다.&lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;^=&lt;/td&gt;
      &lt;td&gt;값의 XOR 비트 연산 후 대입한다.&lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&amp;amp;^=&lt;/td&gt;
      &lt;td&gt;값의 AND NOT 비트 연산 후 대입한다.&lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;«=&lt;/td&gt;
      &lt;td&gt;비트를 왼쪽으로 이동 후 대입한다.&lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;»=&lt;/td&gt;
      &lt;td&gt;비트를 오른쪽으로 이동 후 대입한다.&lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;fmt&quot;&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;func&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;

	&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;num = a :&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;num += 4 :&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;num -= 2 :&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;num *= 5 :&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;num /= 2 :&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;num %= 3 :&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

	&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;//00000011&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;//00000010&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;num &amp;amp;= 2 : %08b, %d&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;//00000101&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;num |= 5 : %08b, %d&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;^=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;//00000100&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;num ^= 4 : %08b, %d&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;^=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;//00000010&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;num &amp;amp;^= 2 : %08b, %d&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;9&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;//00001001&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;num &amp;lt;&amp;lt;= 9 : %08b, %d&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;//00001000&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;num &amp;gt;&amp;gt;= 8 : %08b, %d&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// 실행결과&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;20&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mo&quot;&gt;00000010&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mo&quot;&gt;00000111&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;^=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mo&quot;&gt;00000011&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;^=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mo&quot;&gt;00000001&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;9&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1000000000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;512&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mo&quot;&gt;00000010&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;iv-논리-연산자&quot;&gt;IV. 논리 연산자&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AND(논리곱)&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;OR(논리합)&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;NOT(논리부정)&lt;/code&gt;을 연산한다.&lt;/p&gt;

&lt;p&gt;마찬가지로 다른 언어들과 거의 동일하다.&lt;br /&gt;
주의할 점은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Go&lt;/code&gt; 에서는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;NOT&lt;/code&gt; 연산시 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bool&lt;/code&gt; 형의 선언 및 사용만이 가능하다.&lt;br /&gt;
즉, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;false&lt;/code&gt; , &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;true&lt;/code&gt; 값만 사용할 수 있다.&lt;br /&gt;
아래 예시를 보자.&lt;br /&gt;&lt;/p&gt;

&lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// 불가능&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// 불가능&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;종류&lt;/th&gt;
      &lt;th&gt;기능&lt;/th&gt;
      &lt;th&gt;설명&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;&amp;amp;&amp;amp;&lt;/td&gt;
      &lt;td&gt;연산하는 A와 B모두 ‘참’이면 연산 결과로 ‘참’을 반환한다.&lt;/td&gt;
      &lt;td&gt;1&amp;amp;&amp;amp;0=0&lt;br /&gt;1&amp;amp;&amp;amp;1=1&lt;br /&gt;0&amp;amp;&amp;amp;0=0&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;||&lt;/td&gt;
      &lt;td&gt;연산하는 A와 B 둘 중 하나라도 ‘참’이면 연산 결과로 ‘참’을 반환한다.&lt;/td&gt;
      &lt;td&gt;1||0=1&lt;br /&gt;1||1=1&lt;br /&gt;0||0=0&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;!&lt;/td&gt;
      &lt;td&gt;연산하는 A가 ‘참’이면 ‘거짓’, ‘거짓’이면 ‘참’을 반환한다.&lt;/td&gt;
      &lt;td&gt;!1=0&lt;br /&gt;!0=1&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;fmt&quot;&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;func&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;bool&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;

	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;0 &amp;amp;&amp;amp; 0 : &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;0 &amp;amp;&amp;amp; 1 : &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;1 &amp;amp;&amp;amp; 1 : &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;0 || 0 : &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;0 || 1 : &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;1 || 1 : &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;!1 &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;!0 &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// 실행결과&lt;/span&gt;

&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;  &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;  &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;  &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;  &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;  &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;  &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;  &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;  &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;v-관계-연산자&quot;&gt;V. 관계 연산자&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;관계 연산자는 두 값의 대소와 동등의 관계를 따지는 연산자이다.&lt;br /&gt;
관계 연산자는 조건을 만족하면 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;true&lt;/code&gt;를, 만족하지 않으면 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;false&lt;/code&gt;를 반환한다.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;종류&lt;/th&gt;
      &lt;th&gt;기능&lt;/th&gt;
      &lt;th&gt;설명&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;==&lt;/td&gt;
      &lt;td&gt;두 값이 같은지 비교한다.&lt;/td&gt;
      &lt;td&gt;같을 경우 ‘true’, 다를 경우 ‘false’를 반환한다.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;!=&lt;/td&gt;
      &lt;td&gt;두 값이 다른지 비교한다.&lt;/td&gt;
      &lt;td&gt;다를 경우 ‘true’, 같을 경우 ‘false’를 반환한다.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&amp;lt;&lt;/td&gt;
      &lt;td&gt;오른쪽 값이 큰지 비교한다.&lt;/td&gt;
      &lt;td&gt;오른쪽 값이 큰 경우 ‘true’, 그렇지 않을 경우 ‘false’를 반환한다.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&amp;lt;=&lt;/td&gt;
      &lt;td&gt;오른쪽 값이 크거나 같은지 비교한다.&lt;/td&gt;
      &lt;td&gt;오른쪽 값이 크거나 같은 경우 ‘true’, 그렇지 않을 경우 ‘false’를 반환한다.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&amp;gt;&lt;/td&gt;
      &lt;td&gt;왼쪽 값이 큰지 비교한다.&lt;/td&gt;
      &lt;td&gt;왼쪽 값이 큰 경우 ‘true’, 그렇지 않을 경우 ‘false’를 반환한다.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&amp;gt;=&lt;/td&gt;
      &lt;td&gt;왼쪽 값이 크거나 같은지 비교한다.&lt;/td&gt;
      &lt;td&gt;왼쪽 값이 크거나 같은 경우 ‘true’, 그렇지 않을 경우 ‘false’를 반환한다.&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;fmt&quot;&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;func&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;13 == 13 : &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;13&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;13&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;13 == 23 : &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;13&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;23&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;13 != 13 : &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;13&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;13&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;3 != 5 : &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;0 &amp;lt; 1 : &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;0 &amp;gt; 1 : &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;0 &amp;gt;= 1 : &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;0 &amp;lt;= 1 : &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// 실행 결과&lt;/span&gt;

&lt;span class=&quot;mi&quot;&gt;13&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;13&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;  &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;13&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;23&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;  &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;13&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;13&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;  &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;  &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;  &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;  &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;  &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;  &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;vi-비트-연산자&quot;&gt;VI. 비트 연산자&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;비트 연산자는 비트 단위의 연산을 수행한다.&lt;br /&gt;
나한테는 PS를 할 때 비트마스킹 등으로 익숙하다.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;종류&lt;/th&gt;
      &lt;th&gt;기능&lt;/th&gt;
      &lt;th&gt;설명&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;&amp;amp;&lt;/td&gt;
      &lt;td&gt;두 값을 비트 단위로 AND 연산을 한다.&lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;|&lt;/td&gt;
      &lt;td&gt;두 값을 비트 단위로 OR 연산을 한다.&lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;^&lt;/td&gt;
      &lt;td&gt;두 값을 비트 단위로 XOR 연산을 한다.&lt;/td&gt;
      &lt;td&gt;사용할 수 있는 값의 자료형은 정수입니다.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&amp;amp;^&lt;/td&gt;
      &lt;td&gt;두 값을 비트 단위로 AND NOT 연산을 한다.&lt;/td&gt;
      &lt;td&gt;사용할 수 있는 값의 자료형은 정수입니다.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;«&lt;/td&gt;
      &lt;td&gt;값의 비트 열을 왼쪽으로 이동시킨다.&lt;/td&gt;
      &lt;td&gt;사용할 수 있는 값의 자료형은 정수입니다.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;»&lt;/td&gt;
      &lt;td&gt;값의 비트 열을 오른쪽으로 이동시킨다.&lt;/td&gt;
      &lt;td&gt;사용할 수 있는 값의 자료형은 정수입니다.&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;fmt&quot;&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;func&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;num1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;15&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;//00001111&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;num2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;20&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;//00010100&lt;/span&gt;

	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;num1 &amp;amp; num2 : %08b, %d&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;num1 | num2 : %08b, %d&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;num1 ^ num2 : %08b, %d&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;^&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;^&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;num1 &amp;amp;^ num2 : %08b, %d&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;^&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;^&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;num1 &amp;lt;&amp;lt; 4 : %08b, %d&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;num2 &amp;gt;&amp;gt; 2 : %08b, %d&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// 실행 결과&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;num1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mo&quot;&gt;00000100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;num1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mo&quot;&gt;00011111&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;31&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;num1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;^&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mo&quot;&gt;00011011&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;27&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;num1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;^&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mo&quot;&gt;00001011&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;11&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;num1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;11110000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;240&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;num2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mo&quot;&gt;00000101&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;vii-채널-연산자&quot;&gt;VII. 채널 연산자&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Go&lt;/code&gt; 언어에는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;채널&lt;/code&gt; 이라는 개념이 있다.&lt;br /&gt;
간단히 말하자면 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;채널&lt;/code&gt;이랑 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;고루틴(goroutine)&lt;/code&gt;끼리 데이터를 주고 받고 실행 흐름을 제어하는 기능이다.&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;채널 연산자&lt;/code&gt;는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;채널&lt;/code&gt;을 사용할때 쓰는 연산자이다.&lt;/p&gt;

&lt;p&gt;처음으로 아예 색다른 연산자가 나왔다.&lt;br /&gt;
지금은 그런가보다 하고 넘어가고 채널에 대해 자세한건 이후에 배워보자.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;종류&lt;/th&gt;
      &lt;th&gt;기능&lt;/th&gt;
      &lt;th&gt;설명&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;&amp;lt;-&lt;/td&gt;
      &lt;td&gt;채널의 수신을 연산한다.&lt;/td&gt;
      &lt;td&gt;채널에 값을 보내거나 가져옵니다.&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;fmt&quot;&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;func&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;ch&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;make&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;chan&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;//정수형 채널 생성&lt;/span&gt;

	&lt;span class=&quot;n&quot;&gt;go&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;func&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;ch&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;
	&lt;span class=&quot;p&quot;&gt;}()&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;//채널에 10을 보냄&lt;/span&gt;

	&lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ch&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;//채널로부터 10을 전달받음&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// 실행 결과&lt;/span&gt;

&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;viii-포인터-연산자&quot;&gt;VIII. 포인터 연산자&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;포인터 연산자는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;C++&lt;/code&gt;과 같이 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;amp;&lt;/code&gt;와 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;*&lt;/code&gt;연산자를 이용해 메모리에 접근할 수 있도록 한다.&lt;br /&gt;
주의할 점은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Go&lt;/code&gt;언어는 포인터 연산자를 제공하지만 포인터 산술 즉, 포인터에 더하고 빼는 기능은 제공하지 않는다.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;종류&lt;/th&gt;
      &lt;th&gt;기능&lt;/th&gt;
      &lt;th&gt;설명&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;&amp;amp;&lt;/td&gt;
      &lt;td&gt;변수의 메모리 주소를 참조한다.&lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;*&lt;/td&gt;
      &lt;td&gt;포인터 변수에 저장된 메모리에 접근하여 값을 참조한다.&lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;fmt&quot;&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;func&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pnum&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt;

	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;num : &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;   &lt;span class=&quot;c1&quot;&gt;//num 값&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;pnum :&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pnum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;//num의 메모리 주소&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;pnum :&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pnum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;//num의 주소로 메모리에 할당돼있는 값 접근&lt;/span&gt;

	&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pnum&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;num : &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;pnum :&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pnum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;c1&quot;&gt;//포인터 연산자를 이용한 값 변경&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// 실행 결과&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;  &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;pnum&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mh&quot;&gt;0xc0000160c8&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;pnum&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;  &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;pnum&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;마무리&quot;&gt;마무리&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;대부분의 연산자는 다른 언어들에서 최소 한 번씩은 본 연산자들이지만, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;채널 연산자&lt;/code&gt; 는 처음이라 조금 색달랐다.&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;다른건 없고, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;증감 연산자&lt;/code&gt; , &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;논리 연산자&lt;/code&gt; , &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;포인터 연산자&lt;/code&gt; 의 주의사항 정도만 확인하고 넘어가면 될 것 같다.&lt;/p&gt;
</description>
        <pubDate>Tue, 27 Dec 2022 14:10:00 +0900</pubDate>
        <link>https://hjy.today/study/Go-_3.1_%EC%97%B0%EC%82%B0%EC%9E%90_%EC%A2%85%EB%A5%98.html</link>
        <guid isPermaLink="true">https://hjy.today/study/Go-_3.1_%EC%97%B0%EC%82%B0%EC%9E%90_%EC%A2%85%EB%A5%98.html</guid>
        
        <category>go</category>
        
        
        <category>study</category>
        
      </item>
    
      <item>
        <title>[Ansible] #5.2 조회</title>
        <description>&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ansible&lt;/code&gt; 의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;조회&lt;/code&gt; 에 대해서 알아보자.&lt;/p&gt;

&lt;!--more--&gt;

&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#1-조회&quot; id=&quot;markdown-toc-1-조회&quot;&gt;1. 조회&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#2-파일-조회&quot; id=&quot;markdown-toc-2-파일-조회&quot;&gt;2. 파일 조회&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#3-url-조회&quot; id=&quot;markdown-toc-3-url-조회&quot;&gt;3. URL 조회&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#url-조회-테스트&quot; id=&quot;markdown-toc-url-조회-테스트&quot;&gt;URL 조회 테스트&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#4-dig-조회-테스트&quot; id=&quot;markdown-toc-4-dig-조회-테스트&quot;&gt;4. DIG 조회, 테스트&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h1 id=&quot;1-조회&quot;&gt;1. 조회&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;조회(lookup) 플러그인은 파일, 인벤토리, 키/값 저장소, API 등 외부 소스에서 데이터를 검색해 변수로 가져올 수 있다.&lt;/p&gt;

&lt;p&gt;조회 플러그인의 목록은 다음 명령으로 확인할 수 있다.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible-doc &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; lookup &lt;span class=&quot;nt&quot;&gt;-l&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;2-파일-조회&quot;&gt;2. 파일 조회&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;다음은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;file&lt;/code&gt; 조회 플러그인을 이용해 파일의 내용을 변수로 가져오는 예제다.&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;hosts&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;mgmt&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;vars&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; 
    &lt;span class=&quot;na&quot;&gt;auth_key&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;{{&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;lookup(&apos;file&apos;,&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;/home/devops/.ssh/id_rsa.pub&apos;)&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;}}&quot;&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;tasks&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;set authorized keys&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;authorized_key&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;devops&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;present&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;{{&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;auth_key&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;}}&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;auth_key&lt;/code&gt; 의 값을 보면 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;lookup&lt;/code&gt; 플러그인을 사용하고 있는 것을 볼 수 있다.&lt;br /&gt;
함수를 사용하는 것이라고 봐도 된다.&lt;br /&gt;
그리고 첫 번째 파라미터를 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&apos;file&apos;&lt;/code&gt; 로 지정하면 두 번째 파라미터로 오는 파일의 내용을 출력한다.&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;이후 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;set authorized keys&lt;/code&gt; 태스크에서는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;key&lt;/code&gt; 값으로 해당 파일의 내용을 불러와 사용할 수 있다.&lt;/p&gt;

&lt;h1 id=&quot;3-url-조회&quot;&gt;3. URL 조회&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;다음은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;url&lt;/code&gt; 조회 플러그인을 이용해 정보를 변수로 가져오는 예제다.&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;display ip ranges&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;debug&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;{{&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;lookup(&apos;url&apos;,&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;https://ip-ranges.amazonaws.com/ip-ranges.json&apos;,&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;split_lines=False)&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;}}&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;url-조회-테스트&quot;&gt;URL 조회 테스트&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;02_vars&lt;/code&gt; 폴더에서 시작한다.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;mkdir &lt;/span&gt;lookup
&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;lookup
vi url.yaml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;hosts&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;mgmt&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;vars&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;ip_range&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;{{&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;lookup(&apos;url&apos;,&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;https://ip-ranges.amazonaws.com/ip-ranges.json&apos;)&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;}}&quot;&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;tasks&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;debug&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;{{&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;ip_range&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;}}&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible-playbook url.yaml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;실행하면 값이 쏟아져 나오므로, 결과 사진은 생략한다.&lt;/p&gt;

&lt;h1 id=&quot;4-dig-조회-테스트&quot;&gt;4. DIG 조회, 테스트&lt;/h1&gt;
&lt;hr /&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;vi dig.yaml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# Library: sudo apt install python3-dnspython&lt;/span&gt;

&lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;hosts&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;mgmt&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;vars&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;google_ip&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;{{&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;lookup(&apos;dig&apos;,&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;www.google.com&apos;,&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;qtype=&apos;A&apos;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;}}&quot;&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;tasks&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;debug&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;{{&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;google_ip&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;}}&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dig&lt;/code&gt; 은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DNS&lt;/code&gt; 를 쿼리하는 것이다.&lt;/p&gt;

&lt;p&gt;q타입은 A 레코드로, 구글에 대한 A 레코드를 DNS 서버에 질의할 것이다.&lt;br /&gt;
이 때 주의할 점으로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dig lookup&lt;/code&gt;을 사용하기 위해서는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dnspython&lt;/code&gt; 이라는 라이브러리가 필요하므로, 해당 라이브러리를 설치해줘야 한다.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt-cache search dnspython
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-27-[Ansible]_5.2_조회/1.png&quot; alt=&quot;1&quot; /&gt;&lt;/p&gt;

&lt;p&gt;위 명령어로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dnspython&lt;/code&gt; 의 패키지명을 확인할 수 있다.&lt;br /&gt;&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;python3-dnspython
ansible-playbook dig.yaml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-27-[Ansible]_5.2_조회/2.png&quot; alt=&quot;2&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;msg&lt;/code&gt; 로 구글의 주소는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;172.217.27.36&lt;/code&gt; 임을 확인할 수 있다.&lt;/p&gt;
</description>
        <pubDate>Tue, 27 Dec 2022 01:30:00 +0900</pubDate>
        <link>https://hjy.today/study/Ansible-_5.2_%EC%A1%B0%ED%9A%8C.html</link>
        <guid isPermaLink="true">https://hjy.today/study/Ansible-_5.2_%EC%A1%B0%ED%9A%8C.html</guid>
        
        <category>ansible</category>
        
        
        <category>study</category>
        
      </item>
    
      <item>
        <title>[Ansible] #5.1 변수</title>
        <description>&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ansible&lt;/code&gt; 의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;변수&lt;/code&gt; 에 대해서 알아보자.&lt;/p&gt;

&lt;!--more--&gt;

&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#1-변수-이름&quot; id=&quot;markdown-toc-1-변수-이름&quot;&gt;1. 변수 이름&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#2-기본-변수-정의-및-참조-기본-변수&quot; id=&quot;markdown-toc-2-기본-변수-정의-및-참조-기본-변수&quot;&gt;2. 기본 변수 정의 및 참조 기본 변수&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#기본-변수-테스트&quot; id=&quot;markdown-toc-기본-변수-테스트&quot;&gt;기본 변수 테스트&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#3-목록-변수-정의-및-참조&quot; id=&quot;markdown-toc-3-목록-변수-정의-및-참조&quot;&gt;3. 목록 변수 정의 및 참조&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#목록-변수-테스트&quot; id=&quot;markdown-toc-목록-변수-테스트&quot;&gt;목록 변수 테스트&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#4-사전-변수-정의-및-참조&quot; id=&quot;markdown-toc-4-사전-변수-정의-및-참조&quot;&gt;4. 사전 변수 정의 및 참조&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#사전-변수-테스트&quot; id=&quot;markdown-toc-사전-변수-테스트&quot;&gt;사전 변수 테스트&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#5-등록-변수&quot; id=&quot;markdown-toc-5-등록-변수&quot;&gt;5. 등록 변수&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#등록-변수-테스트&quot; id=&quot;markdown-toc-등록-변수-테스트&quot;&gt;등록 변수 테스트&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#6-변수-정의-위치&quot; id=&quot;markdown-toc-6-변수-정의-위치&quot;&gt;6. 변수 정의 위치&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#7-인벤토리-변수&quot; id=&quot;markdown-toc-7-인벤토리-변수&quot;&gt;7. 인벤토리 변수&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#8-플레이북-변수&quot; id=&quot;markdown-toc-8-플레이북-변수&quot;&gt;8. 플레이북 변수&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#플레이북-변수-테스트&quot; id=&quot;markdown-toc-플레이북-변수-테스트&quot;&gt;플레이북 변수 테스트&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#9-런타임---옵션&quot; id=&quot;markdown-toc-9-런타임---옵션&quot;&gt;9. 런타임 - 옵션&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#10-변수의-우선-순위&quot; id=&quot;markdown-toc-10-변수의-우선-순위&quot;&gt;10. 변수의 우선 순위&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#11-변수-범위&quot; id=&quot;markdown-toc-11-변수-범위&quot;&gt;11. 변수 범위&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#작업-변수-범위-테스트&quot; id=&quot;markdown-toc-작업-변수-범위-테스트&quot;&gt;작업 변수 범위 테스트&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h1 id=&quot;1-변수-이름&quot;&gt;1. 변수 이름&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;변수 이름에는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;문자&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;숫자&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;밑줄&lt;/code&gt;만 포함할 수 있다.&lt;br /&gt;
그러나 이미 예약된 플레이북 키워드나 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Python&lt;/code&gt; 키워드는 사용할 수 없다.
또한 변수는 숫자로 시작할 수 없다.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;유효한 변수 이름
    &lt;ul&gt;
      &lt;li&gt;foo&lt;/li&gt;
      &lt;li&gt;foo_env&lt;/li&gt;
      &lt;li&gt;foo_port&lt;/li&gt;
      &lt;li&gt;foo5&lt;/li&gt;
      &lt;li&gt;_foo&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;키워드 DOCS 참조 : 
&lt;a href=&quot;https://docs.ansible.com/ansible/latest/reference_appendices/playbooks_keywords.html#playbook-keywords&quot;&gt;playbook-keywords&lt;/a&gt;&lt;/p&gt;

&lt;h1 id=&quot;2-기본-변수-정의-및-참조-기본-변수&quot;&gt;2. 기본 변수 정의 및 참조 기본 변수&lt;/h1&gt;
&lt;hr /&gt;

&lt;ul&gt;
  &lt;li&gt;기본 변수 정의&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;hosts&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;mgmt&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;vars&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;remote_install_path&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;/opt/my_app_config&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;일반적으로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vars&lt;/code&gt; 라는 키워드를 사용하고, 그 안에서 변수를 선언한다.&lt;br /&gt;
이는 아래 예시 모두 동일하다.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;기본 변수 참조&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;template&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;foo.cfg.j2&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;dest&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;{{&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;remote_install_path&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;}}&apos;/foo.cfg&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;변수를 참조할 때는 반드시 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;이중 중괄호&lt;/code&gt; 를 사용한다.&lt;br /&gt;
변수가 참조하는 사전의 모든 값을 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;따옴표&lt;/code&gt;로 인용한다.&lt;/p&gt;

&lt;h2 id=&quot;기본-변수-테스트&quot;&gt;기본 변수 테스트&lt;/h2&gt;
&lt;hr /&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;mkdir &lt;/span&gt;02_vars
&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;02_vars
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;변수 실습용 폴더인 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;02_vars&lt;/code&gt; 폴더를 만들고, 그 안에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vars&lt;/code&gt; 폴더를 만든다.&lt;br /&gt;&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;vi var.yaml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;hosts&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;mgmt&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;vars&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;hello world!!!&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;tasks&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;debug&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;{{&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;}}&quot;&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;debug&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;hello&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;korea&quot;&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;debug&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;MESSAGE:&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;{{&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;}}&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible-playbook var.yaml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-26-[Ansible]_5.1_변수/1.png&quot; alt=&quot;1&quot; /&gt;&lt;/p&gt;

&lt;p&gt;다음은 패키지 설치 예시이다.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;vi var2.yaml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;hosts&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;mgmt&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;vars&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;pkg_name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;apache2&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;tasks&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;apt&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;{{&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;pkg_name&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;}}&quot;&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;present&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;service&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;{{&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;pkg_name&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;}}&quot;&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;started&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible-playbook var2.yaml &lt;span class=&quot;nt&quot;&gt;-b&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-26-[Ansible]_5.1_변수/2.png&quot; alt=&quot;2&quot; /&gt;&lt;/p&gt;

&lt;h1 id=&quot;3-목록-변수-정의-및-참조&quot;&gt;3. 목록 변수 정의 및 참조&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;목록(List) 변수&lt;/code&gt;는 여러 개의 값이 목록으로 선언된 변수다.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;목록 변수 정의&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;region&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;northeast&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;southeast&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;midwest&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;목록 변수 참조&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;region&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;{{&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;region[0]&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;}}&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;목록-변수-테스트&quot;&gt;목록 변수 테스트&lt;/h2&gt;
&lt;hr /&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;vi var3.yaml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;hosts&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;mgmt&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;vars&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;mylist&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;aaa&lt;/span&gt;
      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;bbb&lt;/span&gt;
      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;ccc&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;tasks&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;debug&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;{{&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;mylist[0]&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;}}&quot;&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;debug&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;{{&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;mylist[1]&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;}}&quot;&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;debug&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;{{&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;mylist[2]&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;}}&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible-playbook var3.yaml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-26-[Ansible]_5.1_변수/3.png&quot; alt=&quot;3&quot; /&gt;&lt;/p&gt;

&lt;h1 id=&quot;4-사전-변수-정의-및-참조&quot;&gt;4. 사전 변수 정의 및 참조&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;사전(Dictionary) 변수&lt;/code&gt;는 변수에 하나 이상의 사전 값이 선언된 변수다.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;사전 변수 정의&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;foo&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;field1&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;one&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;field2&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;two&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;사전 변수 참조&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;s&quot;&gt;foo[&apos;field1&apos;]&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt;foo.field1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;대괄호 표기법 : 항상 적절하게 참조됨&lt;/li&gt;
  &lt;li&gt;점 표기법 : 모듈에 따라 일부 키가 Python 사전(Dictionary)의 속성 및 메서드와 충돌할 수 있음&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;사전-변수-테스트&quot;&gt;사전 변수 테스트&lt;/h2&gt;
&lt;hr /&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;vi var4.yaml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;hosts&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;mgmt&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;vars&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;mydict&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;aaa&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;bbb&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;tasks&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;debug&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;{{&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;mydict.a&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;}}&quot;&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;debug&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;{{&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;mydict[&apos;a&apos;]&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;}}&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible-playbook var4.yaml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-26-[Ansible]_5.1_변수/4.png&quot; alt=&quot;4&quot; /&gt;&lt;/p&gt;

&lt;h1 id=&quot;5-등록-변수&quot;&gt;5. 등록 변수&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;등록(Registered) 변수&lt;/code&gt; 는 모듈의 반환 값을 저장하는 변수다.&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;플레이북&lt;/code&gt; 은 실행시 리턴 밸류가 나오지 않는다.&lt;br /&gt;
즉, 실행 자체에 초점을 맞춘 기능이고, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ad-hoc&lt;/code&gt; 의 경우는 리턴 밸류를 출력하므로 주로 디버깅에 사용된다.&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;플레이북&lt;/code&gt; 에서의 디버깅에는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;등록 변수&lt;/code&gt; 를 주로 사용하게 된다.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;등록 변수 사용&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;hosts&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;web_servers&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;tasks&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Run a shell command and register its output as a variable&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;shell&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;/usr/bin/foo&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;register&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;foo_result&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;ignore_errors&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;true&lt;/span&gt;

    &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Run a shell command using output of the previous task&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;shell&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;/usr/bin/bar&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;when&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;foo_result.rc == &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;5&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;위와 같이 작성할 수 있다.&lt;br /&gt;
실제로 테스트를 통해 이해해보자.&lt;/p&gt;

&lt;h2 id=&quot;등록-변수-테스트&quot;&gt;등록 변수 테스트&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;02_vars&lt;/code&gt; 폴더에서 시작하여 아래 명령어로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;reg.yaml&lt;/code&gt; 파일을 생성한다.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;mkdir &lt;/span&gt;register
&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;register
vi reg.yaml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;hosts&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;mgmt&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;gather_facts&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;no&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;tasks&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;ping&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;pi&quot;&gt;{}&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;register&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;ping_result&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;debug&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;{{&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;ping_result&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;}}&quot;&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;debug&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;{{&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;ping_result.ping&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;}}&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ping&lt;/code&gt; 모듈을 실행하는 플레이북을 작성하였다.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;register&lt;/code&gt; 는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;task&lt;/code&gt; 의 키워드임을 명심하자.&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;register&lt;/code&gt; 의 값으로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ping_register&lt;/code&gt; 라는 임의의 변수명을 지정하였고, 이를 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;msg&lt;/code&gt; 로 출력하면 리턴 밸류를 볼 수 있게 된다.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible-playbook reg.yaml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-26-[Ansible]_5.1_변수/5.png&quot; alt=&quot;5&quot; /&gt;&lt;/p&gt;

&lt;h1 id=&quot;6-변수-정의-위치&quot;&gt;6. 변수 정의 위치&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;변수를 정의할 수 있는 위치는 다음과 같다.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;인벤토리&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;플레이북(&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vars:&lt;/code&gt;)&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;재사용 가능 파일(외부 참조 파일)&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;역할&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;명령의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-e&lt;/code&gt; 옵션&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;위에서는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;플레이북&lt;/code&gt; 내의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vars&lt;/code&gt; 키워드에서 변수를 정의하였지만, 그 밖의 다른 곳에서도 변수를 선언할 수 있다.&lt;/p&gt;

&lt;p&gt;만약 동일한 변수명으로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;인벤토리&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;플레이북&lt;/code&gt; 등에서 선언하였을 경우, 우선순위에 따라 그 값이 결정된다.&lt;/p&gt;

&lt;p&gt;때문에 변수의 범위를 상정하여 변수를 선언해야 하며, 동일한 변수명으로 여러 곳에서 만들지 않고 변수 범위를 생각해서 선언하도록 하자.&lt;/p&gt;

&lt;h1 id=&quot;7-인벤토리-변수&quot;&gt;7. 인벤토리 변수&lt;/h1&gt;
&lt;hr /&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;pi&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;atlanta&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt;host1 http_port=80 maxRequestsPerChild=808&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt;host2 http_port=303 maxRequestPerChild=900&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;인벤토리 변수의 예시이다.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;host1&lt;/code&gt; , &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;host2&lt;/code&gt; 는 호스트 명을 나타내며, 그 이하는 모두 변수를 나타낸다.&lt;br /&gt;
즉, 해당 변수는 각 호스트에만 적용되는 변수이며 그것이 각 변수의 범위이다.&lt;br /&gt;
이를 &lt;strong&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;호스트 변수&lt;/code&gt;&lt;/strong&gt; 라고 한다.&lt;/p&gt;

&lt;p&gt;위의 경우 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;atlanta&lt;/code&gt; 라는 호스트 그룹을 구성하였을 때 &lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;host1&lt;/code&gt; 에서의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;http_port&lt;/code&gt; 라는 변수의 값은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;80&lt;/code&gt; 이 되고,&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;host2&lt;/code&gt; 에서의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;http_port&lt;/code&gt; 의 값은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;303&lt;/code&gt; 이 된다.&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;pi&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;atlanta&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt;host1&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt;host2&lt;/span&gt;

&lt;span class=&quot;pi&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;atlanta&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;vars&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt;ntp_server=ntp.atlanta.example.com&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt;proxy=proxy.atlanta.example.com&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;밑은 &lt;strong&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;그룹 변수&lt;/code&gt;&lt;/strong&gt; 라고 하며, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[그룹명:vars]&lt;/code&gt; 로 나타낼 수 있다.&lt;br /&gt;
이렇게 하면 해당 변수들은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;atlanta&lt;/code&gt; 라는 그룹에 있는 호스트에 공통적으로 적용된다.&lt;/p&gt;

&lt;h1 id=&quot;8-플레이북-변수&quot;&gt;8. 플레이북 변수&lt;/h1&gt;
&lt;hr /&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nn&quot;&gt;---&lt;/span&gt;
&lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;hosts&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;all&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;remote_user&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;root&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;vars&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;favcolor&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;blue&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;vars_files&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;vars/external_vars.yaml&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;tasks&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;This is just a placeholder&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;command&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;/bin/echo foo&lt;/span&gt;
&lt;span class=&quot;nn&quot;&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nn&quot;&gt;---&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# This is external_vars.yaml&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;somevar&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;somevalue&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;password&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;magic&lt;/span&gt;
&lt;span class=&quot;nn&quot;&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;위에서 했던 것 처럼 플레이북에서는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vars&lt;/code&gt; 키워드를 사용해서 변수를 선언할 수 있다.&lt;br /&gt;
또한 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vars_files&lt;/code&gt; 키워드로 외부 파일을 참조하는 것도 가능하다.&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;플레이북-변수-테스트&quot;&gt;플레이북 변수 테스트&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;02_var/vars&lt;/code&gt; 폴더에서 시작한다.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;vi var5.yaml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;hosts&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;mgmt&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;vars_files&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;varfile.yaml&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;tasks&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;debug&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;{{&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;myvar&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;}}&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;vi varfile.yaml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;myvar&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;hello myvar&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible-playbook var5.yaml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-26-[Ansible]_5.1_변수/6.png&quot; alt=&quot;6&quot; /&gt;&lt;/p&gt;

&lt;h1 id=&quot;9-런타임---옵션&quot;&gt;9. 런타임 - 옵션&lt;/h1&gt;
&lt;hr /&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;키 = 값 형식&lt;/p&gt;

    &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible-playbook release.yml &lt;span class=&quot;nt&quot;&gt;--extra-vars&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;version=1.23.45 other_variable=foo&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--extra-vars&lt;/code&gt; 옵션은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-e&lt;/code&gt; 로 축약해서 사용할 수 있다.&lt;br /&gt;
이에 대한 변수가 뒤에 오는 문자열이다.&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;키 = 값&lt;/code&gt; 형식 은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;INI&lt;/code&gt; 방식이라고 생각하면 된다.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;JSON 문자열 형식&lt;/p&gt;

    &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible-playbook release.yml &lt;span class=&quot;nt&quot;&gt;--extra-vars&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;{&quot;version&quot;:&quot;1.23.45&quot;, &quot;other_variable&quot;:&quot;foo&quot;}&apos;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;JSON 또는 YAML 파일&lt;/p&gt;

    &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible-playbook release.yml &lt;span class=&quot;nt&quot;&gt;--extra-vars&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;@some_file.json&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;@&lt;/code&gt; 를 사용하면 외부 파일을 참조할 수 있다.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;10-변수의-우선-순위&quot;&gt;10. 변수의 우선 순위&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;번호가 높을수록 우선 순위가 높다.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;명령의 옵션 (예 : -u my_user)&lt;/li&gt;
  &lt;li&gt;역할의 기본(defaults) 변수 파일(role_defaults_main.yml)&lt;/li&gt;
  &lt;li&gt;인벤토리 파일의 그룹 변수 / 동적 인벤토리 스크립트의 그룹 변수&lt;/li&gt;
  &lt;li&gt;인벤토리 파일이 있는 경로의 group_vars/all 파일&lt;/li&gt;
  &lt;li&gt;플레이북 파일이 있는 경로의 group_vars/all 파일&lt;/li&gt;
  &lt;li&gt;인벤토리 파일이 있는 경로의 group_vars/* 모든 파일&lt;/li&gt;
  &lt;li&gt;플레이북 파일이 있는 경로의 group_vars/* 모든 파일&lt;/li&gt;
  &lt;li&gt;인벤토리 파일의 호스트 변수 / 동적 인벤토리 스크립트의 호스트 변수&lt;/li&gt;
  &lt;li&gt;인벤토리 파일이 있는 경로의 host_vars/* 모든 파일&lt;/li&gt;
  &lt;li&gt;플레이북 파일이 있는 경로의 host_vars/* 모든 파일&lt;/li&gt;
  &lt;li&gt;호스트의 팩트 변수 / set_fact 모듈에 의해 캐시된 변수&lt;/li&gt;
  &lt;li&gt;플레이의 vars 키워드&lt;/li&gt;
  &lt;li&gt;플레이의 vars_prompt 키워드&lt;/li&gt;
  &lt;li&gt;플레이의 vars_files 키워드&lt;/li&gt;
  &lt;li&gt;역할의 vars 변수 파일(role_vars_main.yml)&lt;/li&gt;
  &lt;li&gt;블록의 vars 키워드&lt;/li&gt;
  &lt;li&gt;작업의 vars 키워드&lt;/li&gt;
  &lt;li&gt;include_vars 모듈&lt;/li&gt;
  &lt;li&gt;set_facts 모듈 / 등록 변수&lt;/li&gt;
  &lt;li&gt;역할(또는 include_role 모듈)의 파라미터&lt;/li&gt;
  &lt;li&gt;include 모듈의 파라미터&lt;/li&gt;
  &lt;li&gt;ansible-playbook 명령의 ‘–extra-vars’ 변수&lt;/li&gt;
&lt;/ol&gt;

&lt;h1 id=&quot;11-변수-범위&quot;&gt;11. 변수 범위&lt;/h1&gt;
&lt;hr /&gt;

&lt;ul&gt;
  &lt;li&gt;전역/플레이북 : 구성 파일, 환경 변수(ansible_*), 명령 줄 옵션(&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-e&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--extra-vars&lt;/code&gt;)&lt;/li&gt;
  &lt;li&gt;호스트 그룹 : 인벤토리의 그룹 변수&lt;/li&gt;
  &lt;li&gt;호스트 : 인벤토리의 호스트 변수&lt;/li&gt;
  &lt;li&gt;플레이 : &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vars&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vars_files&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vars_prompt&lt;/code&gt; 등 지시어, 역할의 기본 변수(defaults) 및 변수(vars)&lt;/li&gt;
  &lt;li&gt;블록&lt;/li&gt;
  &lt;li&gt;작업&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;블록은 아직 안배웠으니 넘어가고, 작업에 대해서 살펴보자.&lt;/p&gt;

&lt;h2 id=&quot;작업-변수-범위-테스트&quot;&gt;작업 변수 범위 테스트&lt;/h2&gt;
&lt;hr /&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;vi var6.yaml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;hosts&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;mgmt&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;vars&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;hello play&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;tasks&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;debug&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;{{&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;}}&quot;&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;debug&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;{{&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;}}&quot;&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;vars&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;hello task&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible-playbook var6.yaml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-26-[Ansible]_5.1_변수/7.png&quot; alt=&quot;7&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;var6.yaml&lt;/code&gt; 에는 두 개의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;message&lt;/code&gt; 변수가 존재하며, &lt;br /&gt;
첫 번째 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;debug&lt;/code&gt; 태스크는 기본 변수로 정의된 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hello play&lt;/code&gt; 를 출력하고, &lt;br /&gt;
두 번째 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;debug&lt;/code&gt; 태스크는 작업 범위 내에서 선언된 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vars&lt;/code&gt; 의 값인 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hello task&lt;/code&gt; 를 출력한다.&lt;/p&gt;
</description>
        <pubDate>Mon, 26 Dec 2022 23:00:00 +0900</pubDate>
        <link>https://hjy.today/study/Ansible-_5.1_%EB%B3%80%EC%88%98.html</link>
        <guid isPermaLink="true">https://hjy.today/study/Ansible-_5.1_%EB%B3%80%EC%88%98.html</guid>
        
        <category>ansible</category>
        
        
        <category>study</category>
        
      </item>
    
      <item>
        <title>[Ansible] #4.2 플레이북</title>
        <description>&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ansible&lt;/code&gt; 의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;플레이북&lt;/code&gt; 의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;YAML&lt;/code&gt; 형식에 대해서 알아보자.&lt;/p&gt;

&lt;!--more--&gt;

&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#1-플레이북&quot; id=&quot;markdown-toc-1-플레이북&quot;&gt;1. 플레이북&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#2-플레이북의-작업-실행-순서&quot; id=&quot;markdown-toc-2-플레이북의-작업-실행-순서&quot;&gt;2. 플레이북의 작업 실행 순서&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#3-멱등성idempotent&quot; id=&quot;markdown-toc-3-멱등성idempotent&quot;&gt;3. 멱등성(Idempotent)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#4-멱등성을-제공하지-않는-예시&quot; id=&quot;markdown-toc-4-멱등성을-제공하지-않는-예시&quot;&gt;4. 멱등성을 제공하지 않는 예시&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#5-핸들러handler&quot; id=&quot;markdown-toc-5-핸들러handler&quot;&gt;5. 핸들러(Handler)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#6-멱등성을-만족하지-못하는-예&quot; id=&quot;markdown-toc-6-멱등성을-만족하지-못하는-예&quot;&gt;6. 멱등성을 만족하지 못하는 예&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#7-멱등성을-상황에-따라-만족하는-예&quot; id=&quot;markdown-toc-7-멱등성을-상황에-따라-만족하는-예&quot;&gt;7. 멱등성을 상황에 따라 만족하는 예&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#8-테스트&quot; id=&quot;markdown-toc-8-테스트&quot;&gt;8. 테스트&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#핸들러-추가&quot; id=&quot;markdown-toc-핸들러-추가&quot;&gt;핸들러 추가&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#name-추가&quot; id=&quot;markdown-toc-name-추가&quot;&gt;name 추가&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#become-추가&quot; id=&quot;markdown-toc-become-추가&quot;&gt;become 추가&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#removeyaml&quot; id=&quot;markdown-toc-removeyaml&quot;&gt;remove.yaml&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h1 id=&quot;1-플레이북&quot;&gt;1. 플레이북&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ansible&lt;/code&gt; 플레이북 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;YAML&lt;/code&gt; 로 정의하고, 하나 이상의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;모듈&lt;/code&gt;을 이용해 하나 이상의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;작업&lt;/code&gt;을 실행하고 해당 작업을 특정 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;호스트/그룹&lt;/code&gt;에 실행하는 하나 이상의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;플레이&lt;/code&gt;를 가짐&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;플레이북&lt;/code&gt; : 하나 이상의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;플레이&lt;/code&gt;를 가짐&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;플레이&lt;/code&gt; : 특정 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;관리 노드/그룹&lt;/code&gt;을 지정해 하나 이상의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;작업&lt;/code&gt;을 가짐&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;작업&lt;/code&gt; : 하나의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;모듈&lt;/code&gt;과 모듈의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;옵션/파라미터/아규먼트&lt;/code&gt;를 지정&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;플레이북 키워드:&lt;br /&gt;
&lt;a href=&quot;https://docs.ansible.com/ansible/latest/reference_appendices/playbooks_keywords.html#playbook-keywords&quot;&gt;https://docs.ansible.com/ansible/latest/reference_appendices/playbooks_keywords.html#playbook-keywords&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-12-[Ansible]_4.2_플레이북/1.png&quot; alt=&quot;1&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hosts&lt;/code&gt; 는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;플레이&lt;/code&gt; 이며 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;list&lt;/code&gt; 로 표현되고, 그 값은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;호스트/그룹&lt;/code&gt; 이 온다.&lt;br /&gt;
같은 레벨에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tasks&lt;/code&gt; 가 들어가고, 그 값으로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;apt&lt;/code&gt; , &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;service&lt;/code&gt; 같은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;task&lt;/code&gt; 가 들어간다.&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;apt&lt;/code&gt; 는 또 하나의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;키&lt;/code&gt; 로서 그 값으로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;name&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;state&lt;/code&gt; 와 같은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;옵션/파라미터/아규먼트&lt;/code&gt; 가 온다.&lt;/p&gt;

&lt;p&gt;즉 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;플레이&lt;/code&gt; 와 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;task&lt;/code&gt; 는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;list&lt;/code&gt; 이고, 위 파일에는 두 개의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;플레이&lt;/code&gt; 가 존재한다.&lt;/p&gt;

&lt;p&gt;간단한 테스트로 플레이북 파일을 생성해보자.&lt;br /&gt;
홈 디렉토리에서 시작한다.&lt;br /&gt;&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;mkdir test
cd test
&lt;/span&gt;vi test.yaml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;그리고 아래 내용을 입력한다.&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nn&quot;&gt;---&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# ansible mgmt -m apt -a &apos;name=apache2 state=present&apos;&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# ansible mgmt -m service -a &apos;name=apache2 enabled=true state=started&apos;&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# ansible mgmt -m file -a &apos;path=/var/www/html state=directory&apos;&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# ansible mgmt -m copy -a &apos;src=index.html dest=/var/www/html/index.html&apos;&lt;/span&gt;

&lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;hosts&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;mgmt&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;tasks&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;apt&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;apache2&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;present&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;service&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;apache2&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;enabled&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;true&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;started&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;file&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;/var/www/html&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;directory&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;copy&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;index.html&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;dest&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;/var/www/html/index.html&lt;/span&gt;
&lt;span class=&quot;nn&quot;&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;주석처리된 부분은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ad-hoc&lt;/code&gt; 커맨드이다.&lt;br /&gt;
이를 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;플레이북&lt;/code&gt; 작성할 시 위와 같이 작성할 수 있다.&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;이제 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;index.html&lt;/code&gt; 파일을 작성하여 테스트해보자.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;vi index.html
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;title&amp;gt;&lt;/span&gt; hello &lt;span class=&quot;nt&quot;&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;h1&amp;gt;&lt;/span&gt; hello world &lt;span class=&quot;nt&quot;&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;뒤에 나오겠지만, 위 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;플레이북&lt;/code&gt; 을 실행시켜보자.&lt;br /&gt;
패키지 설치시에 관리자 권한이 필요하기 떄문에, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-b&lt;/code&gt; 옵션을 붙여주자.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible-playbook test.yaml &lt;span class=&quot;nt&quot;&gt;-b&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-12-[Ansible]_4.2_플레이북/3.png&quot; alt=&quot;3&quot; /&gt;&lt;/p&gt;

&lt;p&gt;각 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;apt&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;service&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;file&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;copy&lt;/code&gt; 모듈이 잘 실행되었음을 확인할 수 있다.&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ok&lt;/code&gt; 는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ad-hoc&lt;/code&gt; 커맨드의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SUCCESS&lt;/code&gt; 와 동일하다고 생각하면 된다.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;curl 192.168.56.21
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-12-[Ansible]_4.2_플레이북/4.png&quot; alt=&quot;4&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;curl&lt;/code&gt; 을 사용하여 해당 페이지에 접속되는지를 확인할 수 있다.&lt;/p&gt;

&lt;p&gt;+ 추가로, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;모듈&lt;/code&gt; 을 사용하여 해당 페이지에 접속이 되는지도 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;플레이북&lt;/code&gt;으로 작성하여 테스트 할 수 있도록 해보자.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;test.yaml&lt;/code&gt; 파일을 다음과 같이 수정한다.&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nn&quot;&gt;---&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# ansible mgmt -m apt -a &apos;name=apache2 state=present&apos;&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# ansible mgmt -m service -a &apos;name=apache2 enabled=true state=started&apos;&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# ansible mgmt -m file -a &apos;path=/var/www/html state=directory&apos;&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# ansible mgmt -m copy -a &apos;src=index.html dest=/var/www/html/index.html&apos;&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# ansible mgmt -m uri -a &apos;url=http://192.168.56.21 status_code=200 return_content=yes&apos;&lt;/span&gt;

&lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;hosts&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;mgmt&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;tasks&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;apt&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;apache2&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;present&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;service&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;apache2&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;enabled&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;true&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;started&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;file&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;/var/www/html&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;directory&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;copy&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;index.html&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;dest&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;/var/www/html/index.html&lt;/span&gt;
&lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;hosts&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;localhost&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;tasks&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;uri&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;http://192.168.56.21&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;status_code&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;200&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;return_content&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;yes&lt;/span&gt;
&lt;span class=&quot;nn&quot;&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-12-[Ansible]_4.2_플레이북/5.png&quot; alt=&quot;5&quot; /&gt;&lt;/p&gt;

&lt;p&gt;이렇게 확인 가능하다.&lt;/p&gt;

&lt;p&gt;이후에 하는 모든 실습은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git repository&lt;/code&gt; 로 옮겼다.&lt;/p&gt;

&lt;p&gt;위치는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/goorm-7th-ansible&lt;/code&gt;.&lt;/p&gt;

&lt;h1 id=&quot;2-플레이북의-작업-실행-순서&quot;&gt;2. 플레이북의 작업 실행 순서&lt;/h1&gt;
&lt;hr /&gt;

&lt;ol&gt;
  &lt;li&gt;호스트의 패턴과 일치하는 모든 시스템에 대해 각 작업을 순서대로 실행&lt;/li&gt;
  &lt;li&gt;각 직업은 지정한 모듈 옵션을 사용하여 모듈 실행&lt;/li&gt;
  &lt;li&gt;하나의 작업이 호스트 패턴과 일치하는 모든 시스템에서 완료되면 다음 작업으로 이동&lt;/li&gt;
  &lt;li&gt;특정 호스트에서 특정 작업이 실패하면 해당 호스트는 작업이 더 남아 있더라도 제외&lt;/li&gt;
&lt;/ol&gt;

&lt;h1 id=&quot;3-멱등성idempotent&quot;&gt;3. 멱등성(Idempotent)&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;수학이나 IT에서 연산의 한 성질을 나타낸다.&lt;/p&gt;

&lt;p&gt;연산/작업을 여러번 적용하더라도 결과가 달라지지 않는 성질을 의미한다.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ansible&lt;/code&gt; 의 대부분의 모듈은 최종적으로 원하는 상태가 달성되었는지 확인하고, 이미 원하는 최종 상태를 달성했다면 작업을 실행하지 않고, 몇번의 작업을 반복 실행하더라도 최종 상태가 변경되지 않는다.&lt;/p&gt;

&lt;p&gt;일부 모듈 및 모듈의 옵션에 따라 멱등성을 제공하지 않는 경우도 있다.&lt;/p&gt;

&lt;h1 id=&quot;4-멱등성을-제공하지-않는-예시&quot;&gt;4. 멱등성을 제공하지 않는 예시&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;모듈 :&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;command&lt;/li&gt;
  &lt;li&gt;shell&lt;/li&gt;
  &lt;li&gt;raw&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;service 모듈의 상태에 따라 :&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;state : restarted&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;5-핸들러handler&quot;&gt;5. 핸들러(Handler)&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;특정 작업이 실행되어 변경 사항이 발생한 경우에만 실행해야 하는 작업이 있는데, 이 작업을 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;핸들러&lt;/code&gt;라고 한다.&lt;/p&gt;

&lt;p&gt;대표적인 예는 설정 파일을 복사해서 서비스를 재시작 해야하는 경우이다.&lt;/p&gt;

&lt;p&gt;서비스를 항상 재시작하는 것은 멱등성을 만족하지 못한다.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;핸들러&lt;/code&gt;는 작업에 변경 사항이 발생한 경우에만 실행할 작업이다.&lt;/p&gt;

&lt;h1 id=&quot;6-멱등성을-만족하지-못하는-예&quot;&gt;6. 멱등성을 만족하지 못하는 예&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-12-[Ansible]_4.2_플레이북/6.png&quot; alt=&quot;6&quot; /&gt;&lt;/p&gt;

&lt;p&gt;이런식으로 매번 서비스를 재시작 하는것은 바람직하지 않다.&lt;/p&gt;

&lt;p&gt;설정 파일이 복사되었을때만 재시작 하는것이 바람직하다.&lt;/p&gt;

&lt;h1 id=&quot;7-멱등성을-상황에-따라-만족하는-예&quot;&gt;7. 멱등성을 상황에 따라 만족하는 예&lt;/h1&gt;
&lt;p&gt;–&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-12-[Ansible]_4.2_플레이북/7.png&quot; alt=&quot;7&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;핸들러&lt;/code&gt; 작업은 매번 실행하는 작업이 아니라 특정 조건에서만 싫애되는 작업이다.&lt;/p&gt;

&lt;p&gt;그 조건이 바로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;알림&lt;/code&gt; 을 받았을 때이며, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;알림&lt;/code&gt; 을 보내는 조건은 해당되는 모듈의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;changed&lt;/code&gt; 가 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;true&lt;/code&gt; 인 경우이다.&lt;/p&gt;

&lt;p&gt;이제 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;copy&lt;/code&gt; 가 이루어지면 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;알림&lt;/code&gt; 이 전송되고, 알림을 받은 작업은 실행을 하게 된다.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;알림&lt;/code&gt;이 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;notify&lt;/code&gt; 이고 해당 값인 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;restart apache2&lt;/code&gt; 라는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;알림&lt;/code&gt; 을 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;핸들러&lt;/code&gt; 가 받아서 작업을 실행한다.&lt;/p&gt;

&lt;p&gt;만약 이미 똑같은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ports.conf&lt;/code&gt; 가 이미 존재해서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;changed&lt;/code&gt; 가 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;false&lt;/code&gt; 이면, 변경이 없기 때문에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;notify&lt;/code&gt; 즉 알림이 전송되지 않으므로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;핸들러&lt;/code&gt; 작업이 실행되지 않는다.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;핸들러&lt;/code&gt;를 사용하는 주된 첫 번째 이유는 서비스를 언제 재시작하냐를 지정하는 것이다.&lt;/p&gt;

&lt;h1 id=&quot;8-테스트&quot;&gt;8. 테스트&lt;/h1&gt;
&lt;hr /&gt;

&lt;h2 id=&quot;핸들러-추가&quot;&gt;핸들러 추가&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/goorm-7th-ansible/01_playbook&lt;/code&gt; 에서 시작.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ssh 192.168.56.21 &lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt; /etc/apache2/ports.conf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-12-[Ansible]_4.2_플레이북/8.png&quot; alt=&quot;8&quot; /&gt;&lt;/p&gt;

&lt;p&gt;여기에서 다음의 내용을 복사한다.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Listen 80

&amp;lt;IfModule ssl_module&amp;gt;
        Listen 443
&amp;lt;/IfModule&amp;gt;

&amp;lt;IfModule mod_gnutls.c&amp;gt;
        Listen 443
&amp;lt;/IfModule&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;vi ports.conf.tpl
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;해당 파일에 붙여넣는다.&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tpl&lt;/code&gt; 은 템플릿이라는 뜻이다.&lt;/p&gt;

&lt;p&gt;이제 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;test.yaml&lt;/code&gt; 파일을 다음과 같이 수정한다.&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nn&quot;&gt;---&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# ansible mgmt -m apt -a &apos;name=apache2 state=present&apos;&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# ansible mgmt -m service -a &apos;name=apache2 enabled=true state=started&apos;&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# ansible mgmt -m file -a &apos;path=/var/www/html state=directory&apos;&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# ansible mgmt -m copy -a &apos;src=index.html dest=/var/www/html/index.html&apos;&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# ansible mgmt -m uri -a &apos;url=http://192.168.56.21 status_code=200 return_content=yes&apos;&lt;/span&gt;

&lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;hosts&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;mgmt&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;tasks&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;apt&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;apache2&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;present&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;service&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;apache2&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;enabled&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;true&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;started&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;copy&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;ports.conf.tpl&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;dest&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;/etc/apache2/ports.conf&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;notify&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;restart service&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;file&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;/var/www/html&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;directory&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;copy&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;index.html&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;dest&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;/var/www/html/index.html&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;handlers&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;restart service&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;service&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;apache2&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;restarted&lt;/span&gt;
&lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;hosts&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;localhost&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;tasks&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;uri&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;http://192.168.56.21&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;status_code&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;200&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;return_content&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;yes&lt;/span&gt;
&lt;span class=&quot;nn&quot;&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-12-[Ansible]_4.2_플레이북/10.png&quot; alt=&quot;10&quot; /&gt;&lt;/p&gt;

&lt;p&gt;설정 파일을 복사하는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;copy&lt;/code&gt; 모듈과 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;handler&lt;/code&gt; 를 추가하였다.&lt;/p&gt;

&lt;p&gt;이제 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;플레이북&lt;/code&gt;을 실행시키자.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible-playbook test.yaml &lt;span class=&quot;nt&quot;&gt;-b&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-12-[Ansible]_4.2_플레이북/8.png&quot; alt=&quot;8&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;copy&lt;/code&gt; 모듈에서 변경사항이 발생하였기 때문에(&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;changed&lt;/code&gt;), 모든 작업이 실행되고 난 뒤 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;핸들러&lt;/code&gt; 가 실행되었음을 확인할 수 있다.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;플레이북&lt;/code&gt; 을 한 번 더 실행하면, 이미 동일한 설정 파일이 존재하기 때문에 변경사항이 없으므로 핸들러가 실행되지 않는다.&lt;br /&gt;
즉 멱등성이 지켜지고 있다는 뜻이다.&lt;/p&gt;

&lt;p&gt;참고로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Gathering Facks&lt;/code&gt; 는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;플레이&lt;/code&gt; 를 실행할 떄 항상 처음에 실행되는 것이라고 생각하면 된다.&lt;br /&gt;
당장은 그 정도만 알고 넘어가자.&lt;/p&gt;

&lt;h2 id=&quot;name-추가&quot;&gt;name 추가&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;그런데 지금 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;copy&lt;/code&gt; 모듈이 2개라 각 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;copy&lt;/code&gt; 가 어떤 역할을 수행하는지 조금 헷갈린다.&lt;/p&gt;

&lt;p&gt;이를 개선해보도록 하자.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;test.yaml&lt;/code&gt; 파일을 다음과 같이 수정한다.&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nn&quot;&gt;---&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# ansible mgmt -m apt -a &apos;name=apache2 state=present&apos;&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# ansible mgmt -m service -a &apos;name=apache2 enabled=true state=started&apos;&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# ansible mgmt -m file -a &apos;path=/var/www/html state=directory&apos;&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# ansible mgmt -m copy -a &apos;src=index.html dest=/var/www/html/index.html&apos;&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# ansible mgmt -m uri -a &apos;url=http://192.168.56.21 status_code=200 return_content=yes&apos;&lt;/span&gt;

&lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Install Web Server&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;hosts&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;mgmt&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;tasks&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Install Apache2 Package&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;apt&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;apache2&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;present&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Checking Apache Service with Running&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;service&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;apache2&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;enabled&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;true&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;started&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Change Apache Service Port&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;copy&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;ports.conf.tpl&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;dest&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;/etc/apache2/ports.conf&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;notify&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Restart Apache2 Service&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Checking Web Contents Directory&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;file&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;/var/www/html&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;directory&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Copy Web Contents&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;copy&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;index.html&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;dest&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;/var/www/html/index.html&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;handlers&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Restart Apache2 Service&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;service&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;apache2&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;restarted&lt;/span&gt;
&lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Remote Access Check&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;hosts&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;localhost&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;tasks&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Access Check&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;uri&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;http://192.168.56.21&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;status_code&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;200&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;return_content&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;yes&lt;/span&gt;
&lt;span class=&quot;nn&quot;&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-12-[Ansible]_4.2_플레이북/11.png&quot; alt=&quot;11&quot; /&gt;&lt;/p&gt;

&lt;p&gt;각 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;플레이&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;모듈&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;핸들러&lt;/code&gt;에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;name&lt;/code&gt; 으로 이름을 붙여주었다.&lt;br /&gt;
이제 다시 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;플레이북&lt;/code&gt; 을 실행해보자.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible-playbook test.yaml &lt;span class=&quot;nt&quot;&gt;-b&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-12-[Ansible]_4.2_플레이북/12.png&quot; alt=&quot;12&quot; /&gt;&lt;/p&gt;

&lt;p&gt;더 보기 편해졌다.&lt;/p&gt;

&lt;h2 id=&quot;become-추가&quot;&gt;become 추가&lt;/h2&gt;
&lt;hr /&gt;

&lt;p&gt;또 추가적으로, 매번 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;become&lt;/code&gt; 옵션을 넣기 귀찮다면 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;플레이&lt;/code&gt; 에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;become: true&lt;/code&gt; 를 넣음으로써 생략할 수 있다.&lt;/p&gt;

&lt;p&gt;최종적인 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;test.yaml&lt;/code&gt; 은 다음과 같다.&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nn&quot;&gt;---&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# ansible mgmt -m apt -a &apos;name=apache2 state=present&apos;&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# ansible mgmt -m service -a &apos;name=apache2 enabled=true state=started&apos;&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# ansible mgmt -m file -a &apos;path=/var/www/html state=directory&apos;&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# ansible mgmt -m copy -a &apos;src=index.html dest=/var/www/html/index.html&apos;&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# ansible mgmt -m uri -a &apos;url=http://192.168.56.21 status_code=200 return_content=yes&apos;&lt;/span&gt;

&lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Install Web Server&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;hosts&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;mgmt&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;become&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;tasks&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Install Apache2 Package&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;apt&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;apache2&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;present&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Checking Apache Service with Running&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;service&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;apache2&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;enabled&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;true&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;started&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Change Apache Service Port&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;copy&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;ports.conf.tpl&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;dest&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;/etc/apache2/ports.conf&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;notify&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Restart Apache2 Service&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Checking Web Contents Directory&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;file&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;/var/www/html&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;directory&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Copy Web Contents&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;copy&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;index.html&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;dest&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;/var/www/html/index.html&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;handlers&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Restart Apache2 Service&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;service&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;apache2&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;restarted&lt;/span&gt;
&lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Remote Access Check&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;hosts&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;localhost&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;tasks&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Access Check&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;uri&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;http://192.168.56.21&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;status_code&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;200&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;return_content&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;yes&lt;/span&gt;
&lt;span class=&quot;nn&quot;&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;계속 test 라고 쓰기는 애매해서 파일명을 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;install.yaml&lt;/code&gt; 로 바꾸어 주었다.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;mv &lt;/span&gt;test.yaml install.yaml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;removeyaml&quot;&gt;remove.yaml&lt;/h2&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;apache2&lt;/code&gt; 웹 서버를 생성하는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;플레이북&lt;/code&gt;을 만들었으니, 제거하는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;플레이북&lt;/code&gt;도 만들어보자.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;vi remove.yaml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;아래 내용을 넣는다.&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nn&quot;&gt;---&lt;/span&gt;
&lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Remove Apache2&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;hosts&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;mgmt&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;become&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;true&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;tasks&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Stop Apache2 Service&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;service&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;apache2&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;stopped&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;ignore_errors&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Remove Web Contents&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;file&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;/var/www/html&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;absent&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Remove Apache2 Package&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;apt&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;apache2&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;absent&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;autoremove&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;true&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;purge&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;nn&quot;&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible-playbook remove.yaml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-12-[Ansible]_4.2_플레이북/13.png&quot; alt=&quot;13&quot; /&gt;&lt;/p&gt;

&lt;p&gt;성공적으로 제거되었다.&lt;/p&gt;
</description>
        <pubDate>Sat, 10 Dec 2022 17:00:00 +0900</pubDate>
        <link>https://hjy.today/study/Ansible-_4.2_%ED%94%8C%EB%A0%88%EC%9D%B4%EB%B6%81.html</link>
        <guid isPermaLink="true">https://hjy.today/study/Ansible-_4.2_%ED%94%8C%EB%A0%88%EC%9D%B4%EB%B6%81.html</guid>
        
        <category>ansible</category>
        
        
        <category>study</category>
        
      </item>
    
      <item>
        <title>[Ansible] #4.1 YAML</title>
        <description>&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ansible&lt;/code&gt; 의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;플레이북&lt;/code&gt; 의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;YAML&lt;/code&gt; 형식에 대해서 알아보자.&lt;/p&gt;

&lt;!--more--&gt;

&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#1-yaml-기본&quot; id=&quot;markdown-toc-1-yaml-기본&quot;&gt;1. YAML 기본&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#2-목록list&quot; id=&quot;markdown-toc-2-목록list&quot;&gt;2. 목록(List)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#3-사전&quot; id=&quot;markdown-toc-3-사전&quot;&gt;3. 사전&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#4-사전--목록-혼합&quot; id=&quot;markdown-toc-4-사전--목록-혼합&quot;&gt;4. 사전 / 목록 혼합&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#5-사전--목록-혼합---축약형&quot; id=&quot;markdown-toc-5-사전--목록-혼합---축약형&quot;&gt;5. 사전 / 목록 혼합 - 축약형&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#6-불리언boolean&quot; id=&quot;markdown-toc-6-불리언boolean&quot;&gt;6. 불리언(Boolean)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#7-멀티라인-값&quot; id=&quot;markdown-toc-7-멀티라인-값&quot;&gt;7. 멀티라인 값&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#8-플레이북-작성-시-팁&quot; id=&quot;markdown-toc-8-플레이북-작성-시-팁&quot;&gt;8. 플레이북 작성 시 팁&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h1 id=&quot;1-yaml-기본&quot;&gt;1. YAML 기본&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;선택적으로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;YAML&lt;/code&gt; 문서의 시작은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;---&lt;/code&gt; 로 시작하고 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;...&lt;/code&gt; 으로 끝낸다. &lt;br /&gt;
필수는 아니고, 관습적으로 하는것.&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ansible&lt;/code&gt; 에서 모든 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;YAML&lt;/code&gt; 파일은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-&lt;/code&gt; 로 시작하는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;목록(List)&lt;/code&gt; 으로 시작한다.&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;YAML&lt;/code&gt; 파일은 많은 곳에 쓰지만 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ansible&lt;/code&gt; 에서만 항상 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-&lt;/code&gt; 로 시작하는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;목록&lt;/code&gt; 으로 시작한다.&lt;/p&gt;

&lt;p&gt;각 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;목록&lt;/code&gt; 의 항목은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;사전(Dictionary, hash)&lt;/code&gt; 이라고 하는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;키/값&lt;/code&gt; 쌍을 가진다.&lt;/p&gt;

&lt;p&gt;형식에 따른 표현은 다음과 같다.&lt;br /&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Key=Value&lt;/code&gt; : &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;INI&lt;/code&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Key:Value&lt;/code&gt; : &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;YAML&lt;/code&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;들여쓰기는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;탭&lt;/code&gt;이 아닌 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;공백(일반적으로 공백 2칸)&lt;/code&gt;으로 한다.&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;파일의 확장자는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;yml&lt;/code&gt; 또는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;yaml&lt;/code&gt; 을 사용한다.&lt;/p&gt;

&lt;h1 id=&quot;2-목록list&quot;&gt;2. 목록(List)&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;목록은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;순서(Order)&lt;/code&gt; 를 가진다.&lt;br /&gt;
리스트는 위에서 아래 방향이다.&lt;br /&gt;
목록은 대시와 공백으로 시작하며 동일한 들여쓰기 수준을 가진다.&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-&lt;/code&gt; 뒤에 띄워쓰기를 한 칸 해야함을 명심하자.&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-10-[Ansible]_4.1_YAML/1.png&quot; alt=&quot;1&quot; /&gt;&lt;/p&gt;

&lt;h1 id=&quot;3-사전&quot;&gt;3. 사전&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Dictionary&lt;/code&gt; 또는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Hash&lt;/code&gt; 라고 한다.&lt;/p&gt;

&lt;p&gt;위 목록처럼 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;String&lt;/code&gt; 만 들어가는 경우는 거의 없고, 사전 처럼 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;키/값&lt;/code&gt; 쌍으로 위치한다.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-10-[Ansible]_4.1_YAML/2.png&quot; alt=&quot;2&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;name&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;job&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;skill&lt;/code&gt; 앞에 두 칸 띄워쓰기로 들여쓰기가 구현되어 있고, 이렇게 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;키/값&lt;/code&gt; 쌍으로 이루어진 것 하나하나를 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Dictionary&lt;/code&gt; 라고 한다.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;martin(키)&lt;/code&gt; / &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;name,job,skill(값)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;name(키)&lt;/code&gt; / &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Martin D’ vloper(값)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;이런 식으로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;계층적 키 값 관계&lt;/code&gt;를 가진다.&lt;/p&gt;

&lt;h1 id=&quot;4-사전--목록-혼합&quot;&gt;4. 사전 / 목록 혼합&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-10-[Ansible]_4.1_YAML/3.png&quot; alt=&quot;3&quot; /&gt;&lt;/p&gt;

&lt;p&gt;위 처럼 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;키 - 값(키) - 값&lt;/code&gt; 과 같은 식으로 많이 나타난다.&lt;br /&gt;
위 파일은, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;martin&lt;/code&gt; 과 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tabitha&lt;/code&gt; 두 개의 리스트를 가진다고 볼 수 있다.&lt;br /&gt;
이 때 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;martin&lt;/code&gt; 이 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;키&lt;/code&gt;이고 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;name&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;job&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;skills&lt;/code&gt; 모두 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;값&lt;/code&gt;이 되며, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;skills&lt;/code&gt; 는 또 하나의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;키&lt;/code&gt;가 되고 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;값&lt;/code&gt;으로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;python&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;per1&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pascal&lt;/code&gt; 이라는 리스트를 포함한다.&lt;/p&gt;

&lt;p&gt;근데 언제는 리스트(&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-&lt;/code&gt;)를 쓰고 언제는 안쓰냐 ?&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;도커&lt;/code&gt;랑 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;쿠버네티스&lt;/code&gt; 다 언제 쓰고 언제 안쓰는지가 모두 다르다…&lt;br /&gt;
일단은 대충 알고 넘어가자.&lt;/p&gt;

&lt;h1 id=&quot;5-사전--목록-혼합---축약형&quot;&gt;5. 사전 / 목록 혼합 - 축약형&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-10-[Ansible]_4.1_YAML/4.png&quot; alt=&quot;4&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;목록&lt;/code&gt; : &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[ ]&lt;/code&gt; 블록&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;사전&lt;/code&gt; : &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;{ }&lt;/code&gt; 블록&lt;/p&gt;

&lt;p&gt;너무 파일이 길어질경우 축약형으로 한 줄에 늘여서 쓸 수도 있다.&lt;/p&gt;

&lt;p&gt;이렇게도 쓸 수 있지만, 이런식으로 늘여 쓰면 가독성이 안좋아질 수 있다.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;YAML&lt;/code&gt; 파일은 되도록이면 괄호를 쓰지 않는 것을 원칙으로 하기 때문에, 이왕이면 위 방식으로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;YAML&lt;/code&gt; 파일을 사용하고 축약형으로는 익숙해지면 사용하도록 하자.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;YAML&lt;/code&gt; 의 목적은 사람이 읽고 쓰기 쉽게 하기 위함인데 익숙하지 않으면 정말 고통스러울 수 있다 …&lt;/p&gt;

&lt;h1 id=&quot;6-불리언boolean&quot;&gt;6. 불리언(Boolean)&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-10-[Ansible]_4.1_YAML/5.png&quot; alt=&quot;5&quot; /&gt;&lt;/p&gt;

&lt;p&gt;따옴표(&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&apos;&lt;/code&gt;)를 쓰면 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;String&lt;/code&gt; 이 되기 때문에 절대 쓰지 말자.&lt;/p&gt;

&lt;p&gt;비단 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;불리언&lt;/code&gt; 뿐만 아니라 숫자에도 따옴표를 붙이면 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;String&lt;/code&gt;이 된다.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;yes&lt;/code&gt; = &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;true&lt;/code&gt; = &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;True&lt;/code&gt; = &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;TRUE&lt;/code&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;no&lt;/code&gt; = &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;false&lt;/code&gt; = &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;False&lt;/code&gt; = &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FALSE&lt;/code&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;7-멀티라인-값&quot;&gt;7. 멀티라인 값&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-10-[Ansible]_4.1_YAML/6.png&quot; alt=&quot;6&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;key&lt;/code&gt; 에 대한 하나의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;value&lt;/code&gt; 를 이렇게 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;|&lt;/code&gt; , &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;gt;&lt;/code&gt; 를 이용해서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;멀티라인&lt;/code&gt;으로 작성할수도 있다.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;|&lt;/code&gt; 나 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;gt;&lt;/code&gt; 나 기본적으로 둘 다 동일하다.&lt;br /&gt;
이렇게 작성하는 이유는 가독성 때문이다.&lt;/p&gt;

&lt;h1 id=&quot;8-플레이북-작성-시-팁&quot;&gt;8. 플레이북 작성 시 팁&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vim&lt;/code&gt; 에디터 : &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vim&lt;/code&gt; 환경 설정 파일&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.vimrc&lt;/code&gt; 파일을 생성하자.&lt;br /&gt;
그리고 아래 코드를 넣어준다.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;syntax on
autocmd FileType yaml setlocal &lt;span class=&quot;nv&quot;&gt;ts&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;2 &lt;span class=&quot;nv&quot;&gt;sts&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;2 &lt;span class=&quot;nv&quot;&gt;sw&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;2 expandtab autoindent
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;이렇게 하면 원래 공백 8칸이던 탭키가 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;yaml&lt;/code&gt; 파일을 수정할때는 공백 2칸이 된다.&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;VS Code&lt;/code&gt; 를 쓴다면, 아래 확장 플러그인을 설치하면 유용하다.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Visual Studio Code : YAML, Ansible 확장 플러그인 설치&lt;/p&gt;

    &lt;p&gt;&lt;a href=&quot;https://marketplace.visualstudio.com/&quot;&gt;Extensions for Visual Studio family of products _ Visual Studio Marketplace&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Sat, 10 Dec 2022 17:00:00 +0900</pubDate>
        <link>https://hjy.today/study/Ansible-_4.1_YAML.html</link>
        <guid isPermaLink="true">https://hjy.today/study/Ansible-_4.1_YAML.html</guid>
        
        <category>ansible</category>
        
        
        <category>study</category>
        
      </item>
    
      <item>
        <title>[Ansible] #3.5 Ansible 기본 - Ad-hoc 명령</title>
        <description>&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ansible&lt;/code&gt; 의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ad-hoc&lt;/code&gt; 명령에 대해서 알아보자.&lt;/p&gt;

&lt;!--more--&gt;

&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#1-ad-hoc-명령&quot; id=&quot;markdown-toc-1-ad-hoc-명령&quot;&gt;1. Ad-hoc 명령&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#2-모듈의-반환-값&quot; id=&quot;markdown-toc-2-모듈의-반환-값&quot;&gt;2. 모듈의 반환 값&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h1 id=&quot;1-ad-hoc-명령&quot;&gt;1. Ad-hoc 명령&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;하나 이상의 관리 노드에 하나의 모듈을 정의해 단일 작업을 실행하는 임시 명령이다.&lt;br /&gt;
반복이 필요하지 않은 간단한 작업에 주로 사용한다.&lt;br /&gt;&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;OPTIONS] pattern
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;OPTION&lt;/code&gt; 은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pattern&lt;/code&gt; 뒤에 넣어도 된다.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;pattern&lt;br /&gt;
  인벤토리 파일에 있는 호스트/그룹이름 또는 패턴(정규화 표현식)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;예:&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; inven.ini &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; apt &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;name=apache2 state=present&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; ssh &lt;span class=&quot;nt&quot;&gt;-u&lt;/span&gt; ubuntu &lt;span class=&quot;nt&quot;&gt;-b&lt;/span&gt; webservers
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;2-모듈의-반환-값&quot;&gt;2. 모듈의 반환 값&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;일반적으로 공통으로 사용되는 모듈의 반환 값에 대한 설명이다.&lt;/p&gt;

&lt;p&gt;일반적인 모듈의 반환 값 이외에 모듈에 따라 반환 값은 다르다.&lt;/p&gt;

&lt;p&gt;모듈의 반환 값은 모듈의 설명서를 참조한다.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html&quot;&gt;Return Values — Ansible Documentation&lt;/a&gt;&lt;/p&gt;
</description>
        <pubDate>Wed, 07 Dec 2022 03:30:00 +0900</pubDate>
        <link>https://hjy.today/study/Ansible-_3.5_Ansible_%EA%B8%B0%EB%B3%B8_-_Ad-hoc_%EB%AA%85%EB%A0%B9.html</link>
        <guid isPermaLink="true">https://hjy.today/study/Ansible-_3.5_Ansible_%EA%B8%B0%EB%B3%B8_-_Ad-hoc_%EB%AA%85%EB%A0%B9.html</guid>
        
        <category>ansible</category>
        
        
        <category>study</category>
        
      </item>
    
      <item>
        <title>[Ansible] 오류 SSH auth method: private key Timed out</title>
        <description>&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ansible&lt;/code&gt; 오류 정리&lt;br /&gt;
SSH auth method: private key Timed out while waiting for the machine to boot&lt;/p&gt;

&lt;!--more--&gt;

&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#1-오류&quot; id=&quot;markdown-toc-1-오류&quot;&gt;1. 오류&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#2-오류-원인&quot; id=&quot;markdown-toc-2-오류-원인&quot;&gt;2. 오류 원인&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#3-해결-방법&quot; id=&quot;markdown-toc-3-해결-방법&quot;&gt;3. 해결 방법&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h1 id=&quot;1-오류&quot;&gt;1. 오류&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-07-[Ansible]_오류_SSH_auth_method_private_key_Timed_out_while_waiting_for_the_machine_to_boot/1.png&quot; alt=&quot;1&quot; /&gt;&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;iac-node1: SSH auth method: pivate key 
Timed out &lt;span class=&quot;k&quot;&gt;while &lt;/span&gt;waiting &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;config.vm.boot_timeout&quot;&lt;/span&gt; value&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;time &lt;/span&gt;period.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;2-오류-원인&quot;&gt;2. 오류 원인&lt;/h1&gt;
&lt;hr /&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;vagrant up
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;이전에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vagrant halt&lt;/code&gt; 로 VM을 정상종료 하지 않고 꺼버렸더니, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vagrant up&lt;/code&gt; 을 할 때 이와 같은 문제가 발생했다.&lt;br /&gt;
정상 종료하지 않으면 다음 번 접속 때 문제가 발생할 수 있다는 것을 처음 알게 되었다 …&lt;/p&gt;

&lt;h1 id=&quot;3-해결-방법&quot;&gt;3. 해결 방법&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;우선 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;VirtualBox&lt;/code&gt; 를 켜준다.&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-07-[Ansible]_오류_SSH_auth_method_private_key_Timed_out_while_waiting_for_the_machine_to_boot/2.png&quot; alt=&quot;2&quot; /&gt;&lt;/p&gt;

&lt;p&gt;이제 각 VM의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;시작(T)&lt;/code&gt; - &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;일반 시작(N)&lt;/code&gt; 을 눌러 접속한다.&lt;br /&gt;
만약에 이미 켜져있으면, 전원을 종료한 뒤 다시 시작해주자.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-07-[Ansible]_오류_SSH_auth_method_private_key_Timed_out_while_waiting_for_the_machine_to_boot/3.png&quot; alt=&quot;3&quot; /&gt;&lt;/p&gt;

&lt;p&gt;모든 VM이 정상적으로 전원이 켜지고, 주루루룩 줄이 내려가다가 유저 로그인 화면까지 출력되면 다시 터미널로 넘어가자.&lt;br /&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;vagrant halt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-07-[Ansible]_오류_SSH_auth_method_private_key_Timed_out_while_waiting_for_the_machine_to_boot/4.png&quot; alt=&quot;4&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;halt&lt;/code&gt; 로 VM을 정상 종료해준다.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-07-[Ansible]_오류_SSH_auth_method_private_key_Timed_out_while_waiting_for_the_machine_to_boot/5.png&quot; alt=&quot;5&quot; /&gt;&lt;/p&gt;

&lt;p&gt;종료가 확인되었으면, 이제 다시 켜주자.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;vagrant up
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;이 때 만약 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SSH auth method: private key&lt;/code&gt; 단계에서 멈춘다면, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;VirtualBox&lt;/code&gt; 에서 켜는 중인 VM을 클릭해주자.&lt;br /&gt;
그러면 미리보기에서 로그가 주루룩 내려가면서, 터미널에서도 제대로 연결이 된다.&lt;br /&gt;
슈뢰딩거의 VM도 아니고 … 이 단계에서 10분을 기다렸는데 안되어서 직접 보고자 들어갔더니 그제서야 되길래 황당했다 …&lt;/p&gt;
</description>
        <pubDate>Wed, 07 Dec 2022 01:30:00 +0900</pubDate>
        <link>https://hjy.today/study/Ansible-_%EC%98%A4%EB%A5%98_SSH_auth_method_private_key_Timed_out_while_waiting_for_the_machine_to_boot.html</link>
        <guid isPermaLink="true">https://hjy.today/study/Ansible-_%EC%98%A4%EB%A5%98_SSH_auth_method_private_key_Timed_out_while_waiting_for_the_machine_to_boot.html</guid>
        
        <category>ansible</category>
        
        <category>ansible-error</category>
        
        
        <category>study</category>
        
      </item>
    
      <item>
        <title>[Ansible] 오류 Permission denied @ rb_sysopen (Errno::EACCES)</title>
        <description>&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ansible&lt;/code&gt; 오류 정리&lt;br /&gt;
C:/HashiCorp/Vagrant/embedded/gems/2.3.2/gems/vagrant-2.3.2/plugins/providers/virtualbox/action/set_name.rb:46:in `initialize’: Permission denied @ rb_sysopen - C:/Windows/System32/vagrant/iac/.vagrant/machines/iac-control1/virtualbox/action_set_name (Errno::EACCES)&lt;/p&gt;

&lt;!--more--&gt;

&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#1-오류&quot; id=&quot;markdown-toc-1-오류&quot;&gt;1. 오류&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#2-오류-원인&quot; id=&quot;markdown-toc-2-오류-원인&quot;&gt;2. 오류 원인&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#3-해결-방법&quot; id=&quot;markdown-toc-3-해결-방법&quot;&gt;3. 해결 방법&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h1 id=&quot;1-오류&quot;&gt;1. 오류&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-07-[Ansible]_오류_Permission_denied_@_rb_sysopen_(Errno_EACCES)/1.png&quot; alt=&quot;1&quot; /&gt;&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;C:/HashiCorp/Vagrant/embedded/gems/2.3.2/gems/vagrant-2.3.2/plugins/providers/virtualbox/action/set_name.rb:46:in &lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;initialize&lt;span class=&quot;s1&quot;&gt;&apos;: Permission denied @ rb_sysopen - C:/Windows/System32/vagrant/iac/.vagrant/machines/iac-control1/virtualbox/action_set_name (Errno::EACCES)
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;2-오류-원인&quot;&gt;2. 오류 원인&lt;/h1&gt;
&lt;hr /&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;vagrant up
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vagrant up&lt;/code&gt; 실행 시 오류 발생.&lt;br /&gt;
터미널을 계속 켜두고 작업을 하던지라 깜빡했는데, 터미널을 킬 때 반드시 관리자 권한으로 실행해야한다.&lt;br /&gt;&lt;/p&gt;

&lt;h1 id=&quot;3-해결-방법&quot;&gt;3. 해결 방법&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;우선 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;VirtualBox&lt;/code&gt; 를 켜준다.&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-07-[Ansible]_오류_Permission_denied_@_rb_sysopen_(Errno_EACCES)/2.png&quot; alt=&quot;2&quot; /&gt;&lt;/p&gt;

&lt;p&gt;관리자 권한으로 실행해주자.&lt;/p&gt;
</description>
        <pubDate>Wed, 07 Dec 2022 01:30:00 +0900</pubDate>
        <link>https://hjy.today/study/Ansible-_%EC%98%A4%EB%A5%98_Permission_denied_@_rb_sysopen_(Errno_EACCES).html</link>
        <guid isPermaLink="true">https://hjy.today/study/Ansible-_%EC%98%A4%EB%A5%98_Permission_denied_@_rb_sysopen_(Errno_EACCES).html</guid>
        
        <category>ansible</category>
        
        <category>ansible-error</category>
        
        
        <category>study</category>
        
      </item>
    
      <item>
        <title>[Ansible] #3.4.2 Ansible 기본 - 모듈 상세</title>
        <description>&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ansible&lt;/code&gt; 의 기본 구성 요소인 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;모듈&lt;/code&gt; 중 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ping&lt;/code&gt; , &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;command&lt;/code&gt;&lt;/p&gt;

&lt;!--more--&gt;

&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#1-ping&quot; id=&quot;markdown-toc-1-ping&quot;&gt;1. ping&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#2-command&quot; id=&quot;markdown-toc-2-command&quot;&gt;2. command&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#3-copy&quot; id=&quot;markdown-toc-3-copy&quot;&gt;3. copy&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#4-fetch&quot; id=&quot;markdown-toc-4-fetch&quot;&gt;4. fetch&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#5-file&quot; id=&quot;markdown-toc-5-file&quot;&gt;5. file&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#생성-및-변경&quot; id=&quot;markdown-toc-생성-및-변경&quot;&gt;생성 및 변경&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#삭제&quot; id=&quot;markdown-toc-삭제&quot;&gt;삭제&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#6-apt&quot; id=&quot;markdown-toc-6-apt&quot;&gt;6. apt&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#7-service&quot; id=&quot;markdown-toc-7-service&quot;&gt;7. service&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#8-replace&quot; id=&quot;markdown-toc-8-replace&quot;&gt;8. replace&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h1 id=&quot;1-ping&quot;&gt;1. ping&lt;/h1&gt;
&lt;hr /&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible mgmt &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; ping
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-03-[Ansible]-3.4.2_Ansible_기본_-_모듈_상세/1.png&quot; alt=&quot;1&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;모듈&lt;/code&gt; 을 사용한 명령문의 기본 정보에 대해서 알아보자.&lt;br /&gt;
위 명령어는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ping&lt;/code&gt; 이라는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;모듈&lt;/code&gt; 을 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mgmt&lt;/code&gt; 에 실행한 결과를 반환한다.&lt;br /&gt;
즉, 반환된 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ansible_facts&lt;/code&gt; , &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;changed&lt;/code&gt; , &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ping&lt;/code&gt; 등은 모두 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;return value&lt;/code&gt; 이다.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible mgmt &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; ping &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;data=xyz&apos;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-03-[Ansible]-3.4.2_Ansible_기본_-_모듈_상세/2.png&quot; alt=&quot;2&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ping&lt;/code&gt; 모듈에 대해서 좀 더 보자면, 기본적으로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ping&lt;/code&gt; 이라는 프로토콜은 랜덤 문자를 보내고 그게 그대로 돌아오는지를 확인하는 매커니즘을 가지고있다.
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ansible&lt;/code&gt; 에서의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ping&lt;/code&gt; 모듈은 기본적으로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ping&lt;/code&gt; 이라는 값을 보내서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pong&lt;/code&gt; 이라는 값이 오는지를 확인한다.&lt;br /&gt;
위 명령어는 이 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pong&lt;/code&gt; 대신, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xyz&lt;/code&gt; 라는 값을 반환하고, 확인하도록 변경하였다.&lt;br /&gt;
이러한 기능, 옵션 등을 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Specification&lt;/code&gt;이라고 하며, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ansible-doc&lt;/code&gt; 에서 확인할 수 있다.&lt;/p&gt;

&lt;h1 id=&quot;2-command&quot;&gt;2. command&lt;/h1&gt;
&lt;hr /&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible-doc &lt;span class=&quot;nb&quot;&gt;command&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-03-[Ansible]-3.4.2_Ansible_기본_-_모듈_상세/6.png&quot; alt=&quot;6&quot; /&gt;&lt;/p&gt;

&lt;p&gt;위 명령어로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;command&lt;/code&gt; 에 대한 정보를 쭉 보다보면 다음과 같은 설명이 있다.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-03-[Ansible]-3.4.2_Ansible_기본_-_모듈_상세/7.png&quot; alt=&quot;7&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;OPTIONS&lt;/code&gt; 항목에 대한 설명중 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;free_form&lt;/code&gt; 이라는 것이 있다.&lt;br /&gt;
자유형식이라는 뜻으로, 설명을 읽어보면 실행시킬 명령을 자유형식의 문자열로 넣으라고 안내되어있다.&lt;br /&gt;
또한 이는 실제 파라미터가 아니며, 단지 자유형식이라는 의미이다.&lt;br /&gt;
따라서 다음과 같이 자유롭게 명령을 옵션으로 넣을 수 있다.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible mgmt &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;command&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;id&apos;&lt;/span&gt;
ansible mgmt &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;command&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;ls -l&apos;&lt;/span&gt;
ansible mgmt &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;command&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;ps&apos;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-03-[Ansible]-3.4.2_Ansible_기본_-_모듈_상세/8.png&quot; alt=&quot;8&quot; /&gt;&lt;/p&gt;

&lt;p&gt;하지만 다음 명령문을 보자.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible mgmt &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;command&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;ps | grep python3&apos;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-03-[Ansible]-3.4.2_Ansible_기본_-_모듈_상세/9.png&quot; alt=&quot;9&quot; /&gt;&lt;/p&gt;

&lt;p&gt;실패한다.&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;일단 기본적으로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;부모 프로세스&lt;/code&gt; 와 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;자식 프로세스&lt;/code&gt; 에 대한 이해가 필요하다.&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;부모 프로세스&lt;/code&gt; 는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bash&lt;/code&gt; 라고 생각하고, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;자식 프로세스&lt;/code&gt; 는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bash&lt;/code&gt; 에서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ls&lt;/code&gt; 를 실행한다고 생각하자.&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;부모 프로세스&lt;/code&gt; 인 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bash&lt;/code&gt; 는 실행중이고, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bash&lt;/code&gt; 에서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ls&lt;/code&gt; 를 실행하려면 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;자식 프로세스&lt;/code&gt; 에게 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fork()&lt;/code&gt; 를 하게 된다.&lt;br /&gt;
즉 메모리를 복사하게 된다.&lt;br /&gt;
그리고 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;부모 프로세스&lt;/code&gt; 는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;자식 프로세스&lt;/code&gt; 가 종료할 때 까지 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wait()&lt;/code&gt; , 대기하게 된다.&lt;br /&gt;
그 동안 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;자식 프로세스&lt;/code&gt; 는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;exec()&lt;/code&gt; , 실행하게 된다.&lt;br /&gt;
여기서의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fork()&lt;/code&gt; , &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wait()&lt;/code&gt; , &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;exec()&lt;/code&gt; 는 모두 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;C&lt;/code&gt; 함수들이다.&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Linux&lt;/code&gt; 는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;C&lt;/code&gt; 로 만들어져있기 때문이다.&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;자식 프로세스&lt;/code&gt; 에서의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ls&lt;/code&gt; 가 끝나게 되면, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;exit()&lt;/code&gt;, 종료를 하게 되고 이때 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;return code&lt;/code&gt; 를 같이 전송을 시킨다.&lt;br /&gt;
기본적으로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;return code&lt;/code&gt; 는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0&lt;/code&gt; 만이 정상 종료이고, 나머지 모든 값은 비정상 종료이다.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;ls
echo&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$?&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-03-[Ansible]-3.4.2_Ansible_기본_-_모듈_상세/10.png&quot; alt=&quot;10&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;echo $?&lt;/code&gt; 의 결과값 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0&lt;/code&gt; 이 방금 실행한 프로세스, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ls&lt;/code&gt; 의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;return code&lt;/code&gt; 이다.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-K&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$?&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-03-[Ansible]-3.4.2_Ansible_기본_-_모듈_상세/11.png&quot; alt=&quot;11&quot; /&gt;&lt;/p&gt;

&lt;p&gt;이번에는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ls -K&lt;/code&gt; 에서 오류가 발생했다.&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ls&lt;/code&gt; 에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-K&lt;/code&gt; 라는 옵션은 존재하지 않는다.&lt;br /&gt;
따라서 해당 프로세스는 비정상 종료하며, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;return code&lt;/code&gt; 로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;2&lt;/code&gt; 를 반환했음을 알 수 있다.
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;2&lt;/code&gt; 가 무엇을 의미하는지는 다음을 통해 알 수 있다.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;man &lt;span class=&quot;nb&quot;&gt;ls&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-03-[Ansible]-3.4.2_Ansible_기본_-_모듈_상세/12.png&quot; alt=&quot;12&quot; /&gt;&lt;/p&gt;

&lt;p&gt;쭉 내리면, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Exit status&lt;/code&gt; 에서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;2&lt;/code&gt; 가 무엇을 의미하는지가 나온다.&lt;br /&gt;
이는 각 명령어마다 다 다르기 때문에 모든 명령어의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;status&lt;/code&gt; 가 의미하는 자세한 바를 외우기는 힘드지만, 공통적으로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0&lt;/code&gt; 이 의미하는 바는 정상 종료이다.&lt;/p&gt;

&lt;p&gt;다시 돌아와서, 그럼 다음의 명령어와 결과를 다시 보자.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible mgmt &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;command&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;ps | grep python3&apos;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-03-[Ansible]-3.4.2_Ansible_기본_-_모듈_상세/9.png&quot; alt=&quot;9&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;return code&lt;/code&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;1&lt;/code&gt; , 즉 실패다.&lt;br /&gt;
이유는 간단하다.&lt;br /&gt;
우리는 앞서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;command&lt;/code&gt; 가 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;쉘&lt;/code&gt; 을 사용하지 않는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;모듈&lt;/code&gt; 이라는 것을 배웠다.&lt;br /&gt;
하지만 인자로 들어간 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;|&lt;/code&gt; 는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;쉘&lt;/code&gt; 의 기능이므로, 오류가 발생한것이다.&lt;br /&gt;
다음의 명령과 비교해보자.&lt;br /&gt;&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible mgmt &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; shell &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;ps | grep python3&apos;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-03-[Ansible]-3.4.2_Ansible_기본_-_모듈_상세/13.png&quot; alt=&quot;13&quot; /&gt;&lt;/p&gt;

&lt;p&gt;잘 실행된다.&lt;/p&gt;

&lt;h1 id=&quot;3-copy&quot;&gt;3. copy&lt;/h1&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;hello&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; hello.txt
&lt;span class=&quot;nb&quot;&gt;cat &lt;/span&gt;hello.txt
ansible mgmt &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; copy &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;src=hello.txt dest=/tmp/hello.txt&apos;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-03-[Ansible]-3.4.2_Ansible_기본_-_모듈_상세/3.png&quot; alt=&quot;3&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dest&lt;/code&gt; 는 원격지의 절대경로, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;src&lt;/code&gt; 는 로컬 상대경로, 절대경로 로 쓰면 된다.&lt;br /&gt;
참고로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ansible-doc&lt;/code&gt; 으로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;copy&lt;/code&gt; 의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;spec&lt;/code&gt; 을 보면, 다른 옵션은 앞에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-&lt;/code&gt; 가 붙어있지만 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dest&lt;/code&gt; 는 앞에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;=&lt;/code&gt; 이 붙어있다.&lt;br /&gt;
이는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mandatory&lt;/code&gt; , 즉 필수 옵션이라는 뜻이다.&lt;/p&gt;

&lt;p&gt;파일이 복사되었기 때문에, 변경 내역이 있으므로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;“changed”&lt;/code&gt; 는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;true&lt;/code&gt; 가 되고, 이는 상태가 계속 변하는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;가변 인프라&lt;/code&gt; 임을 나타낸다.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible mgmt &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; copy &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;src=hello.txt dest=/tmp/hello.txt&apos;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-03-[Ansible]-3.4.2_Ansible_기본_-_모듈_상세/4.png&quot; alt=&quot;4&quot; /&gt;&lt;/p&gt;

&lt;p&gt;한 번 더 실행시, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SUCCESS&lt;/code&gt; 라고 뜨지만 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&quot;changed&quot;&lt;/code&gt; 는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;false&lt;/code&gt; 이다.&lt;br /&gt;
즉 실행은 되었지만, 결론적으로 복사는 되지 않은것이다.&lt;br /&gt;
동일한 파일이 이미 존재하기 때문이다.&lt;br /&gt;
만약에 파일 내용을 바꾸고 명령을 실행하면, 파일이 달라졌기 때문에 복사가 된다 !&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;즉 파일의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&quot;checksum&quot;&lt;/code&gt; 으로 파일명 뿐만 아니라 내용까지도 감안해서 복사를 진행한다.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;rm &lt;/span&gt;hello.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;다음 실습을 위해 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;control1&lt;/code&gt; 노드에서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hello.txt&lt;/code&gt; 를 지운다.&lt;/p&gt;

&lt;h1 id=&quot;4-fetch&quot;&gt;4. fetch&lt;/h1&gt;
&lt;hr /&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible mgmt &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; fetch &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;src=/tmp/hello.txt dest=./&apos;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;ls
ls &lt;/span&gt;node1/tmp/hello.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-03-[Ansible]-3.4.2_Ansible_기본_-_모듈_상세/5.png&quot; alt=&quot;5&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fetch&lt;/code&gt; 는 가져옴을 뜻한다.&lt;br /&gt;
이 때 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;src&lt;/code&gt; 는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mgmt&lt;/code&gt; 가, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dest&lt;/code&gt; 는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;control1&lt;/code&gt; 이 될 것이다.&lt;br /&gt;
결과, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;control1&lt;/code&gt; 에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;node1&lt;/code&gt; 이란 폴더가 생기게 되고, 여기 안에 디렉토리가 생기면서 파일을 가져오게 된다.&lt;br /&gt;
왜 이런식으로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fetch&lt;/code&gt; 가 이루어질까 ? &lt;br /&gt;
만약 우리가 대상 노드를 여러개를 지정한 경우, 즉 그룹을 대상으로 지정한 경우, 겹치게 되므로 노드마다 디렉토리를 만든 다음 그 안에 파일을 가져오게 된다.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rf&lt;/span&gt; node1/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;다음 실습을 위해 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;control1&lt;/code&gt; 노드에서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;node1&lt;/code&gt; 을 지운다.&lt;/p&gt;

&lt;h1 id=&quot;5-file&quot;&gt;5. file&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;주로 파일을 생성하고, 속성을 변경할 때 사용한다.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;path (필수)&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;file&lt;/code&gt; 모듈의 필수 아규먼트는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;path&lt;/code&gt; 이다.&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;path&lt;/code&gt; 라는 이름 대신에, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dest&lt;/code&gt; , &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;name&lt;/code&gt; 으로 적어도 된다.&lt;br /&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;stat&lt;br /&gt;
또 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;stat&lt;/code&gt; 이라는 인자가 있다.&lt;br /&gt;
다음의 옵션 중에 하나를 선택해서 사용한다.&lt;/p&gt;
    &lt;ul&gt;
      &lt;li&gt;absent&lt;/li&gt;
      &lt;li&gt;directory&lt;/li&gt;
      &lt;li&gt;file (default)&lt;/li&gt;
      &lt;li&gt;hard&lt;/li&gt;
      &lt;li&gt;link&lt;/li&gt;
      &lt;li&gt;touch&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;node1&lt;/code&gt; 에 있는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hello.txt&lt;/code&gt; 를 대상으로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;file&lt;/code&gt; 모듈을 사용해보자.&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;생성-및-변경&quot;&gt;생성 및 변경&lt;/h2&gt;
&lt;hr /&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible mgmt &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; file &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;path=/tmp/hello.txt&apos;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-03-[Ansible]-3.4.2_Ansible_기본_-_모듈_상세/14.png&quot; alt=&quot;14&quot; /&gt;&lt;/p&gt;

&lt;p&gt;여기서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;state&lt;/code&gt; 에 주목해보자.&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hello.txt&lt;/code&gt; 는 파일이기 때문에, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;file&lt;/code&gt; 이라고 표시된다.&lt;br /&gt;
대상이 디렉토리일 경우, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;directory&lt;/code&gt; 가 나온다.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible mgmt &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; file &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;path=/tmp state=file&apos;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-03-[Ansible]-3.4.2_Ansible_기본_-_모듈_상세/15.png&quot; alt=&quot;15&quot; /&gt;&lt;/p&gt;

&lt;p&gt;디렉토리를 대상으로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;state&lt;/code&gt; 를 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;file&lt;/code&gt; 로 지정했기 때문에, fail이 나게 된다.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible mgmt &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; file &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;path=/tmp/hello1.txt state=touch&apos;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-03-[Ansible]-3.4.2_Ansible_기본_-_모듈_상세/16.png&quot; alt=&quot;16&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;state&lt;/code&gt; 를 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;touch&lt;/code&gt; 로 지정해주면, 대상 빈 파일을 만든다.&lt;br /&gt;
상태가 바뀌었기 때문에, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CHANGED&lt;/code&gt; 가 나온다.&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;touch&lt;/code&gt; 가 아닌 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;directory&lt;/code&gt; 를 지정하면, 디렉토리를 생성한다.&lt;br /&gt;&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible mgmt &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; file &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;path=/tmp/test state=directory mode=700 owner=root&apos;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-b&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-03-[Ansible]-3.4.2_Ansible_기본_-_모듈_상세/17.png&quot; alt=&quot;17&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;state&lt;/code&gt; = &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;directory&lt;/code&gt; 를 지정했기 때문에 디렉토리가 생성된다.&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mode&lt;/code&gt; = &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;700&lt;/code&gt; 으로 권한 변경도 가능하다.&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;owner&lt;/code&gt; = &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;root&lt;/code&gt; 로 소유자도 변경 가능하다. 단, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;root&lt;/code&gt; 로 변경할 때에는 관리자 권한이 필요하므로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-b&lt;/code&gt; 를 붙이지 않으면 오류가 발생한다.&lt;/p&gt;

&lt;h2 id=&quot;삭제&quot;&gt;삭제&lt;/h2&gt;
&lt;hr /&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible mgmt &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; file &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;path=/tmp/test state=absent&apos;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-b&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-03-[Ansible]-3.4.2_Ansible_기본_-_모듈_상세/18.png&quot; alt=&quot;18&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;state&lt;/code&gt; 를 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;absent&lt;/code&gt; 로 지정하면, 대상이 삭제된다.&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;absent&lt;/code&gt; 는 존재하지 않음을 뜻한다.&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;동일한 명령문을 다시 실행하면, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SUCCESS&lt;/code&gt; 가 뜬다.&lt;br /&gt;
변경사항이 없고, 대상이 존재하지 않음은 참이기 때문이다.&lt;/p&gt;

&lt;p&gt;위에서 생성했던 파일도 삭제해주자.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible mgmt &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; file &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;path=/tmp/hello.txt state=absent&apos;&lt;/span&gt;
ansible mgmt &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; file &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;path=/tmp/hello1.txt state=absent&apos;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;6-apt&quot;&gt;6. apt&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;패키지를 설치할 때 사용하는 모듈이다.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;state&lt;br /&gt;
다음의 옵션에서 한 가지를 지정 가능하다.
    &lt;ul&gt;
      &lt;li&gt;absent (삭제)&lt;/li&gt;
      &lt;li&gt;build-dep&lt;/li&gt;
      &lt;li&gt;latest (설치)&lt;/li&gt;
      &lt;li&gt;present (설치, default)&lt;/li&gt;
      &lt;li&gt;fixed&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;apt&lt;/code&gt; 모듈을 사용하여 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;node1&lt;/code&gt; 에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;apache2&lt;/code&gt; 를 설치해보자.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible mgmt &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; apt &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;name=apache2 state=present&apos;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-b&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-03-[Ansible]-3.4.2_Ansible_기본_-_모듈_상세/19.png&quot; alt=&quot;19&quot; /&gt;&lt;/p&gt;

&lt;p&gt;성공적으로 설치되었다.&lt;br /&gt;
한 번 더 실행하면, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;file&lt;/code&gt; 과 마찬가지로 이미 존재하며 변경사항이 없기 때문에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SUCCESS&lt;/code&gt; 가 출력된다.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible mgmt &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; apt &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;name=apache2 state=absent&apos;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-b&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-03-[Ansible]-3.4.2_Ansible_기본_-_모듈_상세/20.png&quot; alt=&quot;20&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;absent&lt;/code&gt; 를 지정하여 삭제.&lt;/p&gt;

&lt;h1 id=&quot;7-service&quot;&gt;7. service&lt;/h1&gt;
&lt;hr /&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;name (필수)&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;state&lt;br /&gt;
아래 항목 중 하나 선택
    &lt;ul&gt;
      &lt;li&gt;reloaded&lt;/li&gt;
      &lt;li&gt;restarted&lt;/li&gt;
      &lt;li&gt;started&lt;/li&gt;
      &lt;li&gt;stopped&lt;/li&gt;
      &lt;li&gt;(null) (default)&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;enabled&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible mgmt &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; apt &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;name=apache2 state=present&apos;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-b&lt;/span&gt;
ansible mgmt &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; service &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;name=apache2 enabled=false&apos;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-b&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-03-[Ansible]-3.4.2_Ansible_기본_-_모듈_상세/21.png&quot; alt=&quot;21&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;apt&lt;/code&gt; 로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;apache2&lt;/code&gt; 를 다시 설치하고, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;service&lt;/code&gt; 모듈을 사용해보자.&lt;br /&gt;
기본적으로 관리자 권한이 필요하다.&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;enabled&lt;/code&gt; 를 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;false&lt;/code&gt; 로 지정하면, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;apache2&lt;/code&gt; 를 사용할 수 없게 된다.&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-03-[Ansible]-3.4.2_Ansible_기본_-_모듈_상세/22.png&quot; alt=&quot;22&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;disabled&lt;/code&gt; 를 확인할 수 있다.&lt;br /&gt;
다시 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;enabled&lt;/code&gt; 를 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;true&lt;/code&gt; 로 바꿔보자.&lt;br /&gt;&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible mgmt &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; service &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;name=apache2 enabled=true state=started&apos;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-b&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-03-[Ansible]-3.4.2_Ansible_기본_-_모듈_상세/23.png&quot; alt=&quot;23&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;state&lt;/code&gt; 는 이미 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;started&lt;/code&gt; 이기 때문에, 이것만 실행하면 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SCCUESS&lt;/code&gt; 가 출력되었을 것이고, 이번에는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;enabled&lt;/code&gt; 를 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;true&lt;/code&gt; 바꾸었기 때문에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CHANGED&lt;/code&gt; 가 출력되었다.&lt;/p&gt;

&lt;h1 id=&quot;8-replace&quot;&gt;8. replace&lt;/h1&gt;
&lt;hr /&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;path (필수)&lt;br /&gt;
수정할 경로를 나타낸다.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;regexp (필수)&lt;br /&gt;
바꿀 텍스트를 정규화 표현식으로 나타낼 수 있다.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;replace&lt;br /&gt;
어떤 텍스트로 변경할지 지정한다.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;hello&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; hello.txt
ansible mgmt &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; copy &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;src=hello.txt dest=/tmp/hello.txt&apos;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hello.txt&lt;/code&gt; 파일을 만들고, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;node1&lt;/code&gt; 에 복사한다.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ansible mgmt &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; replace &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;path=/tmp/hello.txt regexp=&quot;hello&quot; replace=&quot;hello world&quot;&apos;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/img/study_Ansible/2022-12-03-[Ansible]-3.4.2_Ansible_기본_-_모듈_상세/24.png&quot; alt=&quot;24&quot; /&gt;&lt;/p&gt;

&lt;p&gt;이런식으로 파일의 내용을 수정할 수 있다.&lt;/p&gt;
</description>
        <pubDate>Sat, 03 Dec 2022 04:00:00 +0900</pubDate>
        <link>https://hjy.today/study/Ansible-3.4.2_Ansible_%EA%B8%B0%EB%B3%B8_-_%EB%AA%A8%EB%93%88_%EC%83%81%EC%84%B8.html</link>
        <guid isPermaLink="true">https://hjy.today/study/Ansible-3.4.2_Ansible_%EA%B8%B0%EB%B3%B8_-_%EB%AA%A8%EB%93%88_%EC%83%81%EC%84%B8.html</guid>
        
        <category>ansible</category>
        
        
        <category>study</category>
        
      </item>
    
  </channel>
</rss>
