인프라/aws
-
프로젝트 구조 변경을 CI/CD 파이프라인에 반영하기인프라/aws 2024. 4. 25. 18:06
기존의 싱글 모듈 프로젝트에서 CI/CD를 구축해 두었습니다. 이 프로젝트를 멀티 모듈 형태로 변경하면서 기존 프로젝트의 경로가 변경되었습니다. 이 변경된 내용을 Dockerfile과 각종 yml에 반영하는 과정을 메모합니다. 이 글은 아래와 같은 순서로 작성되었습니다.1. 현재 상황2. 파이프라인 스테이지별 수정사항 반영3. 정리하기 1. 현재 상황왼쪽의 이미지는 현재 구성되어있는 파이프라인의 모습이고 오른쪽은 프로젝트의 폴더 구조입니다.이전에 root 경로에 있던 quiz_service의 파일들이 ./quiz_service로 이동된 모습입니다. 2. 파이프라인 스테이지별 수정사항 반영1. Source Stage우선 깃 브랜치 전략부터 변경이 필요했습니다. 기존에 main quiz_service..
-
보조 계정으로 ECR에서 Push / Pull 하기인프라/aws 2024. 4. 10. 00:27
ECR에 권한을 부여하는 페이지가 2종류가 있습니다. 다음 번에는 여기서 헤매지 않기 위해 글로 남깁니다. 글을 진행하기에 앞서서, ECR repository를 가지고 있는 계정을 main 계정이라고 부르고, push/pull을 하려는 계정을 sub 계정이라고 정리하고 시작하겠습니다. 아래의 글은 다음의 순서로 진행됩니다. 1. Push를 하려는 서비스에서 사용하는 권한 확인하기 2. Repository를 가지고 있는 계정에서 권한을 부여하기 3. Push를 하는 측 권한 수정하기 4. 확인하기 1. Push를 하려는 서비스에서 사용하는 권한 확인하기 sub계정의 CodePipeline에서 CodeBuild stage가 ECR에 접근해야하는 상황입니다. 따라서 현재 CodeBuild에 적용되어있는 Rol..
-
내가 보려고 만든 CodePipeline 구축 A to Z인프라/aws 2024. 3. 23. 22:21
1. 사전 설정하기 EC2 관련 사전 설정하기 (링크의 2. EC2 세팅하기 참고) 2. CodePipeline 생성하기 CodeBuild를 먼저 생성하지 않고 CodePipeline에서 생성하는 것이 포인트입니다. 2-1. 파이프라인 생성하기 적당한 이름으로 파이프라인을 만들어줍니다. 2-2. 소스 stage 생성하기 version2를 선택해서 원하는 레포의 브랜치와 연결해줍니다. 2-3. 빌드 stage 생성하기 만들어준 CodeBuild를 연결하지 않고 새로운 Build를 생성합니다. Create project를 누르면 Code Build 탭에서 만드는 것과 동일한 프로세스를 진행합니다. 차이점은 소스코드를 어디서 받는지 별도로 선택하지 않는다는 점입니다. ECR을 사용하기 때문에 privileg..
-
[CodePipeline]Unable to access the artifact with Amazon S3 object key인프라/aws 2024. 3. 19. 04:11
Code Pipeline으로 CI/CD 구축하던 중 Deploy stage에서 발생한 에러입니다. 이 에러를 이해하려면 기본적으로 Code pipeline의 각 stage 간에 결과물을 s3를 사용해서 공유한다는 것을 기억해야합니다. [에러 해결을 위한 체크 리스트] 1. Build stage에서 s3에 artifacts를 남기고 있는가? 2. EC2에서 해당 버킷에 접근할 수 있는 권한을 가지고 있는가? 3. Code Deploy에서 소스코드를 받을 수 있는가? ( Code Deploy에서 소스코드를 사용해야한다면 ) 저 같은 경우에는 CodeBuild에서 ECR로 push 를 하는 상황이라 빌드의 결과물이 없기 때문에 s3에 artifacts를 업로드 하지않은 것이 이 에러 발생의 원인이었습니다. 문..
-
CodePipeline으로 CI/CD 구축하기인프라/aws 2024. 3. 19. 03:22
프로젝트를 진행하면서 게시글 서비스를 github action과 docker hub를 사용해서 ci/cd를 구축해서 사용하고 있었습니다. 이번에 유저 서비스를 새로 만들면서 인프라 툴을 여러 곳에 분산해서 사용하는 것보다 한 곳으로 모으는 것에 이점이 있을 것 같아서 이미지 관리와 CI/CD 방법을 변경하면서 작성하는 글입니다. 여러 차례 막히는 구간이 생겨서 하루 종일 고생하다가 정리해두는 것이 좋을 것 같아 오랜만에 글로 남깁니다. [관련 포스팅] 1. Elastic Container Registry (ECR) 로 도커 이미지 관리하기 2. CodeBuild로 ECR 갱신하기 3. CodeDeploy로 EC2에 배포하기 4. CodePipeline으로 CI/CD 구축하기 글은 크게 5가지 항목으로 진..
-
CodeDepoly로 EC2에 배포하기인프라/aws 2024. 3. 18. 13:52
프로젝트를 진행하면서 게시글 서비스를 github action과 docker hub를 사용해서 ci/cd를 구축해서 사용하고 있었습니다. 이번에 유저 서비스를 새로 만들면서 인프라 툴을 여러 곳에 분산해서 사용하는 것보다 한 곳으로 모으는 것에 이점이 있을 것 같아서 이미지 관리와 CI/CD 방법을 변경하면서 작성하는 글입니다. 여러 차례 막히는 구간이 생겨서 하루 종일 고생하다가 정리해두는 것이 좋을 것 같아 오랜만에 글로 남깁니다. [관련 포스팅] 1. Elastic Container Registry (ECR) 로 도커 이미지 관리하기 2. CodeBuild로 ECR 갱신하기 3. CodeDeploy로 EC2에 배포하기 4. CodePipeline으로 CI/CD 구축하기 글은 크게 5가지 항목으로 진..
-
CodeBuild로 ECR 갱신하기인프라/aws 2024. 3. 18. 13:38
프로젝트를 진행하면서 게시글 서비스를 github action과 docker hub를 사용해서 ci/cd를 구축해서 사용하고 있었습니다. 이번에 유저 서비스를 새로 만들면서 인프라 툴을 여러 곳에 분산해서 사용하는 것보다 한 곳으로 모으는 것에 이점이 있을 것 같아서 이미지 관리와 CI/CD 방법을 변경하면서 작성하는 글입니다. 여러 차례 막히는 구간이 생겨서 하루 종일 고생하다가 정리해두는 것이 좋을 것 같아 오랜만에 글로 남깁니다. [관련 포스팅] 1. Elastic Container Registry (ECR) 로 도커 이미지 관리하기 2. CodeBuild로 ECR 갱신하기 3. CodeDeploy로 EC2에 배포하기 4. CodePipeline으로 CI/CD 구축하기 글은 크게 5가지 항목으로 진..
-
[CodeDeploy] appspec.yml의 destination 설정인프라/aws 2024. 3. 17. 18:07
Code Deploy 사용 중에 만난 이슈 사항입니다. 나중에도 참고할 일이 생길 수 있을 것 같아 남겨봅니다. 문제의 appspec.yml 입니다. ec2 터미널에서 cd ~/ 를 할 경우 유저의 홈으로 이동하기에 destination을 ~/ 으로 설정하였습니다. 원하는 건 홈에 빌드에 필요한 파일들이 설치되는 것이 었습니다. version: 0.0 os: linux files: - source: / destination: ~/ hooks: ApplicationStop: - location: deploy_scripts/new_script.sh timeout: 300 runas: root Code Deploy 배포가 실패해서 로그를 찾아봤습니다. (/var/log/aws/codedeploy-agent/c..