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

SQS Event Source on Alias has race condition #2084

Closed
sam-goodwin opened this issue Mar 22, 2019 · 3 comments · Fixed by #2091
Closed

SQS Event Source on Alias has race condition #2084

sam-goodwin opened this issue Mar 22, 2019 · 3 comments · Fixed by #2091
Labels
@aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug.

Comments

@sam-goodwin
Copy link
Contributor

If you create a SQS event source pointing at an Alias, CFN won't wait for the Alias to be created before attempting to create the event source mapping, causing the stack to fail.

Repro:

const fn = new lambda.Function(this, 'Function', {
  code: lambda.Code.inline('exports.handler = function() { return "hello"; }'),
  handler: 'index.handler',
  runtime: lambda.Runtime.NodeJS810
});
const version = fn.addVersion('1');
const alias = new lambda.Alias(this, 'Alias', {
  version,
  aliasName: 'test'
});

const queue = new sqs.Queue(this, 'Queue');
alias.addEventSource(new event_sources.SqsEventSource(queue));

Error:

Function does not exist (Service: AWSLambda; Status Code: 400; Error Code: InvalidParameterValueException;
@sam-goodwin sam-goodwin added @aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug. labels Mar 22, 2019
@eladb
Copy link
Contributor

eladb commented Mar 24, 2019

What's the solution?

@rix0rrr
Copy link
Contributor

rix0rrr commented Mar 25, 2019

How can this be true? Doesn't the event source refer to the alias ARN?

@sam-goodwin
Copy link
Contributor Author

@RomainMuller identified that it's because the alias's ARN is created with a Fn:Join, so we can fix that or add a dependency (ew).

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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants