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

CDK followSymlinks not supported #6959

Open
vieirai opened this issue Apr 17, 2024 · 2 comments
Open

CDK followSymlinks not supported #6959

vieirai opened this issue Apr 17, 2024 · 2 comments
Labels
blocked/more-info-needed More info is needed from the requester. If no response in 14 days, it will become stale. type/bug

Comments

@vieirai
Copy link

vieirai commented Apr 17, 2024

SAM should support the CDK followSymlinks config option.

Currently SAM is the recommended tool for running CDK applications locally, as such I expect my CDK config to be compatible with SAM, however that is not always the case.
https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-cdk-testing.html

Proposal

The CDK followSymlinks flag should be supported by SAM.
https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.AssetImageCodeProps.html#followsymlinks

Additional Details

The more I think about this, I'm not even sure if this is a SAM issue, or a Cloudformation issue or a CDK issue.
Currently CDK seems to be outputting AWS::Lambda::Function resources, which are part of the Cloudformation spec.
I guess CDK would have to be extended to output this flag in the Metadata and them SAM would have to implement some logic on top?

@vieirai vieirai added stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. type/feature Feature request labels Apr 17, 2024
@hnnasit
Copy link
Contributor

hnnasit commented Apr 18, 2024

Hi @vieirai, thanks for opening the issue. I'm trying to understand this more. I tried playing around with an image type lambda function and followSymlinks enum value and observed that on running cdk synth, the symlinks followed are based on the value set for followSymlinks. E.g. Setting it to NEVER and running sam build or sam local invoke does not follow the symlink and it can't find the Dockerfile, whereas setting it to ALWAYS or EXTERNAL allows the symlink to be followed and find the Dockerfile. Could you elaborate on what support are you looking for with the followSymlinks property for sam local commands and maybe provide an example of how it would work?

@hnnasit hnnasit added blocked/more-info-needed More info is needed from the requester. If no response in 14 days, it will become stale. type/bug and removed stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. type/feature Feature request labels Apr 18, 2024
@vieirai
Copy link
Author

vieirai commented Apr 25, 2024

Hi @hnnasit , thank you for looking into this.
I can confirm it does work as expected.

In short our project was doing:

cdk synth SymlinkStack --no-staging > template.yml
sam build symlink
sam local invoke symlink

And this way it does not resolve the symlink references and we end up with broken files inside the container.
Looks like we were trying to be too smart and avoid having to pass the template path, and it ended up causing problems.

I can confirm that if we follow the docs example and do:

cdk synth
sam build -t cdk.out/SymlinkStack.template.json symlink
sam local invoke -t cdk.out/SymlinkStack.template.json symlink

Then it does work.

Not sure if this is worth highlighting in the docs or not, but either way I'm happy for you to resolve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked/more-info-needed More info is needed from the requester. If no response in 14 days, it will become stale. type/bug
Projects
None yet
Development

No branches or pull requests

2 participants