-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
CodeUri intrinsic function doesn't work for S3 bucket #526
Comments
Unfortunately, the SAM translator does not support intrinsic functions in the CodeUri field of You should be able to workaround this limitation by using the S3 location format of CodeUri and using your intrinsic functions inside that object. Try this instead:
If you use this form of CodeUri, the SAM translator just validates that you've provided Bucket and Key parameters and will then pass those values onto the Code property of the |
Hit this issue when using a !Ref to a Parameter. In our case, we're pointing at a local file so the workaround doesn't help. |
@rjlohan Could you provide an example of what you were trying to do? Were you trying to ref a parameter in the |
Hi there, I have a similar issue with intrinsic functions with s3 codeUri I think (although specifically with What we started with was this: CodeUri: !Ref PathToFunction however this was causing errors, presumably due to the issues with intrinsic functions here, so we switched to something like this which works: CodeUri: ../path/to/my/lambda/function However we quite like the parameterisation... So following the above workaround we end up with this: CodeUri:
Bucket: some-s3-bucket
Key: !Ref PathToFunction However locally that path appears to get set incorrectly, so I tried hardcoding it again: CodeUri:
Bucket: some-s3-bucket
Key: ../path/to/my/lambda/function But unfortunately still no luck. Presumably because locally I don't have an s3 bucket to reference... which I suspect may be the same issue as @rjlohan is having @keetonian . |
Just found #271 which looks like a similar issue to this one (and better matches my comment/question). |
@craigkj You can't specify a local path like this. The only case where you're allowed to specify a local path is when you run |
|
SAM CLI, version 1.0.0, still has error "Lambda function 'HelloWorldFunction' has specified S3 location for CodeUri which is unsupported. Using default value of '.' instead" I just build for Example Hello World of SAM. Has any solution for it? :((( |
Worry not my little chicklets, I've submitted a feature request for this bug. It will be passed to the internal AWS engineering team. However, I'm not sure how long it will take for them to engineer the solution. |
Solution can be found in #526 (comment) Closing as the way to achieve this is to use the S3 location format over the shorthand. |
I defined CodeUri param with !Sub function in YAML:
And only Specifying CodeUri using inartistic functions caused exception:
According to https://aws.amazon.com/about-aws/whats-new/2017/02/aws-serverless-application-model-aws-sam-supports-inline-swagger-and-aws-cloudformation-intrinsic-functions/ (Posted On: Feb 17, 2017):
CodeUri: !Sub "s3://my_backet/my_app/${Version}/code.zip"
Observed result:
Exception:
Failed to create the changeset: Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state Status: FAILED. Reason: Transform AWS::Serverless-2016-10-31 failed with: Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [MyFunc] is invalid. 'CodeUri' requires Bucket and Key properties to be specified
Expected result:
CodeUri could by defined as S3 bucket using inartistic functions like !Sub
The text was updated successfully, but these errors were encountered: