Scheduled Auto Scaling: 指定時刻・定期的に自動でインスタンスを起動
2 notes
指定時刻に自動でインスタンスを起動させることを Scheduled Auto Scaling
というみたい。as-describe-scheduled-actions
で指定時刻にインスタンスを起動する必要があったため、コマンドのオプションを確認してみる。
(インスタンスの定義、グループの定義は完了しているものとする。)
Scheduled Auto Scaling 系のコマンドの種類
コマンド | 説明 |
---|---|
as-descrive-scheduled-actions | スケジュールの確認 |
as-put-scheduled-update-group-action | スケジュールの更新 |
as-delete-scheduled-action | スケジュールの削除 |
コマンドの形式は as-describe-scheduled-actions [ScheduledActionNames [ScheduledActionNames ...] ] [--auto-scaling-group value ] [--end-time value ] [--max-records value ] [--start-time value] [General Options]
で入力する。
Scheduled Auto Scaling を設定してみる
指定した時間(日本時間の 2013 年 02 月 07 日 19 時)にインスタンスを 3 台起動するスケジュール MyScheduleScaleOut1
を登録する。
// スケジュール登録
$ as-put-scheduled-update-group-action MyScheduleScaleOut1 --auto-scaling-group MyScaleGroup --time 2013-02-07T10:00:00Z --min-size 3 --max-size 7
// 確認
$ as-describe-scheduled-actions --headers
UPDATE-GROUP-ACTION GROUP-NAME NAME START-TIME MIN-SIZE MAX-SIZE
UPDATE-GROUP-ACTION MyScaleGroup MyScheduleScaleOut1 2013-02-07T10:00:00Z 3 7
登録されているスケジュール MyScheduleScaleOut1
を 最大 10 台起動するよう更新する。
// スケジュール修正
$ as-put-scheduled-update-group-action MyScheduleScaleOut1 --auto-scaling-group MyScaleGroup --time 2013-02-07T21:00:00Z --min-size 3 --max-size 10
OK-Put Scheduled Update Group Action
// 確認
$ as-describe-scheduled-actions --headers
UPDATE-GROUP-ACTION GROUP-NAME NAME START-TIME MIN-SIZE MAX-SIZE
UPDATE-GROUP-ACTION MyScaleGroup MyScheduleScaleOut1 2013-02-07T10:00:00Z 3 10
定期的(日本時間の 21 時)にインスタンスを 2 台起動するスケジュール MyScheduleScaleOut2
を登録する。
// スケジュール登録
$ as-put-scheduled-update-group-action MyScheduleScaleOut2 --auto-scaling-group MyScaleGroup --name "scale out" --region ap-northeast-1 --recurrence "0 12 * * *" -min-size 2 -max-size 5
OK-Put Scheduled Update Group Action
// 確認
$ as-describe-scheduled-actions --headers
UPDATE-GROUP-ACTION GROUP-NAME NAME START-TIME RECURRENCE MIN-SIZE MAX-SIZE
UPDATE-GROUP-ACTION MyScaleGroup MyScheduleScaleOut2 2013-02-07T12:00:00Z 0 12 * * * 2 5
登録されているスケジュール MyScheduleScaleOut2
の時間を 21 時から 20 時に変更する。
// スケジュール修正
$ as-put-scheduled-update-group-action MyScheduleScaleOut2 --auto-scaling-group MyScaleGroup --name "scale out" --region ap-northeast-1 --recurrence "0 11 * * *" -min-size 2 -max-size 5
OK-Put Scheduled Update Group Action
// 確認
$ as-describe-scheduled-actions --headers
UPDATE-GROUP-ACTION GROUP-NAME NAME START-TIME RECURRENCE MIN-SIZE MAX-SIZE
UPDATE-GROUP-ACTION MyScaleGroup MyScheduleScaleOut2 2013-02-07T11:00:00Z 0 12 * * * 2 5
なぜか --reccurence
部分が更新されなかった。
ちゃんと反映させるべく、登録されているスケジュールを一旦削除して再登録する。
// スケジュール削除
$ as-delete-scheduled-action MyScheduleScaleOut2 --auto-scaling-group MyScaleGroup
Are you sure you want to delete this Scheduled Action? [Ny]y
OK-Deleted Scheduled Action
// スケジュール登録
$ as-put-scheduled-update-group-action MyScheduleScaleOut2 --auto-scaling-group MyScaleGroup --name "scale out" --region ap-northeast-1 --recurrence "0 11 * * *" -min-size 2 -max-size 5
OK-Put Scheduled Update Group Action
// 確認
$ as-describe-scheduled-actions --headers
UPDATE-GROUP-ACTION GROUP-NAME NAME START-TIME RECURRENCE MIN-SIZE MAX-SIZE
UPDATE-GROUP-ACTION MyScaleGroup MyScheduleScaleOut2 2013-02-07T11:00:00Z 0 11 * * * 2 5
以下、各コマンドのヘルプ。
as-describe-scheduled-actions –help
SYNOPSIS
as-describe-scheduled-actions
[ScheduledActionNames [ScheduledActionNames ...] ] [--auto-scaling-group
value ] [--end-time value ] [--max-records value ] [--start-time value
] [General Options]
DESCRIPTION
Describes the specified scheduled actions, if the scheduled actions exist.
ARGUMENTS
ScheduledActionNames
Optional list of scheduled action names to be described.
If this list is omitted, all scheduled actions are described.
The list of requested scheduled actions cannot
contain more than 50 items. If an Auto Scaling
group name is provided, the results are limited to that group.
If unknown scheduled actions are requested, they are
ignored with no error.
SPECIFIC OPTIONS
--end-time VALUE
The latest scheduled start time that will be returned. If scheduled
action names are provided, this field will be ignored.
-g, --auto-scaling-group VALUE
No description available for this parameter.
--max-records VALUE
Maximum number of scheduled actions that will be described with each call
(default = 20, max = 50).
--start-time VALUE
The earliest scheduled start time that will be returned. If scheduled
action names are provided, this field will be ignored.
GENERAL OPTIONS
--aws-credential-file VALUE
Location of the file with your AWS credentials. This value can be set by
using the environment variable 'AWS_CREDENTIAL_FILE'.
-C, --ec2-cert-file-path VALUE
Path to the file holding the X.509 certificate. This value can be set by
using the environment variable 'EC2_CERT'.
--connection-timeout VALUE
Connection timeout (in seconds). The default value is '30'.
--delimiter VALUE
The delimiter to use when displaying delimited (long) results.
-H, --headers
For displaying tabular or delimited results, it includes the column
headers. For displaying XML results, it returns the HTTP headers from the
service request, if applicable. This is off by default.
-I, --access-key-id VALUE
The AWS access ID to use.
-K, --ec2-private-key-file-path VALUE
Path to the file holding the X.509 private key. This value can be set by
using the environment variable 'EC2_PRIVATE_KEY'.
--region VALUE
Amazon EC2 region to use. This value can be set by using the environment
variable 'EC2_REGION'.
-S, --secret-key VALUE
The AWS Secret Key to use.
--show-empty-fields
Shows empty fields and rows, using a (nil) value. The default is to not
show empty fields or columns.
--show-request
Displays the URL the tools used to call the AWS Service. The default
value is 'false'.
--show-table, --show-long, --show-xml, --quiet
The way in which the results are displayed: tabular, delimited (long),
XML or no output (quiet). Tabular shows a subset of the data in fixed
column-width form, while long shows all of the returned values delimited
by a character, XML is the raw return from the service and quiet
suppresses all standard output. The default is tabular, or 'show-table'.
-U, --url VALUE
This option will override the URL for the service call with VALUE. This
value can be set by using the environment variable
'AWS_AUTO_SCALING_URL'.
INPUT EXAMPLES
Describes all of the user's scheduled actions.
$PROMPT> as-describe-scheduled-actions
Describes more of the user's scheduled actions.
$PROMPT> as-describe-scheduled-actions --token token-1
Describes all of the user's scheduled actions in group test-group1.
$PROMPT> as-describe-scheduled-actions -g test-group1
Describes all the user's scheduled actions named 'test-action1' and
'test-action2'.
$PROMPT> as-describe-scheduled-actions test-action1 test-action2
Describes all the user's scheduled actions named 'test-action1' and
'test-action2' in group 'test-group1'.
$PROMPT> as-describe-scheduled-actions test-action1 test-action2 -g test-group1
OUTPUT
This command returns a table that contains the following:
* GROUP-NAME - Name of the Auto Scaling group.
* NAME - Name of the scheduled action.
* START-TIME - No description available for this column.
* RECURRENCE - Recurrence string.
* MIN-SIZE - Minimum group size.
* MAX-SIZE - Maximum group size.
* DESIRED-CAPACITY - Current desired capacity of the group.
* ACTION-ARN - ARN that references this scheduled action. This column
appears only in the --show-long view.
OUTPUT EXAMPLES
This is an example output for a scheduled action.
GROUP-NAME NAME TIME MIN-SIZE MAX-SIZE DESIRED-CAPACITY
test-cg test-action1 2010-06-01T00:00:00Z 1 2 1
This is an example output for a recurring scheduled action.
GROUP-NAME NAME TIME RECURRENCE MIN-SIZE MAX-SIZE DESIRED-CAPACITY
test-cg test-recurring-action 2010-06-01T00:00:00Z 1 * * * * 1 2 1
as-put-scheduled-update-group-action –help
SYNOPSIS
as-put-scheduled-update-group-action
ScheduledActionName --auto-scaling-group value [--desired-capacity
value ] [--end-time value ] [--max-size value ] [--min-size value ]
[--recurrence value ] [--start-time value ] [--time value ]
[General Options]
DESCRIPTION
Creates or updates a specified scheduled update group action with
attributes.
ARGUMENTS
ScheduledActionName
User-supplied scheduled action identifier which will uniquely identify
the scheduled action. You can also set this value using "--name".
Required.
SPECIFIC OPTIONS
-b, --start-time VALUE
User-specified start time when the scheduled action should execute on or
after.
--desired-capacity VALUE
New capacity setting for the group (minimum-size <= desired-capacity <=
maximum-size).
-e, --end-time VALUE
User-specified end time after which the recurring scheduled action should
not execute.
-g, --auto-scaling-group VALUE
User-supplied Auto Scaling group identifier which will uniquely identify
the Auto Scaling group. Required.
--max-size VALUE
Maximum group size (minimum-size <= maximum-size < 10000).
--min-size VALUE
Minimum group size (0 <= minimum-size <= maximum-size).
-r, --recurrence VALUE
User-specified recurrence string to determine start-time for recurring
future actions in Unix cron syntax. See
http://en.wikipedia.org/wiki/Cron for more details about cron syntax.
-t, --time VALUE
User-specified start time when the scheduled action should execute on or
after. !!WARNING!! Alias for "--start-time". Deprecated.
GENERAL OPTIONS
--aws-credential-file VALUE
Location of the file with your AWS credentials. This value can be set by
using the environment variable 'AWS_CREDENTIAL_FILE'.
-C, --ec2-cert-file-path VALUE
Path to the file holding the X.509 certificate. This value can be set by
using the environment variable 'EC2_CERT'.
--connection-timeout VALUE
Connection timeout (in seconds). The default value is '30'.
--delimiter VALUE
The delimiter to use when displaying delimited (long) results.
-H, --headers
For displaying tabular or delimited results, it includes the column
headers. For displaying XML results, it returns the HTTP headers from the
service request, if applicable. This is off by default.
-I, --access-key-id VALUE
The AWS access ID to use.
-K, --ec2-private-key-file-path VALUE
Path to the file holding the X.509 private key. This value can be set by
using the environment variable 'EC2_PRIVATE_KEY'.
--region VALUE
Amazon EC2 region to use. This value can be set by using the environment
variable 'EC2_REGION'.
-S, --secret-key VALUE
The AWS Secret Key to use.
--show-empty-fields
Shows empty fields and rows, using a (nil) value. The default is to not
show empty fields or columns.
--show-request
Displays the URL the tools used to call the AWS Service. The default
value is 'false'.
--show-table, --show-long, --show-xml, --quiet
The way in which the results are displayed: tabular, delimited (long),
XML or no output (quiet). Tabular shows a subset of the data in fixed
column-width form, while long shows all of the returned values delimited
by a character, XML is the raw return from the service and quiet
suppresses all standard output. The default is tabular, or 'show-table'.
-U, --url VALUE
This option will override the URL for the service call with VALUE. This
value can be set by using the environment variable
'AWS_AUTO_SCALING_URL'.
INPUT EXAMPLES
--start-time is a required parameter for non-recurring future actions.
$PROMPT> as-put-scheduled-update-group-action test-action1 -g test-group1 --start-time 2010-06-01T00:00:00Z --desired-capacity 1
Create a recurring scheduled action test-action1 on group test-group1 with
desired capacity 1, scheduled to execute at 00:30 Hrs on 1st Jan, June, Dec
$PROMPT> as-put-scheduled-update-group-action test-action1 -g test-group1 --recurrence "30 0 1 1,6,12 *" --desired-capacity 1
as-delete-scheduled-action –help
SYNOPSIS
as-delete-scheduled-action
ScheduledActionName --auto-scaling-group value [General Options]
DESCRIPTION
Deletes the specified scheduled action.
ARGUMENTS
ScheduledActionName
Name of the scheduled action to be deleted. You can also set this value
using "--name". Required.
SPECIFIC OPTIONS
-f, --force
Forces the delete to go through without prompting. By default, the delete
command will prompt.
-g, --auto-scaling-group VALUE
No description available for this parameter. Required.
GENERAL OPTIONS
--aws-credential-file VALUE
Location of the file with your AWS credentials. This value can be set by
using the environment variable 'AWS_CREDENTIAL_FILE'.
-C, --ec2-cert-file-path VALUE
Path to the file holding the X.509 certificate. This value can be set by
using the environment variable 'EC2_CERT'.
--connection-timeout VALUE
Connection timeout (in seconds). The default value is '30'.
--delimiter VALUE
The delimiter to use when displaying delimited (long) results.
-H, --headers
For displaying tabular or delimited results, it includes the column
headers. For displaying XML results, it returns the HTTP headers from the
service request, if applicable. This is off by default.
-I, --access-key-id VALUE
The AWS access ID to use.
-K, --ec2-private-key-file-path VALUE
Path to the file holding the X.509 private key. This value can be set by
using the environment variable 'EC2_PRIVATE_KEY'.
--region VALUE
Amazon EC2 region to use. This value can be set by using the environment
variable 'EC2_REGION'.
-S, --secret-key VALUE
The AWS Secret Key to use.
--show-empty-fields
Shows empty fields and rows, using a (nil) value. The default is to not
show empty fields or columns.
--show-request
Displays the URL the tools used to call the AWS Service. The default
value is 'false'.
--show-table, --show-long, --show-xml, --quiet
The way in which the results are displayed: tabular, delimited (long),
XML or no output (quiet). Tabular shows a subset of the data in fixed
column-width form, while long shows all of the returned values delimited
by a character, XML is the raw return from the service and quiet
suppresses all standard output. The default is tabular, or 'show-table'.
-U, --url VALUE
This option will override the URL for the service call with VALUE. This
value can be set by using the environment variable
'AWS_AUTO_SCALING_URL'.
INPUT EXAMPLES
Deletes the scheduled action 'test-action1' on group test-group1 if it
exists.
$PROMPT> as-delete-scheduled-action test-action1 -g test-group1