Amazon web services AWS S3 put事件Lambda使用正确的所有者Cognito创建DynamoDB条目

Amazon web services AWS S3 put事件Lambda使用正确的所有者Cognito创建DynamoDB条目,amazon-web-services,amazon-s3,aws-lambda,amazon-cognito,aws-amplify,Amazon Web Services,Amazon S3,Aws Lambda,Amazon Cognito,Aws Amplify,我使用amplify Storage client JS库将文件放在S3上 this.amplify.storage().put( this.s3ImagePath, this.s3ImageFile, this._storageOptions) 在s3上,我为PUT事件创建了一个触发器,以便调用Lambda。 Lambda在DynamoDB上插入一个条目。 我的问题是,我想在这个新创建的DynamoDB条目中放置正确的所有者

我使用amplify Storage client JS库将文件放在S3上

    this.amplify.storage().put( 
            this.s3ImagePath,
        this.s3ImageFile, 
        this._storageOptions)
在s3上,我为
PUT
事件创建了一个触发器,以便调用Lambda。 Lambda在DynamoDB上插入一个条目。 我的问题是,我想在这个新创建的DynamoDB条目中放置正确的所有者

在Lambda内部,我将headObject称为:

    const headResult = await S3.headObject({Bucket: bucketName, Key: key }).promise();
    console.log('headResult ', headResult);
我希望
headResult
将包含上传文件并在S3 bucket上创建事件的正确所有者。 我可以从S3事件中找到:

ownerIdentity: { principalId: 'A2N3MUDHGLOEZI' },
但是我不知道如何使用它来找到正确的所有者并在新的DynamoDB条目上插入正确的值

我还发现这有助于:

userIdentity: 
{ principalId: 'AWS:AROASQSLQMXWXMMOH3FEA:CognitoIdentityCredentials' },
由于我是无服务器范例的新手,您能告诉我当Lambda从S3 PUT事件触发时,我应该如何向DynamoDB插入一个新条目吗

作为一种解决方法,我考虑删除调用lambda的s3put事件,以便在文件上载完成时创建条目并从客户端调用一个变种。但我认为这是解决问题的方法,不是解决问题的正确方法。