본문 바로가기

Tech/AWS

(5)
AWS Window Server 인스턴스 생성 시 초기 route table 상태 AWS EC2(Window server)에서 사용하는 SDK 관련 IP (ec2 생성시 자동 등록되는 route들) 169.254.169.123 : 인스턴스에 대한 시간 설정 관련 169.254.169.249 : ec2launch 버전 기록 (1.3.2000430.0 버전 이후 route 추가하도록 추가됨) 169.254.169.250 : ec2config 관련 169.254.169.251 : ec2config 관련 169.254.169.253 : VPC용 DNS 서버 관련 169.254.169.254 : 인스턴스 메타데이터 검색 관련 인스턴스 생성시, 위처럼 초기화(셋팅)이 되므로, 만약 윈도우 서버로 사용하고 있는 ec2의 AMI를 다른 VPC or Subnet에서 사용하게 된다면, 변경된 subne..
[S3] boto3 SDK 활용 Key 리스트 확인, 오브젝트 Copy, Move 오브젝트를 생성한 후, 동일 버킷(Bucket) 내에서 다른 Key로 오브젝트를 이동해야하는 일이 생겼다. boto3의 s3 관련 함수들 중에는 Move라는 함수가 존재하지 않았다. 그래서, Copy와 remove를 활용하여 Move를 만들었다. 사용한 코드는 아래와 같다 아래 코드를 보기에 앞서, 아래 코드내용 중에 어떤 동작 함수는 boto3.client를 쓰고, 어떤 동작 함수는 boto3.resource를 쓸것이다. client와 resource의 차이는 다음과 같다고 한다. client는 low-level 인터페이스로, AWS API와 1:1 매핑하여 사용할 때, resource는 high-level 인터페이스로, 자원에 대한 조작을 위주로 사용할 떄, 참고 :https://planbs.tist..
[S3] boto3 SDK 활용 버킷 확인, 생성, 업로드 s3 클라이언트 세션 생성 def get_s3_session(access_key, secret_access_key): s3 = boto3.client( 's3', aws_access_key_id = access_key, aws_secret_access_key= secret_access_key ) return s3 버킷 확인 def check_bucket(s3, bucket_name): # # bucket 명 확인 # response = s3.list_buckets() buckets = [bucket['Name'] for bucket in response['Buckets']] print(f"[INFO] bucket name list: {buckets}") if b..
[Athena] AWS SDK boto3 활용 쿼리 엑세스키, 시크릿 엑세스키 발급 boto3를 활용해서 AWS client에 접근하기 위해서는 access key, secret access key가 필요하다. 어떻게 엏는지는 아래 링크를 참고하자 https://assaeunji.github.io/aws/2020-04-02-boto3/ boto3를 활용한 Athena Query import boto3 import time # # https://gist.github.com/chrisdpa-tvx/96ad6099da868bf83579fcb0d8caa00c # https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/athena.html # athena_handler = boto3.c..
[Athena] 아테나를 사용하면서 필요했던 AWS IAM 정책 전체로 부여받은 정책 S3 관련 별개로 요청한 정책 glue:GetPartitions glue:BatchCreatePartition glue:CreateTable glue:GetDatabase glue:GetTable athena:StartQueryExecution