boto3 Route53抱怨无法连接到端点URL:

时间:2016-07-01 17:49:46

标签: python boto amazon-route53 boto3

我试图让一些Route53自动化与boto一起工作,并注意到这个微小的boto3(版本1.3.1)示例:

create trigger trDatabse_OnDropTable
on database
for drop_table
as
begin
    set nocount on;

    --Get the table schema and table name from EVENTDATA()
    DECLARE @Schema SYSNAME = eventdata().value('(/EVENT_INSTANCE/SchemaName)[1]', 'sysname');
    DECLARE @Table SYSNAME = eventdata().value('(/EVENT_INSTANCE/ObjectName)[1]', 'sysname');

    IF @Schema = 'dbo' AND @Table = 'tab2'
    BEGIN
        PRINT 'DROP TABLE Issued.';

        --Optional: error message for end user.
        RAISERROR ('[dbo].[tab2] cannot be dropped.', 16, 1);

        --Rollback transaction for the DROP TABLE statement that fired the DDL trigger
        ROLLBACK;

        --Run your update after the ROLLBACK
        BEGIN TRAN
            UPDATE dbo.tab2
            SET ... ;
        COMMIT;
    END
    ELSE
    BEGIN
        --Do nothing.  Allow table to be dropped.
        PRINT 'Table dropped: [' + @Schema + '].[' + @Table + ']';
    END
end;

爆炸抱怨:

  File "... venv/lib/python2.7/site-packages/botocore/retryhandler.py", line 356, in _check_caught_exception
    raise caught_exception
botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "https://route53.us-east-1e.amazonaws.com/2013-04-01/hostedzone"

虽然这个类似的boto2(使用版本2.38.0)代码似乎工作正常:

import boto3
client = boto3.client('route53')
print client.list_hosted_zones()

并打印出有关我托管区域的信息字典。如果我试图哄boto3使用端点suggested by Amazon(即使看起来boto3应该知道默认情况下该怎么做...),如下所示:

from boto.route53.connection import Route53Connection
r53_conn = Route53Connection()
print r53_conn.get_all_hosted_zones()

我收到此错误:

  File "... venv/lib/python2.7/site-packages/botocore/client.py", line 572, in _make_api_call
    raise ClientError(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (SignatureDoesNotMatch) when calling the ListHostedZones operation: Credential should be scoped to a valid region, not 'us-east-1e'. 

我需要做些什么来教导boto3如何正确地与Route53对话,为什么boto2似乎知道如何自动执行此操作?

1 个答案:

答案 0 :(得分:1)

感谢您的回答Exception in Boto3 - botocore.exceptions.EndpointConnectionError 您需要做的就是配置~/.aws/config文件。 这似乎是你没有配置它或配置不正确。