この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。
超小ネタです。分かってしまえば『な〜んだぁ』という感じはありますすが、自分の中でも引っ掛かっていた部分でもあり、同じような事象で躓く方もいるかも知れないと思い、エントリとして起こしてみました。
AWS CLIではコマンド実行時に引数にboolean値を取るオプションもあったりします。てっきり自分の中ではオプションコマンドに次いでtrueなりfalseなりを指定するものと思っておりました。が違うようです。(実際勘違いしておりました)
結論から言うと、『boolean値を引数に取るオプションを付加して実行する場合、指定されているキー情報を渡すだけで良い(trueとして認識してくれる)』という事になります。
確認してみましょう。以下はawsコマンド全般で使えるdebugオプションです。--debug (boolean) とあります。
AWS() AWS()
NAME
aws -
DESCRIPTION
The AWS Command Line Interface is a unified tool that provides a con-
sistent interface for interacting with all parts of AWS.
SYNOPSIS
aws [options] <service_name> <operation> [parameters]
Use aws service help for information on a specific service.
OPTIONS
--debug (boolean)
Turn on debug logging.
そして以下はS3のバケット一覧を表示するコマンドです。まずは普通に実行してみます。
$ aws s3 list-buckets
{
"Owner": {
"DisplayName": "xxxxxxxxxxxxxxxxxxx",
"ID": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
},
"Buckets": [
{
"CreationDate": "2013-08-28T10:55:18.000Z",
"Name": "xxxxxxxxxxxxxxxxxx"
},
:
:
]
}
次いで--debugオプションを付けて実行してみます。ちゃんと動きました!
$ aws s3 list-buckets --debug
2013-09-02 12:12:58,421 - botocore.service - DEBUG - Creating service object for: s3
2013-09-02 12:12:58,421 - botocore.base - DEBUG - Attempting to load: aws/s3
2013-09-02 12:12:58,444 - botocore.base - DEBUG - Found data file: /Library/Python/2.7/site-packages/botocore/data/aws/s3.json
2013-09-02 12:12:58,444 - botocore.hooks - DEBUG - Event service-created: calling handler <function register_retries_for_service
:
:
2013-09-02 12:12:58,462 - awscli.clidriver - DEBUG - operation.name=UploadPartCopy
2013-09-02 12:12:58,462 - awscli.clidriver - DEBUG - creating ServiceOperation: upload-part-copy
2013-09-02 12:12:58,463 - botocore.operation - DEBUG - Creating parameter objects for: Operation:ListBuckets
2013-09-02 12:12:58,463 - awscli.clidriver - DEBUG - OrderedDict()
2013-09-02 12:12:58,463 - botocore.hooks - DEBUG - Event building-argument-table.s3.ListBuckets: calling handler <function add_streaming_output_arg at 0x1056e19b0>
2013-09-02 12:12:58,464 - botocore.credentials - INFO - Found credentials in Environment variables.
2013-09-02 12:12:58,464 - botocore.operation - DEBUG - Operation:ListBuckets called with kwargs: {}
2013-09-02 12:12:58,465 - botocore.endpoint - DEBUG - Making request for Operation:ListBuckets (verify_ssl=True) with params: {'headers': {}, 'uri_params': {}, 'payload': <botocore.payload.XMLPayload object at 0x1057ddf90>}
2013-09-02 12:12:58,465 - botocore.endpoint - DEBUG - Building URI for rest endpoint.
2013-09-02 12:12:58,465 - botocore.endpoint - DEBUG - Templated URI path: /
2013-09-02 12:12:58,465 - botocore.endpoint - DEBUG - Templated URI query_params:
2013-09-02 12:12:58,465 - botocore.endpoint - DEBUG - Rendered path: /
2013-09-02 12:12:58,465 - botocore.endpoint - DEBUG - Rendered query_params:
2013-09-02 12:12:58,465 - botocore.hooks - DEBUG - Event before-auth.s3: calling handler <function fix_s3_host at 0x1054dc0c8>
2013-09-02 12:12:58,466 - botocore.handlers - DEBUG - Checking for DNS compatible bucket for: https://s3-ap-northeast-1.amazonaws.com/
2013-09-02 12:12:58,466 - botocore.handlers - DEBUG - Not changing URI, bucket is not DNS compatible:
2013-09-02 12:12:58,466 - botocore.auth - DEBUG - Calculating signature using hmacv1 auth.
2013-09-02 12:12:58,466 - botocore.auth - DEBUG - HTTP request method: GET
2013-09-02 12:12:58,466 - botocore.auth - DEBUG - StringToSign:
GET
Mon, 02 Sep 2013 03:12:58 GMT
/
2013-09-02 12:12:58,472 - botocore.endpoint - DEBUG - Sending http request: <PreparedRequest [GET]>
2013-09-02 12:13:03,432 - botocore.response - DEBUG - Response Body:
<?xml version="1.0" encoding="UTF-8"?>
<ListAllMyBucketsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">(中略)</ListAllMyBucketsResult>
2013-09-02 12:13:03,432 - botocore.hooks - DEBUG - Event needs-retry.s3.ListBuckets: calling handler <botocore.retryhandler.RetryHandler object at 0x1057835d0>
2013-09-02 12:13:03,433 - botocore.retryhandler - DEBUG - No retry needed.
{
"Owner": {
"DisplayName": "xxxxxxxxxxxxxxxxxxx",
"ID": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
},
"Buckets": [
{
"CreationDate": "2013-08-28T10:55:18.000Z",
"Name": "xxxxxxxxxxxxxxxxxx"
},
:
:
]
}
$
--debugの後にtrue/falseを付けてみましょう。やはり『知らんがな』と言われてしまいますね。
$ aws s3 list-buckets --debug true
2013-09-02 12:25:19,384 - botocore.service - DEBUG - Creating service object for: s3
2013-09-02 12:25:19,384 - botocore.base - DEBUG - Attempting to load: aws/s3
:
2013-09-02 12:25:19,430 - botocore.hooks - DEBUG - Event building-argument-table.s3.ListBuckets: calling handler <function add_streaming_output_arg at 0x1102e19b0>
Unknown options: true
$
これを受けて、先日のRedshift x AWS CLIネタで投稿したエントリの『クラスタ削除(aws redshift delete-cluster)時にスナップショットを取るところをスキップするオプションが実行出来ない』件についても試してみます。
まずは何もオプション指定せず。Message欄で件の問題が指摘されています。
$ aws redshift delete-cluster --cluster-identifier cmtestcluster20130902
{
"Cluster": {},
"Errors": [
{
"Message": "FinalClusterSnapshotIdentifier is required unless SkipFinalClusterSnapshot is specified.",
"Code": "InvalidParameterCombination",
"Type": "Sender"
}
],
"ResponseMetadata": {
"RequestId": "c4959b8d-137f-11e3-80b4-c3dd1f2b951c"
}
}
A client error (InvalidParameterCombination) occurred: FinalClusterSnapshotIdentifier is required unless SkipFinalClusterSnapshot is specified.
$
-skip-final-cluster-snapshotを付けて実行。ちゃんと削除されました。ステータスもdeletingになっています。
$ aws redshift delete-cluster --cluster-identifier cmtestcluster20130902 --skip-final-cluster-snapshot
{
"Cluster": {
"ClusterVersion": "1.0",
"NumberOfNodes": 1,
"Endpoint": {
"Port": 5439,
"Address": "cmtestcluster20130902.xxxxxxxxxxxxxxx.ap-northeast-1.redshift.amazonaws.com"
},
"NodeType": "dw.hs1.xlarge",
"PubliclyAccessible": true,
"AvailabilityZone": "ap-northeast-1a",
"MasterUsername": "xxxxxxxxxxxxxxxxxx",
"ClusterParameterGroups": [
{
"ParameterGroupName": "default.redshift-1.0",
"ParameterApplyStatus": "in-sync"
}
],
"Encrypted": false,
"ClusterSecurityGroups": [],
"AllowVersionUpgrade": true,
"VpcSecurityGroups": [
{
"Status": "active",
"VpcSecurityGroupId": "sg-xxxxxxxxxxx"
}
],
"VpcId": "vpc-xxxxxxxxxxxxx",
"ClusterCreateTime": "2013-09-02T03:08:34.095Z",
"ClusterSubnetGroupName": "default",
"AutomatedSnapshotRetentionPeriod": 1,
"ClusterStatus": "deleting",
"ClusterIdentifier": "cmtestcluster20130902",
"PreferredMaintenanceWindow": "wed:13:30-wed:14:00",
"PendingModifiedValues": {}
}
}
オプション内容によってtrue/falseが何を意味してくるかはそのコマンド毎に異なってくる事と思いますので、用法を確認して適切な利用を心掛けて頂ければと思います。
ちなみに今回のこの問題、大瀧さんからのこの神の声的コメントによって解決に至る事となりました。ありがとうございました!
エラーの雰囲気から察するに、–skip~はboolean値”なし”で実行すると、trueになる気がします。どうでしょうか。