- Newest
- Most votes
- Most comments
Here is the correct code:
const stagingLambda = aws_lambda.Function.fromFunctionAttributes(
this,
"MyLambda",
{
functionArn:
"arn:aws:lambda:us-east-1:aaaaaaaaaaaa:function:nnnnnnnnnnnn",
skipPermissions: true,
},
);
The warning you're seeing is related to cross-account Lambda permissions. When you use Function.fromFunctionArn() to reference a Lambda function in another AWS account, the CDK tries to add permissions to that function but can't because it's in a different account.
Your annotation isn't working because you need to use the correct warning ID format. The warning ID "UnclearLambdaEnvironment" doesn't match the actual ID in the warning message.
To properly suppress this warning, you should modify your code to either:
- Use the exact warning ID as shown in the message:
Annotations.of(stagingLambda).acknowledgeWarning(
"addPermission() has no effect on a Lambda Function with region=us-east-1, account=471112525756, in a Stack with region=us-east-1, account=362454057537",
"This warning is intentional and reviewed."
);
Or, a better approach would be to:
- Pass the
sameEnvironment: falseparameter when creating the function reference:
const stagingLambda = aws_lambda.Function.fromFunctionArn(
this,
"FactsetNewDocumentLambda",
"arn:aws:lambda:us-east-1:471112525756:function:FactsetNewDocumentHandler",
{ sameEnvironment: false }
);
This explicitly tells CDK that the Lambda function is in a different environment and not to attempt adding permissions to it.
Sources
Config rule with custom lambda permission issue | AWS re:Post
Granting Lambda function access to other accounts - AWS Lambda
Lambda examples using AWS CLI - AWS SDK Code Examples
Relevant content
- asked 9 months ago
- asked 2 years ago

The code in here doesn't even compile.