function deconstructGetAtt()

in src/declarative-stack.ts [404:425]


function deconstructGetAtt(stack: cdk.Stack, id: string, attribute: string) {
  return cdk.Lazy.string({
    produce: () => {
      const res = stack.node.tryFindChild(id);
      if (!res) {
        const include = stack.node.tryFindChild('Include') as CfnInclude;
        if (!include) {
          throw new Error('Unexpected - "Include" should be in the stack at this point');
        }

        const raw = include.getResource(id);
        if (!raw) {
          throw new Error(`Unable to find a resource ${id}`);
        }

        // just leak
        return { 'Fn::GetAtt': [id, attribute] };
      }
      return (res as any)[attribute];
    },
  });
}