我正在使用aws cdk生成CF模板。在运行cdk deploy时,出现错误 创建资源失败。预期的params.Item为地图。
代码段:
object GenerateItem()
{
StringBuilder sb = new StringBuilder("{ \"ApiKey\": { \"S\": \"{apiKey}\" }, \"HmacSigningKey\": { \"S\": \"{hmacKey}\" }, \"Name\": { \"S\": \"{appName}\" } }");
sb.Replace("{apiKey}", "SuperSecureAPIKey");
sb.Replace("{hmacKey}", "SuperSecureHMACSigningKey");
sb.Replace("{appName}", "SuperSecureApp");
return sb.ToString();
}
insertRecord = new AwsSdkCall()
{
Service = "DynamoDB",
Action = "putItem",
Parameters = new Dictionary<string, object>
{
{ "TableName", Constants.BANKSTATEMENT_API_TOKEN_CONFIG_TABLE_NAME },
{ "Item", GenerateItem() },
},
PhysicalResourceId = PhysicalResourceId.Of("InitDynamoDbData")
};
var ps = new PolicyStatement(new PolicyStatementProps
{
Actions = new[] { "*" },
Resources = new[] { "*" }
});
// TODO: Writing to database is not working. "Failed to create resource. Expected params.Item to be a map"
var dynamodbWriter = new AwsCustomResource(this, Constants.BANKSTATEMENTAPIAUTH_DYNAMODB_WRITER, new AwsCustomResourceProps
{
OnCreate = insertRecord,
Policy = AwsCustomResourcePolicy.FromStatements(new[] { ps })
});