[Portfolio_Website:V.1] 운영 가이드

simon_entj·2025년 1월 27일

Portfolio_Website:V.1

목록 보기
3/3

1. 패치 작업 절차

1.1 git clone

  • Codecommit에 보관되어있는 코드를 클론 후 작업한다.
git clone https://git-codecommit.ap-northeast-2.amazonaws.com/v1/repos/[my-codecommit-repository]

1.2 git push & s3 upload

1.2.1 git push

# patch_commands.sh
git add .
git commit -m "asdfsadf" # check commit messages
git push

1.2.2 s3 upload

# upload_file_to_s3bucket.py
import boto3
import datetime
import os

def upload_file_to_s3(file_path, bucket_name, object_key):
    session = boto3.Session(profile_name='default')
    s3 = session.client('s3')
    
    with open(file_path, 'rb') as file:
        s3.upload_fileobj(file, bucket_name, object_key)

def upload_directory_to_s3(local_directory, bucket_name):
    for root, dirs, files in os.walk(local_directory):
        for file in files:
            file_path = os.path.join(root, file)
            # Remove the local directory part from the path to get the object key
            relative_path = os.path.relpath(file_path, local_directory)
            object_key = relative_path  # Just use the relative path without 'html'
            upload_file_to_s3(file_path, bucket_name, object_key)

bucket_name = "[my-bucket-name]"
local_directory = 'html'

now = datetime.datetime.now()
try:
    upload_directory_to_s3(local_directory, bucket_name)
    print("Success pushing files to S3 : " + str(now))
except Exception as e:
    print("Exception : " + str(e))

1.3 캐시 무효화

  • TTL 반영을 기다리지 않고 바로 업로드된 결과를 확인하려면 캐시 무효화를 aws-cli를 통해 실행할 수 있다.
aws cloudfront create-invalidation --distribution-id <배포-ID> --paths "/index.html"

2. 패치 노트

  • 패치 기록은 아래 테이블에 수기로 작성하여 관리한다.
  • 노션 프로젝트 작업 문서 : [Ops] v.1 운영 관리 문서
profile
cyan-inn.im

0개의 댓글