[Question #14] AWS Certified Solutions Architect - Professional SAP-C02 Actual Exam Questions



A company is running an application on several Amazon EC2 instances in an Auto Scaling group behind an Application Load Balancer. The load on the application varies throughout the day, and EC2 instances are scaled in and out on a regular basis. Log files from the EC2 instances are copied to a central Amazon S3 bucket every 15 minutes. The security team discovers that log files are missing from some of the terminated EC2 instances.
Which set of actions will ensure that log files are copied to the central S3 bucket from the terminated EC2 instances?

  • A. Create a script to copy log files to Amazon S3, and store the script in a file on the EC2 instance. Create an Auto Scaling lifecycle hook and an Amazon EventBridge rule to detect lifecycle events from the Auto Scaling group. Invoke an AWS Lambda function on the autoscaling:EC2_INSTANCE_TERMINATING transition to send ABANDON to the Auto Scaling group to prevent termination, run the script to copy the log files, and terminate the instance using the AWS SDK.
  • B. Create an AWS Systems Manager document with a script to copy log files to Amazon S3. Create an Auto Scaling lifecycle hook and an Amazon EventBridge rule to detect lifecycle events from the Auto Scaling group. Invoke an AWS Lambda function on the autoscaling:EC2_INSTANCE_TERMINATING transition to call the AWS Systems Manager API SendCommand operation to run the document to copy the log files and send CONTINUE to the Auto Scaling group to terminate the instance.
  • C. Change the log delivery rate to every 5 minutes. Create a script to copy log files to Amazon S3, and add the script to EC2 instance user data. Create an Amazon EventBridge rule to detect EC2 instance termination. Invoke an AWS Lambda function from the EventBridge rule that uses the AWS CLI to run the user-data script to copy the log files and terminate the instance.
  • D. Create an AWS Systems Manager document with a script to copy log files to Amazon S3. Create an Auto Scaling lifecycle hook that publishes a message to an Amazon Simple Notification Service (Amazon SNS) topic. From the SNS notification, call the AWS Systems Manager API SendCommand operation to run the document to copy the log files and send ABANDON to the Auto Scaling group to terminate the instance.




---------------------------------------------




한 회사가 애플리케이션 로드 밸런서(ALB) 뒤에 있는 자동 확장 그룹의 여러 Amazon EC2 인스턴스에서 애플리케이션을 실행하고 있습니다. 애플리케이션의 부하는 하루 종일 변동하며, EC2 인스턴스는 정기적으로 확장 및 축소됩니다. EC2 인스턴스의 로그 파일은 15분마다 중앙 Amazon S3 버킷에 복사됩니다. 보안팀은 종료된 일부 EC2 인스턴스에서 로그 파일이 누락된 것을 발견했습니다.
종료된 EC2 인스턴스에서 로그 파일이 중앙 S3 버킷으로 복사되도록 하려면 어떤 조치를 취해야 할까요?

  • A. 로그 파일을 Amazon S3에 복사하는 스크립트를 생성하고, 이 스크립트를 EC2 인스턴스의 파일에 저장합니다. Auto Scaling 수명 주기 후크와 Amazon EventBridge 규칙을 생성하여 Auto Scaling 그룹의 수명 주기 이벤트를 감지합니다. autoscaling:EC2_INSTANCE_TERMINATING 전환 시 AWS Lambda 함수를 호출하여 Auto Scaling 그룹에 ABANDON을 전송하여 종료를 방지하고, 스크립트를 실행하여 로그 파일을 복사한 후 AWS SDK를 사용하여 인스턴스를 종료합니다.
  • B. 로그 파일을 Amazon S3에 복사하는 스크립트가 포함된 AWS Systems Manager 문서를 생성합니다. Auto Scaling 수명 주기 후크와 Amazon EventBridge 규칙을 생성하여 Auto Scaling 그룹의 수명 주기 이벤트를 감지합니다. autoscaling:EC2_INSTANCE_TERMINATING 전환 시 AWS Lambda 함수를 호출하여 AWS Systems Manager API SendCommand 작업을 실행하고, 로그 파일을 복사하는 문서를 실행한 후 Auto Scaling 그룹에 CONTINUE 명령을 전송하여 인스턴스를 종료합니다.
  • C. 로그 전송 속도를 5분 간격으로 변경합니다. 로그 파일을 Amazon S3에 복사하는 스크립트를 생성하고, 해당 스크립트를 EC2 인스턴스 사용자 데이터에 추가합니다. EC2 인스턴스 종료를 감지하는 Amazon EventBridge 규칙을 생성합니다. EventBridge 규칙에서 AWS CLI를 사용하여 사용자 데이터 스크립트를 실행하고 로그 파일을 복사하고 인스턴스를 종료하는 AWS Lambda 함수를 호출합니다.
  • D. 로그 파일을 Amazon S3에 복사하는 스크립트가 포함된 AWS Systems Manager 문서를 생성합니다. Amazon Simple Notification Service(Amazon SNS) 주제에 메시지를 게시하는 Auto Scaling 수명 주기 후크를 생성합니다. SNS 알림에서 AWS Systems Manager API SendCommand 작업을 호출하여 로그 파일을 복사하는 문서를 실행하고, Auto Scaling 그룹에 ABANDON을 전송하여 인스턴스를 종료합니다.






Correct Answer: B




로그 파일을 Amazon S3에 복사하는 스크립트가 포함된 AWS Systems Manager 문서를 생성합니다. Auto Scaling 수명 주기 후크와 Amazon EventBridge 규칙을 생성하여 Auto Scaling 그룹의 수명 주기 이벤트를 감지합니다. autoscaling:EC2_INSTANCE_TERMINATING 전환 시 AWS Lambda 함수를 호출하여 AWS Systems Manager API SendCommand 작업을 실행하고, 로그 파일을 복사하는 문서를 실행한 후 Auto Scaling 그룹에 CONTINUE 명령을 전송하여 인스턴스를 종료합니다. 이 방법은 인스턴스가 종료되기 전에 Auto Scaling 수명 주기 후크를 사용하여 로그 파일을 S3에 복사하는 스크립트를 실행하여 종료된 인스턴스에서 모든 로그 파일이 복사되도록 합니다.





https://aws.amazon.com/blogs/infrastructure-and-automation/run-code-before-terminating-an-ec2-auto-scaling-instance/







댓글

이 블로그의 인기 게시물

[8/9] 1184회 로또 당첨번호 추천!!

[AWS] SCP, OU, Policy 사용하기 !!

[AWS] AWS Activate 스타트업 $1,000 지원 성공

[8/2] 1183회 로또 당첨번호 추천!!

[Gemini API] 구글 생성형 AI API 모델별 요금 및 청구 방식!!

[Shopizer E‑commerce] Shopizer란?

📘 ads.txt란 무엇인가? (2025 최신 가이드)

[Vault] 온프레미스 구축 개요!!