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

Allow for a dynamic LambdaS3Code key property #166

Closed
rclark opened this issue Jun 22, 2018 · 3 comments
Closed

Allow for a dynamic LambdaS3Code key property #166

rclark opened this issue Jun 22, 2018 · 3 comments

Comments

@rclark
Copy link

rclark commented Jun 22, 2018

We have CI systems that build lambda code bundles for our applications on commit. These systems write bundles to S3 locations like this:

s3://some-bucket/bundles/application-name/commit-sha.zip

Our CloudFormation templates all have a GitSha parameter that indicates which commit of the application you want to deploy. So when we define Lambda function's now, the code Property is an object that looks like this:

{
  "S3Bucket": "some-bucket",
  "S3Key": { "Fn::Sub": "bundles/application-name/${GitSha}.zip" }
}

I can't seem to reproduce this behavior through the LambdaS3Code construct, which will only accept a string for the key argument.

new Lambda(this, "Function", {
  code: new LambdaS3Code(utilityBucket, new FnSub('bundles/aws-cdk-explorer/${GitSha}.zip')),
  handler: 'index.js',
  runtime: LambdaRuntime.NodeJS
})
@rix0rrr
Copy link
Contributor

rix0rrr commented Jun 22, 2018

Yes, this is not great, and something we're aware of (but unsure how to fix short of introducing a more complex type system involving generics). Before we start making changes, we want to make an inventory of how often these kinds of scenarios occur in practice.

As a workaround, you can bypass the typechecker by putting as any after the value. It will ultimately synthesize to the correct CloudFormation.

@rclark
Copy link
Author

rclark commented Jun 22, 2018

we want to make an inventory of how often these kinds of scenarios occur in practice.

I can close this ticket with the as any workaround, unless you want it to hang around for the inventory. Thanks!

@rix0rrr
Copy link
Contributor

rix0rrr commented Jun 22, 2018

Yep, we'll close it, we have the link in the other ticket. Thanks for reporting!

@rix0rrr rix0rrr closed this as completed Jun 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants