공부하기싫어
article thumbnail
Published 2023. 8. 10. 04:37
AWS CodeBuild - push to Github AWS/CI CD

1. 목차

     

    1.1. 테스트 목적

    • codebuild 의 buildspec.yml 을 사용해 public github repository 로 manifest file push

     

    1.2. 1. github repository

    public repository

     

    ssh-key 생성 후 공개키는 github 에 등록, 비밀키는 aws-ssm 에 저장해서 불러오는 방식으로 사용

    oauth 나 personal access key 방식으로 source 에 repository 를 등록해서 사용하려고 했으나 no such device or address 에러 발생함

     

    로컬에서 ssh-key 생성

    <bash />
    $ ssh-keygen -t ed25519 -C "my-e-mail" Enter file in which to save the key (/home/cyaninn/.ssh/id_ed25519): #현재 디렉토리 ... $ ls id_ed25519 id_ed25519.pub

    pub key 등록
    secret key 등록

     

     

    1.3. 2. Create CodeBuild Project

     

    이름, 태그 대충 해줌

     

    source - codecommit

     

    enviornment

    나머지는 기본값으로 해주고

    log group 생성해주고 이름 맞춰준다음 생성

     

    인라인 정책 추가

    system-manager-readonly 정책을 연결시켜줌

     

     

    1.4. 3. buildspec.yml

    <bash />
    version: 0.2 env: parameter-store: github_ssh_key: "/ethereum-autotrade/github_ssh_key" phases: pre_build: commands: - mkdir -p ~/.ssh - echo $CODEBUILD_BUILD_NUMBER - echo "$github_ssh_key" > ~/.ssh/id_rsa - chmod 600 ~/.ssh/id_rsa - ssh-keygen -F github.com || ssh-keyscan github.com >>~/.ssh/known_hosts - git config --global user.email "sounddevice3@gmail.com" - git config --global user.name "cyaninn-entj" build: commands: - git clone git@github.com:cyaninn-entj/aws-cicd-test.git - cp app/* aws-cicd-test/ - cd aws-cicd-test - git add . - git commit -m "commit from $CODEBUILD_BUILD_NUMBER" - git push

     

    1.5. 4. codecommit dir

    <bash />
    $ tree . ├── app │   ├── kustomization.yaml │   ├── nn.py │   └── test.txt └── buildspec.yml

    1.6. 5. 확인

    build status
    github repository

     

     

    1.7. 참고

    https://adrianhesketh.com/2018/05/02/go-private-repositories-and-aws-codebuild/

     

    Go, private repositories and AWS CodeBuild

    Go, private repositories and AWS CodeBuild I’ve gotten used to the luxury of CircleCI, but I thought I’d have a go at AWS CodeBuild to bring the build pipeline inside AWS to reduce the attack surface area. AWS Code Pipeline supports triggering builds f

    adrianhesketh.com

    https://kyle79.tistory.com/208

     

    AWS CodeBuild 를 통한 브랜치 자동화 업댓

    version: 0.2 #env: #variables: # key: "value" # key: "value" #parameter-store: # key: "value" # key: "value" #secrets-manager: # key: secret-id:json-key:version-stage:version-id # key: secret-id:json-key:version-stage:version-id #exported-variables: # - va

    kyle79.tistory.com

     

    'AWS > CI CD' 카테고리의 다른 글

    AWS CodeBuild - DOWNLOAD_SOURCE 단계 dial tcp i/o timeout Error  (0) 2024.07.13
    Codebuild + awscli : lambda image update  (0) 2023.08.16
    AWS CodeBuild demo with ECR  (0) 2023.08.10
    AWS CodeCommit demo  (0) 2023.08.09