functionless icon indicating copy to clipboard operation
functionless copied to clipboard

Lambda: detect transitive dependencies from higher-order functions

Open sam-goodwin opened this issue 3 years ago • 5 comments

We currently do not support detecting dependencies to infer IAM Policies and automate environment variable/client instantiation if the dependency is contained within another function called by the closure.

  • [ ] detect dependencies used by another function (declared outside of its scope)
const table = new Table(..);

function foo() {
  return $AWS.DynamoDB.GetItem({
    Table: table,
    ...
  });
}

new Function(scope, id, () => {
  return foo();
});
  • [ ] detect dependencies passed to a function as input
function foo(table: Table) {
  return $AWS.DynamoDB.GetItem({
    Table: table,
    ...
  });
}

const table = new Table(..);

new Function(scope, id, () => {
  // dependency passed to foo
  return foo(table);
});
  • [ ] detect dependencies returned from another funciton
const table = new Table(..);

function getTable() {
  return table;
}

new Function(scope, id, () => {
  return $AWS.DynamoDB.GetItem({
    // dependency returned by a function call
    Table: getTable(),
    ...
  });
});

sam-goodwin avatar Jun 27 '22 02:06 sam-goodwin

The "Integration" term is inclusive of all cases here right?

thantos avatar Jun 27 '22 05:06 thantos

The "Integration" term is inclusive of all cases here right?

Not sure what you mean

sam-goodwin avatar Jun 27 '22 05:06 sam-goodwin

I mean the goal is a bit simpler, "find all integrations and apply them based on their contract" (bind, pre-warm, maybe call)

thantos avatar Jun 27 '22 06:06 thantos

Same as #350 ?

thantos avatar Aug 02 '22 13:08 thantos

declare const table1;
declare const table2;
declare const table3;

function getTables(table1) {
  return [table1, table2, table3]
}

const tables = getTables(table1);

for (const table of tables) {
  $AWS.DynamoDB.GetItem({
    Table: table,
  })
}

sam-goodwin avatar Aug 02 '22 23:08 sam-goodwin