# Codepipeline

이제 [AWS CloudFormation](https://aws.amazon.com/cloudformation/)을 사용하여 AWS CodePipeline을 생성하겠습니다. 이 파이프라인은 GitHub Source repo(eks-example)에서 도커 이미지를 구축하는 데 사용됩니다. 이렇게 해도 이미지가 배포되지 않으며 Weave Flux 에서 이를 처리합니다.

CloudFormation은 클라우드 환경의 모든 인프라 리소스를 설명하고 프로비저닝할 수 있는 공통 언어를 제공하는 IaC([infrastructure as code](https://en.wikipedia.org/wiki/Infrastructure_as_Code)) 툴입니다. CloudFormation을 사용하면 간단한 텍스트 파일을 사용하여 모든 region과 account에 걸쳐 애플리케이션에 필요한 모든 리소스를 자동화되고 안전하게 모델링하고 프로비저닝할 수 있습니다.

각 EKS 배포/서비스는 자체 CodePipeline이 있어야 하며 분리된 소스 저장소에 있어야 합니다.&#x20;

아래 파일을 클릭하여 다운 로드 후 AWS Management Console에 CloudFormation 스택을 생성합니다.&#x20;

{% file src="<https://1998608250-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MhByD5wv8eUbA5ZbUY5%2Fuploads%2F2g7yJosDxpV4U1BOghx2%2Fweave_flux_pipeline.cfn.yml?alt=media&token=3f3a09f2-522c-44cd-a2c5-22ef9bea3993>" %}

* 스택 이름 : image-codepipeline
* Username : git username
* Access token : git access key
* Repository : eks-example
* Branch : main

![](https://1998608250-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MhByD5wv8eUbA5ZbUY5%2Fuploads%2F3N0Trr6aOWl3MNgHmPdU%2Fimage.png?alt=media\&token=16795658-4722-4699-a7c4-1c9b47b7b94d)

Stack이 완료(**CREATE\_COMPLETE)**&#xB420;때 까지 기다립니다.&#x20;

[CodePipeline in the Management Console](https://console.aws.amazon.com/codesuite/codepipeline/pipelines) 에 접속하여 **image-codepipeline** 으로 codepipeline이 시작된 것을 볼 수 있습니다. 현재 저장소에 코드가 없기 때문에 이미지 빌드에 실패가 됩니다.&#x20;

GitHub repo에 샘플 애플리케이션을 추가할 것입니다. 아래 ${YOURUSER}를 GitHub 사용자 이름을 대체합니다.

```
git clone git@github.com:${YOURUSER}/eks-example.git
cd eks-example
```

그런 다음 기본 README 파일, 원본 디렉터리를 만들고 샘플 nginx 구성(hello.conf), 홈 페이지(index.html) 및 도커 파일을 다운로드합니다.

```
echo "# eks-example" > README.md
mkdir src
wget -O src/hello.conf https://raw.githubusercontent.com/aws-samples/eks-workshop/main/content/intermediate/260_weave_flux/app.files/hello.conf
wget -O src/index.html https://raw.githubusercontent.com/aws-samples/eks-workshop/main/content/intermediate/260_weave_flux/app.files/index.html
wget https://raw.githubusercontent.com/aws-samples/eks-workshop/main/content/intermediate/260_weave_flux/app.files/Dockerfile

```

이제 간단한 hello world app를 commit하여 codepipeline 을 시작시킵니다.

```
git add .
git commit -am "Initial commit"
git push 

```

![](https://1998608250-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MhByD5wv8eUbA5ZbUY5%2Fuploads%2FAKz2zGHuorxh93f6r7Ty%2Fimage.png?alt=media\&token=240bd11c-1453-40a7-9c28-f07ae31398cc)

빌드 이미지를 확인하여 위하여 [Amazon ECR console](https://console.aws.amazon.com/ecr/repositories) 접속하여 **eks-example** image repository를 확인합니다.

![](https://1998608250-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MhByD5wv8eUbA5ZbUY5%2Fuploads%2F1QEPAvGQQvC3RCp9N9s6%2Fimage.png?alt=media\&token=7940e08f-b6cb-4117-a82b-ae91ac5411fc)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wjlee81.gitbook.io/amazon-eks/updating-cd-gitops-with-flux/codepipeline.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
