How do I provide a binary attribute value in an AWSCustomResource DynamoDB PutRequest?

0

Hello. I am attempting to write CDK code to populate a DynamoDB table. The table has several attributes, including a binary attribute:

new AwsCustomResource(this, id, {
        onCreate: {
            service: 'DynamoDB',
            action: 'putItem',
            parameters: {
                TableName: tableName,
                Item: {
                    A1: { S: "hello" },
                    A2: { B: how do I do this?? },
                    A3: { N: "1" }
                }
            },
            physicalResourceId: PhysicalResourceId.of(contentKeysInitName)
        }

I've tried various formats that I've seen on the web, and with all of them I get the error "Received response status [FAILED] from custom resource. Message returned: Cannot read properties of undefined (reading 'byteLength')"

I've also seen references to the usage of Uint8array, but no clear examples of how to use it.

Thanks in advance.

2개 답변
1

DynamoDB accepts all data parameters as string values, and binary values should be base64 encoded strings:

  parameters: {
                TableName: tableName,
                Item: {
                    "A1": { "S": "hello" },
                    "A2": { "B": "aG93IGRvIEkgZG8gdGhpcz8/" },
                    "A3": { "N": "1" }
                }
            }
profile pictureAWS
전문가
답변함 8달 전
0

It doesn't work. I get the error I previously posted.

답변함 8달 전

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

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

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

관련 콘텐츠