How do i reference an existing timestream table in CDK?

470 Views Asked by At

I am using AWS CDK (Python) to manage infrastructure, including Amazon Timestream databases and tables.

Suppose i have an existing Timestream table that i want to set permissions on using CDK.

The only way i have seen to get a hold of a Timestream table is to use the CfnTable construct, a so called level 1 construct. This is because Timestream does not expose level 2 constructs yet. However, using this construct, i am creating a table as part of my stack, I am not referencing an existing resource.

For level 2 constructs, such as Function for Lambda, it is possible to reference an existing resource, for example by using the Function.from_function_name() method. I have not found any way of doing something similar for level 1 constructs.

Is it possible? If so, how?

1

There are 1 best solutions below

0
On BEST ANSWER

Just use the table's ARN directly as a resource in an IAM identity-based policy. Then add the policy to the appropriate Role, e.g. a Lambda Role.