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
git add .
git commit -m "asdfsadf"
git push
1.2.2 s3 upload
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)
relative_path = os.path.relpath(file_path, local_directory)
object_key = relative_path
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 운영 관리 문서