boto3 client NoRegionError: You must specify a region error only sometimes

后端 未结 7 1651
误落风尘
误落风尘 2021-01-30 07:30

I have a boto3 client :

boto3.client(\'kms\')

But it happens on new machines, They open and close dynamically.

    if endpoint         


        
7条回答
  •  梦谈多话
    2021-01-30 08:29

    One way or another you must tell boto3 in which region you wish the kms client to be created. This could be done explicitly using the region_name parameter as in:

    kms = boto3.client('kms', region_name='us-west-2')
    

    or you can have a default region associated with your profile in your ~/.aws/config file as in:

    [default]
    region=us-west-2
    

    or you can use an environment variable as in:

    export AWS_DEFAULT_REGION=us-west-2
    

    but you do need to tell boto3 which region to use.

提交回复
热议问题