Cloudformation template to export the dataset into S3 Location

0

Hi All,

Created a Cloudformation template, which exports the subscribed dataset latest revision to S3 bucket. Lambda job looks for the latest revision and uses api 'ExportAssetsToS3' to write the data into s3 bucket. I am trying to achieve, lambda job to write the data to a location with prefix like - bucket/prefix/files .

Prefix is like current date and it should be changed for everyday.

In the ExportAssetsToS3, in AssetDestinations passed Key : '/2020-08-06/ and error came as below.

[ERROR] ValidationException: An error occurred (ValidationException) when calling the CreateJob operation: The request was rejected because it attempted to export distinct assets to the same target Amazon S3 object. When no key is specified in the request, Asset name is used as the default target key.
Traceback (most recent call last):
File "/var/task/index.py", line 69, in handler
{ 'AssetId': asset['Id'], 'Bucket': destination_bucket, 'Key': '/2020-08-06/' } for asset in assets_chunk
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 626, in _make_api_call
raise error_class(parsed_response, operation_name)

Ex: Bucket - ABC
Prefix: /2020-08-06/
Final S3 location - ABC/2020-08-06/file.txt

Is there any approach to add the prefix to the S3 bucket.

Thanks,
Naveen J

Hi All,

Here is the Solution -

Change the code in export_job, AssetDestinations as below

'AssetDestinations': [
{ 'AssetId': asset['Id'], 'Bucket': destination_bucket, 'Key': '
abc/2020-08-06/' + asset['Name'] } for asset in assets_chunk ]

Thanks,
Naveen J

Edited by: naveen838 on Aug 7, 2020 9:33 AM

Edited by: naveen838 on Aug 7, 2020 9:33 AM

질문됨 4년 전305회 조회
1개 답변
0

Hi naveen838, apologies for the late answer. Does the revision you are trying to export have multiple assets with the same name? If multiple assets have the same name, the export fails due to conflict of the target S3 object key.

Edited by: akram-AWS on Jan 7, 2021 3:09 PM

AWS
답변함 3년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠