使用 redshift boto 时出错

Getting an error while using redshift boto

import boto3

client = boto3.Session(profile_name='Sandbox').client('redshift')
response = client.create_tags(ResourceName='arn:aws:redshift:us-east-1:123456:snapshot:situation',
Tags=[ {'Key': 'k1', 'Value': 'v1'},{'Key': 'k2', 'Value': 'v2'}])

打印回复

错误:

File "sai.py", line 5, in <module>
    response = client.create_tags(ResourceName='arn:aws:redshift:us-east-1:123456:snapshot:situation',Tags=[ {'Key': 'k1', 'Value': 'v1'},{'Key': 'k2', 'Value': 'v2'}])
  File "/Library/Python/2.7/site-packages/botocore/client.py", line 253, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/Library/Python/2.7/site-packages/botocore/client.py", line 543, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (InvalidParameterValue) when calling the CreateTags operation: The format of the provided snapshot identifier is invalid.

appears that Amazon Redshift 快照的 ARN 格式是:

arn:aws:redshift:[region]:[account]:snapshot:[cluster-name]/[snapshot-name]

因此,请尝试使用:

arn:aws:redshift:us-east-1:123456:snapshot:*/situation