2

我正在创建一个 csv 处理管道,在其中将原始 csv 文件上传到 S3,Lambda 使用 python 对其执行转换/清理,然后将其上传到不同的/接收 S3 存储桶中。在同一个 Lambda 函数中,我为每个正在处理的 csv 文件创建一个 create_data_set,然后引用该特定 csv,该特定 csv 被发送到接收 S3 存储桶中。

目标是当原始 csv 上传到 s3 时,它将在 lambda 函数中处理,发送到接收 s3 存储桶,并自动(或尽可能)更新已创建的仪表板以指向新的/最新的csv 文件作为其新数据集,该数据集由相同的 Lambda 函数生成。

但是我收到此错误消息:

[ERROR] ClientError: An error occurred (ValidationException) when calling the CreateDataSet operation: 1 validation error detected: Value 'arn:aws:s3:::randombucket-processed-salestotalv4' at 'physicalTableMap.string.member.s3Source.dataSourceArn' failed to satisfy constraint: Specified resource is not reachable in this region ('us-east-1')
Traceback (most recent call last):
  File "/var/task/handler.py", line 100, in featureengineering
    responsedataset = quicksight_client.create_data_set(
  File "/var/runtime/botocore/client.py", line 316, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/var/runtime/botocore/client.py", line 635, in _make_api_call
    raise error_class(parsed_response, operation_name)

那种让我失望,不知道如何解决它。Bellow 是处理数据库创建和摄取的 Lambda 函数的部分,并且是执行数据处理的同一 Lambda 函数的一部分(位于下面):

 responsedataset = quicksight_client.create_data_set(
        AwsAccountId='123456',
        DataSetId= csv_file_1, #the data set ID and name will be the same as the file
        Name= csv_file_1,
        PhysicalTableMap={
            'string': {
                'S3Source': {
                    'DataSourceArn': 'arn:aws:s3:::randombucket-processed-salestotalv4',
                    'UploadSettings': {
                        'Format': 'CSV',
                        'StartFromRow': 1,
                        'ContainsHeader': True,
                        'TextQualifier': 'SINGLE_QUOTE',
                        'Delimiter': ','
                    },
                    'InputColumns': [
                        *removed columns*
                        },
                    ]
                }  
            }
        },
        ImportMode='DIRECT_QUERY',
        Tags=[
            {
                'Key': 'Example',
                'Value': 'test'
            },
        ]
    )
    responseingestion = quicksight_client.create_ingestion(
    DataSetId= csv_file_1,
    IngestionId=csv_file_1,
    AwsAccountId='123456')

需要注意的是,这csv_file_1csv_file_1 = 'total_sales_' + str(datetime.now().strftime('%Y_%m_%d_%H_%M_%S')) + '.csv'我在函数开头定义的,并使用它来唯一指定 S3 中以前版本的处理后的 csv,同时也唯一指定 DataSetID 和 IngestionID。(不确定这是否是一个聪明的主意)。

对此可能还有很多工作/更改,但任何有关错误消息和解决该地区问题的帮助将不胜感激。

4

0 回答 0