Skip to content

(triggers): unable to use Trigger for more than one function #22110

@cecheta

Description

@cecheta

Related to #19272

Describe the bug

When using the Trigger construct, it only has permissions to invoke a single lambda function, meaning it cannot invoke more than one without receiving an access denied error.

Expected Behavior

Both lambda functions are invoked.

Current Behavior

Access denied exception

Reproduction Steps

import * as lambda from 'aws-cdk-lib/aws-lambda';
import * as triggers from 'aws-cdk-lib/triggers';

...

new triggers.TriggerFunction(this, 'One', {
  runtime: lambda.Runtime.NODEJS_16_X,
  handler: 'index.handler',
  code: lambda.Code.fromInline('exports.handler = function() { console.log("One"); };'),
});
    
new triggers.TriggerFunction(this, 'Two', {
  runtime: lambda.Runtime.NODEJS_16_X,
  handler: 'index.handler',
  code: lambda.Code.fromInline('exports.handler = function() { console.log("Two"); };'),
});

Possible Solution

The CustomResourceProvider should use addToRolePolicy rather than creating the policy in the constructor

Additional Information/Context

No response

CDK CLI Version

2.42.0

Framework Version

No response

Node.js Version

16.15.0

OS

Mac OS

Language

Typescript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/triggersRelated to the triggers packagebugThis issue is a bug.effort/smallSmall work item – less than a day of effortin-progressThis issue is being actively worked on.p2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions