Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x | import { CfnResource, Stack } from 'aws-cdk-lib';
import { Construct } from 'constructs';
/**
* Function to get the logicalId of a resource
* @param resource - The input resource for which the logicalId should be found
* @param cfnResource - The Cfn resource type to look for
* @returns - logicalId of the Cfn resource
*/
export function getResourceLogicalId(resource: Construct, cfnResource: any) {
let resourceNode = resource.node.children.find((e) => {
return (e as CfnResource) instanceof cfnResource;
});
const resourceLogicalId = Stack.of(resource).resolve(
(resourceNode!! as CfnResource).logicalId,
);
return resourceLogicalId;
}
|