2025. 3. 2. 20:49ㆍ카테고리 없음
AWS 는 생성하는 방법은 비교적 간단해서 사용하기 편하지만, 편의를 제공하는 만큼 사용 요금도 만만치 않습니다. 그래서 비용 문제를 생각하지 않을 수 없습니다. 이 문제를 해결하는 좋은 방법은 필요한 시간에만 사용하고 필요하지않은 시간에는 꺼두는 것이죠. 가끔씩 사용하는 경으로면 수동으로 on/off 를 시키면 되겠지만 매일 필요해서 반복 on/off 시키는 것도 보통 불편한 것이 아닙니다. 이때 사용할 수 있는 방법이 schedule auto on/off 기능입니다.
어려운 방법도 있지만 굳이 쉬운 방법을 어렵게 할 필요없겠죠.
기능을 제공하는 페이지를 먼저 소개해드리면
https://docs.aws.amazon.com/systems-manager/latest/userguide/quick-setup-scheduler.html
Stop and start EC2 instances automatically on a schedule using Quick Setup - AWS Systems Manager
If you already have one or more configurations in your account, first choose the Library tab or the Create button in the Configurations section to view the cards.
docs.aws.amazon.com
이 페이지 안내대로 그대로 적용하면 되는데, 중요한점 하나만 강조하면 tag 기능입니다.
ec2 instance를 만든때 설정화면 마지막 부분에 다중의 yag 항목을 설정하는 부분이 있습니다.
자동 on/off 설정에 이부분이 중요하게 동작합니다.
tag name과 value 값을 선택할때 내가 원하는 instance 를 필터링할 수 있습니다.
아래 설명 6번에 해당합니다.
1. Open the AWS Systems Manager console at https://console.aws.amazon.com/systems-manager/.
2. In the navigation pane, choose Quick Setup.
3. On the Resource Scheduler card, choose Create.
Tip
If you already have one or more configurations in your account, first choose the Library tab or the Create button in the Configurations section to view the cards.
4. In the Instance tag section, specify the tag key and value applied to the instances you want to associate with your schedule.
5. In the Schedule options section, specify the time zone, days, and times you want to start and stop your instances.
6. In the Targets section, choose whether to set scheduling for a Custom group of organizational units (OUs), or the Current account you're signed in to:
Custom – In the Target OUs section, select the OUs where you want to set up scheduling. Next, in the Target Regions section, select the Regions where you want to set up scheduling.
Current account – Select Current Region or Choose Regions. If you selected Choose Regions, choose the Target Regions where you want to set up scheduling.
7. Verify the schedule information in the Summary section.
8. Choose Create.
이 기능이 설정되고 나면 바로 동작확인도 가능합니다.
또한 일주일 단위로 어느 요일에 동작하게 할지도 설정이 가능합니다.
찾아보면 Lambda 이용하는 방법도 있는데 너무 복잡하고 어렵더라구요. 그래서 간단하게 사용할 수 있는 벙법을 다뤄 봤습니다.
도움이 됐으면 좋겠습닏다.