Skip to content

Lambda: detect transitive dependencies from higher-order functions #310

@sam-goodwin

Description

@sam-goodwin

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(),
    ...
  });
});

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions