Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(lambda): Imported functions don't have account & region set correctly #17053

Closed
MarkRobbo opened this issue Oct 19, 2021 · 1 comment
Closed
Labels
@aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/small Small work item – less than a day of effort p2

Comments

@MarkRobbo
Copy link
Contributor

What is the problem?

Importing a lambda function from ARN using fromFunctionArn does not result in the correct region and account being used from the ARN.

Looking at the code this is a similar bug to #11199, environmentFromArn is not provided in the Import

Reproduction Steps

Either

const lambda = LambdaFunction.fromFunctionAttributes(this, 'ImportedFunction', {
  functionArn: 'arn:aws:lambda:us-east-1:123456789012:function:ProcessKinesisRecords',
  sameEnvironment: false
});

or

const lambda = this.cfnStackSafetyActionFunction = LambdaFunction.fromFunctionArn(
  this,
  'ImportedFunction',
  'arn:aws:lambda:us-east-1:123456789012:function:ProcessKinesisRecords'
);

What did you expect to happen?

Expected lambda.env.region === 'us-east-1' and lambda.env.account === '123456789012'

What actually happened?

lambda.env == scope.env

The environment details are derived from the stack environment rather than the provided ARN, preventing activities like a Lambda Invoke action to a different region in the same account as the CloudFormation Region always points to the same account.

CDK CLI Version

1.128.0 (build 1d3883a)

Framework Version

No response

Node.js Version

v16.7.0

OS

Amazon Linux

Language

Typescript

Language Version

No response

Other information

No response

@MarkRobbo MarkRobbo added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 19, 2021
@github-actions github-actions bot added the @aws-cdk/aws-lambda Related to AWS Lambda label Oct 19, 2021
@ryparker ryparker added effort/small Small work item – less than a day of effort p1 needs-reproduction This issue needs reproduction. and removed needs-triage This issue or PR still needs to be triaged. labels Oct 20, 2021
@nija-at nija-at added p2 and removed p1 needs-reproduction This issue needs reproduction. labels Nov 24, 2021
@nija-at nija-at removed their assignment Nov 24, 2021
@github-actions
Copy link

This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Nov 24, 2022
@github-actions github-actions bot added closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Dec 2, 2022
@github-actions github-actions bot closed this as completed Dec 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/small Small work item – less than a day of effort p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants