Multi-account ๊ตฌ์กฐ์—์„œ AWS ๋ฆฌ์†Œ์Šค(EC2, RDS) ์ž๋™ ์‹œ์ž‘-์ค‘์ง€ ์Šค์ผ€์ค„๋Ÿฌ ๊ตฌ์„ฑํ•˜๊ธฐ : Instance Scheduler on AWS

2023. 8. 27. 22:07ใ†AWS

EventBridge ๋˜๋Š” Lambda ํ•จ์ˆ˜ ๊ตฌ์„ฑ์„ ํ†ตํ•ด ์Šค์ผ€์ค„๋Ÿฌ๋ฅผ ๊ตฌ์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ• ์™ธ์— AWS์—์„œ ์ œ๊ณตํ•˜๋Š” ๋‘ ๊ฐ€์ง€ ์†”๋ฃจ์…˜์ด ์žˆ๋‹ค.

  1. AWS System Manager > Quick Setup > Resource Scheduler
  2. Instance Scheduler on AWS

 

0. ์Šค์ผ€์ค„๋Ÿฌ ์†”๋ฃจ์…˜ ์ข…๋ฅ˜

โ‘  Resource Scheduler

AWS Systems Manager > Quick Setup๋ฅผ ์ด์šฉํ•˜์—ฌ EC2 ์ธ์Šคํ„ด์Šค๋ฅผ ์ž๋™์œผ๋กœ ์‹œ์ž‘ํ•˜๊ณ  ์ค‘์ง€ํ•˜๋Š” Resource Scheduler๋ฅผ ๊ตฌ์„ฑํ•  ์ˆ˜ ์žˆ๋‹ค.

  • ๋Œ€์ƒ : only EC2 ์ธ์Šคํ„ด์Šค
  • ํšจ๊ณผ : EC2 ์‚ฌ์šฉ ์‹œ๊ฐ„ ๊ฐ์†Œ๋กœ ์ธํ•œ EC2 ์‚ฌ์šฉ ์š”๊ธˆ ๊ฐ์†Œ
  • ์‚ฌ์šฉ ๋ฐฉ๋ฒ•
    • ์ •์˜ํ•œ ์ผ์ •์— ๋”ฐ๋ผ ์—ฌ๋Ÿฌ AWS region ๋ฐ ๊ณ„์ •์—์„œ EC2๋ฅผ ์ž๋™์œผ๋กœ ์ค‘์ง€ ๋ฐ ์‹œ์ž‘ ๊ฐ€๋Šฅ.
    • Quick Setup ๊ตฌ์„ฑ์€ ์‚ฌ์šฉ์ž๊ฐ€ ์ง€์ •ํ•œ ํƒœ๊ทธ์˜ ํ‚ค-๊ฐ’์„ ์‚ฌ์šฉํ•˜์—ฌ ์Šค์ผ€์ค„๋Ÿฌ ์„ค์ •.
  • ๋น„์šฉ : Quick Setup ์„ค์ •์œผ๋กœ ์ธํ•œ Resource Scheduler ๊ตฌ์„ฑ ๋น„์šฉ์€ ๋ฐœ์ƒํ•˜์ง€ ์•Š๋Š”๋‹ค.

โ‘ก Instance Scheduler on AWS

๊ทธ๋ฆผ Ref: Instance Scheduler on AWS

์œ„ ์†”๋ฃจ์…˜์„ AWS CloudFormation ํ…œํ”Œ๋ฆฟ์„ ์ด์šฉํ•˜์—ฌ ๋ฐฐํฌํ•  ์ˆ˜ ์žˆ๋‹ค.

  • ๋Œ€์ƒ : EC2, RDS ์ธ์Šคํ„ด์Šค
  • ํšจ๊ณผ : EC2 , RDS ์‚ฌ์šฉ ์‹œ๊ฐ„ ๊ฐ์†Œ๋กœ ์ธํ•œ ๋ฆฌ์†Œ์Šค ๋น„์šฉ ๊ฐ์†Œ
  • ์‚ฌ์šฉ ๋ฐฉ๋ฒ•
    • ์ •์˜ํ•œ ๊ฐ„๊ฒฉ์œผ๋กœ CloudWatch ์ด๋ฒคํŠธ๋ฅผ ์„ค์ •ํ•˜์—ฌ ์ •๊ธฐ์ ์œผ๋กœ Lambda ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•œ๋‹ค.
    • AWS ๋ฆฌ์ „ ๋ฐ ๊ณ„์ •์„ ์ •์˜ํ•˜๊ณ  ์Šค์ผ€์ค„๋Ÿฌ ์ผ์ •์„ EC2 ๋ฐ RDS ์ธ์Šคํ„ด์Šค์— ์—ฐ๊ฒฐํ•˜๋Š” ๋ฐ ์‚ฌ์šฉํ•  ์‚ฌ์šฉ์ž ์ง€์ • ํƒœ๊ทธ๋ฅผ ์ •์˜ํ•œ๋‹ค.
    • Lambda ํ•จ์ˆ˜๋Š” ์‹คํ–‰๋  ๋•Œ๋งˆ๋‹ค DynamoDB์— ์ €์žฅ๋œ ์ผ์ •, ํƒœ๊ทธ ํ‚ค-๊ฐ’ ๋“ฑ์„ ๊ฒ€์ƒ‰ํ•œ๋‹ค.
  • ๋น„์šฉ : Lambda ํ•จ์ˆ˜ ์‹คํ–‰ ๋น„์šฉ ๋ฐ DynamoDB, CloudWatch ๋น„์šฉ์ด ๋ถ€๊ณผ๋œ๋‹ค. ์ƒ์„ธํ•œ ๋‚ด์šฉ์€ ์ด ๊ณณ์„ ์ฐธ๊ณ .

 


 

๋‘ ๊ฐ€์ง€ ๋ฐฉ๋ฒ• ์ค‘ RDS๋„ ํ•จ๊ป˜ ์Šค์ผ€์ค„๋Ÿฌ๋ฅผ ์ ์šฉํ•  ์ˆ˜ ์žˆ๋Š” AWS Instance Scheduler on AWS๋ฅผ ์ด์šฉํ•ด๋ณด์ž.

์ธ์Šคํ„ด์Šค๊ฐ€ ์—ฌ๋Ÿฌ ๊ณ„์ •์— ๋ถ„์‚ฐ๋˜์–ด ์žˆ๊ณ  ์ค‘์•™ ๊ณ„์ •์—์„œ ์Šค์ผ€์ค„๋ง์„ ๊ด€๋ฆฌํ•˜๊ณ  ์‹ถ์€ ๊ฒฝ์šฐ ์•„์ฃผ ์œ ์šฉํ•˜๋‹ค.

 

โ˜„๏ธ To-Be Architecture

 


 

1. CloudFormation Stack ๋ฐฐํฌ

1-1. aws-instance-scheduler ๋ฐฐํฌ

[ Primary Account - A ]์—์„œ aws-instance-scheduler.template๋ฅผ ์ด์šฉํ•˜์—ฌ CloudFormation Stack์„ ์ƒ์„ฑํ•˜์ž. ํ•ด๋‹น ํ…œํ”Œ๋ฆฟ์€ ์ด ๊ณณ์—์„œ ๋‹ค์šด๋กœ๋“œ ๊ฐ€๋Šฅํ•˜๋‹ค.

CloudFormation์—์„œ ๊ฐ ํŒŒ๋ผ๋ฏธํ„ฐ์˜ ์˜๋ฏธ๋Š” ๋‹ค์Œ ๋งํฌ ์ฐธ์กฐ : AWS Docs: Step 1: Launch the instance scheduler hub stack

๐Ÿ”ท Instance Scheduler tag name

์ž๋™ stop-start ์•ก์…˜์„ ์ˆ˜์‹ ํ•  ์ธ์Šคํ„ด์Šค๋ฅผ ์‹๋ณ„ํ•˜๋Š” ํƒœ๊ทธ ํ‚ค๋ฅผ ์˜๋ฏธํ•˜๋ฉฐ ์‚ฌ์šฉ์ž ์ง€์ • ์‹œ์ž‘ ์ค‘์ง€ ๋งค๊ฐœ ๋ณ€์ˆ˜๋„ ํ—ˆ์šฉํ•œ๋‹ค. Instance Scheduler tag name์˜ ๊ธฐ๋ณธ๊ฐ’์€ “Schedule”์ด๋‹ค. ์Šคํƒ ์ƒ์„ฑ ํ›„ EC2 ๋˜๋Š” RDS ์ธ์Šคํ„ด์Šค์— ํƒœ๊น…ํ•  ๋•Œ ๋Œ€์†Œ๋ฌธ์ž ๊ตฌ๋ถ„์— ์œ ์˜ํ•˜์ž. ํƒœ๊ทธ์˜ ํ‚ค๋กœ schedule์„ ์ž…๋ ฅ ์‹œ ์Šค์ผ€์ค„๋Ÿฌ๊ฐ€ ๋™์ž‘ํ•˜์ง€ ์•Š๋Š”๋‹ค.

๐Ÿ”ท This Account

stack์„ ์ƒ์„ฑํ•˜๋Š” ๊ณ„์ •์— ์Šค์ผ€์ค„๋Ÿฌ๋ฅผ ์ ์šฉํ•  ์ธ์Šคํ„ด์Šค๊ฐ€ ์žˆ๋‹ค๋ฉด yes๋ฅผ ์„ ํƒํ•œ๋‹ค. No ์„ ํƒ ์‹œ,๋ฐ˜๋“œ์‹œ cross-account role์„ ๊ตฌ์„ฑํ•ด์•ผ๋งŒ ํ•œ๋‹ค. (1-2์—์„œ ๊ตฌ์„ฑ)

๐Ÿ”ท Frequency

Lambda ํ•จ์ˆ˜๊ฐ€ ์‹คํ–‰๋˜๋Š” ์ฃผ๊ธฐ๋กœ, ์„ ํƒํ•œ ๊ฐ’์— ๋”ฐ๋ผ ์Šค์ผ€์ค„๋งํ•˜๋Š” EventBridge Rule์ด ์ƒ์„ฑ๋œ๋‹ค. ์Šค์ผ€์ค„์„ ๊ด€๋ฆฌํ•  ์ธ์Šคํ„ด์Šค๊ฐ€ ๋งŽ์„์ˆ˜๋ก frequency๋ฅผ ์ž‘์€ ๊ฐ’์œผ๋กœ ๊ฐ€์ ธ๊ฐ€๋Š” ๊ฒƒ์ด ์ข‹๋‹ค๊ณ  ํ•œ๋‹ค.

๐Ÿ”ท Provide a unique namespace value

ํ•ด๋‹น ์†”๋ฃจ์…˜ ๋‹ค์ค‘ ๋ฐฐํฌ์—์„œ ๊ตฌ๋ถ„ํ•˜๊ธฐ ์œ„ํ•œ unique identifier๋ฅผ ์ž…๋ ฅํ•œ๋‹ค. ex) dev, prod, main ๋“ฑ

๐Ÿ”ท Provide Organization Id OR List of Remote Account Ids (⇒ skip!)

๊ต์ฐจ ๊ณ„์ • ์Šค์ผ€์ค„๋ง์— ์ด ์†”๋ฃจ์…˜์„ ์‚ฌ์šฉํ•˜๋ ค๋ฉด aws-instance-scheduler-remote.template๋กœ ์Šคํƒ์„ ๋ฐฐํฌํ•œ ํ›„์— remote account id๋ฅผ ์—…๋ฐ์ดํŠธํ•˜์—ฌ์•ผ ํ•œ๋‹ค. remote account์˜ ์Šคํƒ์€ cross-account role ARN์„ ์ƒ์„ฑํ•˜๊ณ , primary account์˜ ์Šคํƒ์—์„œ remote account id ์—…๋ฐ์ดํŠธํ•˜๋ฉด ์†”๋ฃจ์…˜์ด remote account์˜ ์ธ์Šคํ„ด์Šค์— ๋Œ€ํ•ด ์‹œ์ž‘ ๋ฐ ์ค‘์ง€ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ๋‹ค. ์ด ๋ถ€๋ถ„์€ ์šฐ์„  skipํ•˜๋ฉด ๋œ๋‹ค.

๐Ÿ”ท started tags/stopped tags

์ธ์Šคํ„ด์Šค ์Šค์ผ€์ค„๋Ÿฌ๊ฐ€ ์‹œ์ž‘/์ค‘์ง€ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•  ๋•Œ ์ธ์Šคํ„ด์Šค ์Šค์ผ€์ค„๋Ÿฌ๊ฐ€ ์ธ์Šคํ„ด์Šค์— ์ ์šฉํ•  ํƒœ๊ทธ๋ฅผ ์„ค์ •ํ•˜์—ฌ ์ธ์Šคํ„ด์Šค ์ƒํƒœ๊ฐ€ ์ธ์Šคํ„ด์Šค ์Šค์ผ€์ค„๋Ÿฌ์— ์˜ํ•ด ๋ณ€๊ฒฝ๋˜์—ˆ๋Š”์ง€ ์‰ฝ๊ฒŒ ์‹๋ณ„ํ•  ์ˆ˜ ์žˆ๋‹ค. ์ด ์˜ต์…˜์€ ์„ ํƒ ์‚ฌํ•ญ์ด์ง€๋งŒ ์„œ๋ฒ„์˜ ์ž ์žฌ์ ์ธ ๋ฌธ์ œ ํ•ด๊ฒฐ/์ง„๋‹จ์— ์œ ์šฉํ•˜๋‹ค.

 

์•„๋ž˜ ๊ทธ๋ฆผ์— ํ•ด๋‹นํ•˜๋Š” ์ฒดํฌ๋ฐ•์Šค์— ๋™์˜๋ฅผ ํ•ด์•ผ๋งŒ ์Šคํƒ ์ƒ์„ฑ์ด ๊ฐ€๋Šฅํ•˜๋‹ค. ํ•ด๋‹น CloudFormation ์Šคํƒ ์ƒ์„ฑ์œผ๋กœ ์ธํ•ด IAM ๋ฆฌ์†Œ์Šค๊ฐ€ ์ƒ์„ฑ๋œ๋‹ค๋Š” ๋‚ด์šฉ์ด๋‹ค.

์‹ค์ œ๋กœ, DynamoDB ํ…Œ์ด๋ธ” ๋ฐ Lambda ํ•จ์ˆ˜, IAM์„ ํฌํ•จํ•˜์—ฌ ์—ฌ๋Ÿฌ ๋ฆฌ์†Œ์Šค๊ฐ€ ์ƒ์„ฑ๋œ๋‹ค.

 

1-2. aws-instance-scheduler-remote ๋ฐฐํฌ

[ Secondary Account - B] ์Šค์ผ€์ค„๋ง์„ ์ ์šฉํ•  ์ธ์Šคํ„ด์Šค๊ฐ€ ์กด์žฌํ•˜๋Š” B Account๋กœ ์ด๋™ํ•˜์ž.

์•„๋ž˜ ๋งํฌ๋ฅผ ํ†ตํ•ด remote ํ…œํ”Œ๋ฆฟ์„ ๋‹ค์šด๋กœ๋“œํ•œ๋‹ค.

https://s3.amazonaws.com/solutions-reference/aws-instance-scheduler/latest/aws-instance-scheduler-remote.template

๐Ÿ”ท Provide the same unique namespace value defined in the hub stack.

1-1 ์Šคํƒ ์ƒ์„ฑ ์‹œ namespace value์— ์ž…๋ ฅํ–ˆ๋˜ ๊ฐ’์„ ์ž…๋ ฅํ•œ๋‹ค. ex) dev / prod / main

๐Ÿ”ท Instance Scheduler Hub Account ID

1-1์˜ ์Šคํƒ์„ ์ƒ์„ฑํ•œ account ID๋ฅผ ์ž…๋ ฅํ•œ๋‹ค.

remote ์Šคํƒ ์ƒ์„ฑ ์‹œ ์ƒ์„ฑ๋˜๋Š” IAM role์˜ trust relationship์€ ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Service": "lambda.amazonaws.com",
                "AWS": "arn:aws:iam::{primary-account-id}:root"
            },
            "Action": "sts:AssumeRole"
        }
    ]
}

ํ•ด๋‹น IAM Role์—๋Š” Primary Account์˜ Lambda ํ•จ์ˆ˜๊ฐ€ Secondary Account์˜ RDS์™€ EC2์— ํƒœ๊น…, ์ค‘์ง€, ์‹œ์ž‘ ๋“ฑ์„ ํ•  ์ˆ˜ ์žˆ๋Š” IAM Policy๊ฐ€ Attach๋˜์–ด ์žˆ์—ˆ๋‹ค.

1-3. 1-1์˜ ์Šคํƒ ์—…๋ฐ์ดํŠธ

1-1์—์„œ ์ƒ์„ฑํ•œ ์Šคํƒ > update > use current stack์„ ํ†ตํ•ด remote account id๋ฅผ ์ถ”๊ฐ€ํ•˜์ž. ๋‹ค๋ฅธ ๊ฐ’์€ ์ˆ˜์ •ํ•  ํ•„์š” ์—†์ด [ Provide Organization Id OR List of Remote Account Ids ] ์— 1-2์˜ remote account id๋ฅผ ์ถ”๊ฐ€ํ•˜์—ฌ ์Šคํƒ์„ ์—…๋ฐ์ดํŠธํ•˜์ž.

DynamoDB > ConfigTable > config ์•„์ดํ…œ์„ ํ™•์ธํ•˜์ž. DynamoDB ์ฝ˜์†”์—์„œ ํ™•์ธํ•˜๋Š” ๊ฒฝ์šฐ ํ…Œ์ด๋ธ” ์„ ํƒ ํ›„ [ explore items ] ๋ฒ„ํŠผ์„ ํ†ตํ•ด ์•„์ดํ…œ์„ ์ƒ์„ธํžˆ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

config์—๋Š” [ remote_account_ids ] ์†์„ฑ์ด ์žˆ์–ด์•ผ ํ•˜๊ณ  1-2์˜ remote account id๊ฐ€ ๊ทธ ๊ฐ’์œผ๋กœ ์žˆ์–ด์•ผ ํ•œ๋‹ค. ๊ทธ๋ ‡์ง€ ์•Š์€ ๊ฒฝ์šฐ 1-2 account์—์„œ๋Š” ์ธ์Šคํ„ด์Šค ์Šค์ผ€์ค„๋Ÿฌ๊ฐ€ ๋™์ž‘ํ•˜์ง€ ์•Š๋Š”๋‹ค.


2. Custom Schedule ์ƒ์„ฑ

์Šค์ผ€์ค„์„ ์ƒ์„ฑํ•˜๋ ค๋ฉด AWS Cloudformation์œผ๋กœ ์Šคํƒ ๋ฐฐํฌ ํ›„ 3๊ฐ€์ง€ ๋ฐฉ๋ฒ•์„ ์ด์šฉํ•˜์—ฌ ์Šค์ผ€์ค„๋ง ๊ทœ์น™์„ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ๋‹ค.

โ‘  Amazon DynamoDB ์ฝ˜์†” : DynamoDB์—์„œ ์ผ์ •์„ ์ƒ์„ฑํ•˜๊ธฐ ์œ„ํ•ด ์ฝ˜์†”์—์„œ ๊ตฌ์„ฑ ํ…Œ์ด๋ธ”(ConfigTable)์—์„œ ์ผ์ • ์ค‘ ํ•˜๋‚˜๋ฅผ ์ˆ˜์ •ํ•œ๋‹ค.
โ‘ก ์Šค์ผ€์ค„๋Ÿฌ CLI : ์Šค์ผ€์ค„๋Ÿฌ CLI์—์„œ ์ผ์ •์„ ๋งŒ๋“ค๋ ค๋ฉด ํ•ด๋‹น ๋ช…๋ น์„ ์‚ฌ์šฉํ•œ๋‹ค. ⇒ Scheduler CLI
โ‘ข AWS CloudFormation ์‚ฌ์šฉ์ž ์ง€์ • ๋ฆฌ์†Œ์Šค : ์‚ฌ์šฉ์ž ์ •์˜ ๋ฆฌ์†Œ์Šค๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์˜ˆ์•ฝ์„ ์ƒ์„ฑํ•˜๋ ค๋ฉด ์†”๋ฃจ์…˜์˜ ์‚ฌ์šฉ์ž ์ •์˜ ๋ฆฌ์†Œ์Šค์— ํ•ด๋‹น ํ•„๋“œ๋ฅผ ์ถ”๊ฐ€ํ•œ๋‹ค. ๋‹จ, ์‚ฌ์šฉ์ž ์ง€์ • ๋ฆฌ์†Œ์Šค๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์˜ˆ์•ฝ์„ ์ƒ์„ฑํ•˜๋Š” ๊ฒฝ์šฐ DynamoDB ์ฝ˜์†” ๋˜๋Š” ์Šค์ผ€์ค„๋Ÿฌ CLI๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํ•ด๋‹น ์˜ˆ์•ฝ์„ ์‚ญ์ œํ•˜๊ฑฐ๋‚˜ ์ˆ˜์ •ํ•  ์ˆ˜ ์—†๋‹ค. ์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ์Šคํƒ์— ์ €์žฅ๋œ ๋งค๊ฐœ ๋ณ€์ˆ˜์™€ ํ…Œ์ด๋ธ”์˜ ๊ฐ’ ์‚ฌ์ด์— ์ถฉ๋Œ์ด ๋ฐœ์ƒํ•œ๋‹ค

3๊ฐ€์ง€ ๋ฐฉ๋ฒ• ์ค‘ ๊ฐ€์žฅ ์ง๊ด€์ ์œผ๋กœ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ์—ˆ๋˜ scheduler CLI๋ฅผ ํ†ตํ•ด DynamoDB ํ…Œ์ด๋ธ”์— period์™€ schedule ๊ฐ’์„ ์ƒ์„ฑํ•˜์˜€๋‹ค. DynamoDB ํ…Œ์ด๋ธ”์ด ์กด์žฌํ•˜๋Š” Primary Account์— ์ ‘์†ํ•œ ์ƒํƒœ์—์„œ scheduler-cli ๋ช…๋ น์–ด๋ฅผ ์ˆ˜ํ–‰ํ•˜์˜€๋‹ค.

 

๐Ÿ”ท ์›ํ•˜๋Š” ์กฐ๊ฑด : ์›”์š”์ผ-๊ธˆ์š”์ผ๋งŒ ๊ฐ€๋™๋˜๊ณ  ์ฃผ๋ง์—๋Š” ์ค‘์ง€ ์ƒํƒœ. ์ฃผ์ค‘์—๋Š” ์•„์นจ 6์‹œ๋ถ€ํ„ฐ ์ €๋… 10์‹œ๊นŒ์ง€๋งŒ ๊ฐ€๋™ ์ƒํƒœ.

 

2-1. Scheduler CLI ํŒจํ‚ค์ง€ ๋‹ค์šด๋กœ๋“œ ( ์ฐธ๊ณ  )

2-2. period ์ƒ์„ฑ

scheduler-cli create-period \
--name mon-fri-6am-10pm \
--stack { 1-1์—์„œ ์ƒ์„ฑํ•œ CloudFormation Stack ์ด๋ฆ„ } \
--region ap-northeast-2 \
--begintime 06:00 --endtime 22:00 \
--weekdays mon-fri

2-2. schedule ์ƒ์„ฑ

scheduler-cli create-schedule \
--name mon-fri-6am-10pm \
--stack { 1-1์—์„œ ์ƒ์„ฑํ•œ CloudFormation Stack ์ด๋ฆ„ } \
--region ap-northeast-2 \
--periods mon-fri-6am-10pm \
--timezone Asia/Seoul

schedule์— period๋Š” ๋ฆฌ์ŠคํŠธ๋กœ ๋„ฃ์„ ์ˆ˜ ์žˆ๋‹ค. ์ฆ‰, ํ•˜๋‚˜์˜ ์Šค์ผ€์ค„์— ์—ฌ๋Ÿฌ๊ฐœ์˜ period ํ• ๋‹น์ด ๊ฐ€๋Šฅํ•˜๋‹ค.

DynamoDB > ConfigTable์„ ํ™•์ธํ•ด๋ณด๋ฉด, ํ•˜๊ธฐ ๊ทธ๋ฆผ๊ณผ ๊ฐ™์ด schedule๊ณผ period๊ฐ€ ์ƒ์„ฑ๋˜์–ด ์žˆ์Œ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค. ์ดˆ๊ธฐ์— ์ƒ์„ฑ๋˜์–ด ์žˆ๋Š” schedule๊ณผ period๋Š” ํ•„์š” ์—†๋‹ค๋ฉด ์‚ญ์ œํ•ด๋„ ๋ฌด๋ฐฉํ•˜๋‹ค.

์œ„ schdeuler-cli๋ฅผ ์ด์šฉํ•œ ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด ์ƒ์„ฑ๋œ schedule์€ ์•„๋ž˜์™€ ๊ฐ™์€ attribute๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ๋‹ค.

Ref. AWS Docs: Schedule definitions

enforced, retain_running ๋ฐ stop_new_instances๋Š” ์‹คํ–‰์‹œ๊ฐ„ ์™ธ์— ์ˆ˜๋™ ์ค‘์ง€/์‹œ์ž‘๊ณผ ๊ด€๋ จ๋œ attribute์ด๋‹ˆ ์ฐธ๊ณ ํ•˜์ž.

๐Ÿ’ก ํƒœ๊น… ์ „๋žต ์ฐธ๊ณ  ๐Ÿ’ก 
AWS Whitepaper: Best Practices for Tagging AWS Resources

 


3. ์Šค์ผ€์ค„๋Ÿฌ๋ฅผ ์ ์šฉํ•  ์ธ์Šคํ„ด์Šค์— ํƒœ๊น…

1-1์—์„œ ์ž…๋ ฅํ•œ TagName์— ํ•ด๋‹นํ•˜๋Š” ๊ฐ’์„ Tag Key, 2-2์—์„œ ์ƒ์„ฑํ•œ schedule ์ด๋ฆ„์„ Tag Value๋กœ ํ•˜์—ฌ ์Šค์ผ€์ค„๋ ๋ฅผ ์ ์šฉํ•  ์ธ์Šคํ„ด์Šค์— ํƒœ๊น…์„ ํ•˜์ž. ์—ฌ๋Ÿฌ ์ธ์Šคํ„ด์Šค์— ์ผ๊ด„๋กœ ์ ์šฉํ•  ์‹œ์—๋Š” Tag Editor๋ฅผ ์ด์šฉํ•˜๋Š” ๊ฒƒ๋„ ์œ ์šฉํ•˜๋‹ค.

โš ๏ธ ๋ฐฑ์—… ์‹œ๊ฐ„ ๊ณ ๋ ค โš ๏ธ
๋‹จ, RDS ์ž๋™ ๋ฐฑ์—…์ด ์‹คํ–‰๋˜๋ ค๋ฉด ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค๊ฐ€ available ์ƒํƒœ์—ฌ์•ผ ํ•œ๋‹ค. ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค๊ฐ€ available ์™ธ์˜ ์ƒํƒœ์ธ ๊ฒฝ์šฐ, ์˜ˆ์ปจ๋Œ€ storage_full ์ƒํƒœ์ธ ๊ฒฝ์šฐ ์ž๋™ ๋ฐฑ์—…์ด ์‹คํ–‰๋˜์ง€ ์•Š๋Š”๋‹ค.
Ref. AWS Docs: RDS ๋ฐฑ์—… ์ž‘์—…

 

3์˜ ํƒœ๊น…๊นŒ์ง€ ์ž˜ ์™„๋ฃŒํ–ˆ๋‹ค๋ฉด ์ •ํ•ด์ง„ ์‹œ๊ฐ„์— ์ธ์Šคํ„ด์Šค๊ฐ€ ์‹œ์ž‘๋˜๊ณ  ์ค‘์ง€๋จ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

RDS์™€ EC2์— ์Šค์ผ€์ค„๋Ÿฌ ์ ์šฉ ์„ฑ๊ณต~~! ๐Ÿ˜‡

 

๐Ÿง‘‍๐Ÿ”ง Troubleshooting

ํŠธ๋Ÿฌ๋ธ” ์ŠˆํŒ… ์‹œ, main account์˜ CloudWatch > Log group์—์„œ {1-1์˜ ์Šคํƒ ์ด๋ฆ„}-logs๋ฅผ ํ™•์ธํ•˜์ž.

Ref. Instance Scheduler on AWS > Troubleshooting

 

 


๐Ÿ”— ์ฐธ๊ณ  ๋งํฌ

  1. AWS Docs: Resource Scheduler
  2. AWS Docs: Automate starting and stopping AWS instances
  3. AWS Docs: Step 2 (Optional): Launch the remote stack in secondary accounts
  4. ๊ธฐ์ˆ  ๋ธ”๋กœ๊ทธ: How to Implement AWS Instance Scheduler in an AWS Organization for Cross-Account Cost Savings
  5. ๊ธฐ์ˆ  ๋ธ”๋กœ๊ทธ: ํšจ์œจ์ ์ธ ๋น„์šฉ ๊ด€๋ฆฌ๋ฅผ ์œ„ํ•œ AWS Instance Scheduler ์„ค์ •
  6. AWS Docs: Scheduler CLI