sparse-intern-71089
08/14/2019, 12:51 AMsquare-ability-48831
08/14/2019, 12:51 AMconst dynamoSetup = async () => {
const chargerStateTable = await aws.dynamodb.getTable({name: 'charger_state'})
// Give our Lambda access to the Dynamo DB table, CloudWatch Logs and Metrics.
const chargerEventDispatchRole = new aws.iam.Role("charger-event-dispatch-role", {
assumeRolePolicy: aws.iam.assumeRolePolicyForPrincipal({ Service: "<http://lambda.amazonaws.com|lambda.amazonaws.com>" }),
})
const chargerEventDispatchDynamoDBPolicy = new aws.iam.RolePolicy("charger-event-dispatch-policy", {
role: chargerEventDispatchRole,
policy: pulumi.output({
Version: "2012-10-17",
Statement: [{
Action: ["dynamodb:UpdateItem", "dynamodb:PutItem", "dynamodb:GetItem", "dynamodb:DescribeTable"],
Resource: chargerStateTable.arn,
Effect: "Allow",
}, {
Action: ["logs:*", "cloudwatch:*"],
Resource: "*",
Effect: "Allow",
}],
}),
})
return chargerStateTable
}
dynamoSetup()
square-ability-48831
08/14/2019, 12:52 AMbig-piano-35669
pulumi up
? I tried the code with a DynamoDB table, and it seemed to work.
Note that we've made a recent change where you no longer need the async/await calls to invoke functions like getTable
, so a simplified version like so should work:
const chargerStateTable = aws.dynamodb.getTable({name: 'charger_state'})
// Give our Lambda access to the Dynamo DB table, CloudWatch Logs and Metrics.
const chargerEventDispatchRole = new aws.iam.Role("charger-event-dispatch-role", {
assumeRolePolicy: aws.iam.assumeRolePolicyForPrincipal({ Service: "<http://lambda.amazonaws.com|lambda.amazonaws.com>" }),
})
const chargerEventDispatchDynamoDBPolicy = new aws.iam.RolePolicy("charger-event-dispatch-policy", {
role: chargerEventDispatchRole,
policy: pulumi.output({
Version: "2012-10-17",
Statement: [{
Action: ["dynamodb:UpdateItem", "dynamodb:PutItem", "dynamodb:GetItem", "dynamodb:DescribeTable"],
Resource: chargerStateTable.arn,
Effect: "Allow",
}, {
Action: ["logs:*", "cloudwatch:*"],
Resource: "*",
Effect: "Allow",
}],
}),
})
square-ability-48831
08/14/2019, 4:43 PMindex.ts(33,35): error TS2570: Property 'arn' does not exist on type 'Promise<GetTableResult>'. Did you forget to use 'await'?
square-ability-48831
08/14/2019, 4:43 PMResource: chargerStateTable.arn,
square-ability-48831
08/14/2019, 5:36 PMwhite-balloon-205