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

Improve/fix integration between CDK with AWS SAM for local debugging #5065

Open
marcelokscunha opened this issue Nov 8, 2024 · 0 comments
Open
Labels
feature-request New feature or enhancement. May require GitHub community feedback.

Comments

@marcelokscunha
Copy link

marcelokscunha commented Nov 8, 2024

Is your feature request related to a problem? Please describe.
Yes. AWS SAM CLI works, but AWS Toolkit doesn't.

Directly using the AWS SAM CLI works for local execution of Lambda functions created from CDK as described in docs. However, with the AWS Toolkit for PyCharm (both Community and Professional) doesn't work.

The AWS Toolkit UI doesn't even recognize templates that are not in YAML format (if you open the cdk.out folder nothing is listed if there are only JSONs). Additionally, there seems to be validations in the template that forces us to use AWS SAM specification (i.e. native AWS CloudFormation specification is marked as invalid template, and throws errors like "Code property is invalid").

I'm able to make it work, but manual changes are needed. When I create serverless resources (e.g. Lambda functions) the cdk.out directory outputs JSON template for the compiled CloudFormation. To be able to work with AWS Toolkit for PyCharm and debug functions locally I need to perform 2 steps:

  1. convert template.json to template.yml
  2. modify the desired Lambda resource to follow strictly the AWS SAM specification. For example, i. change resource type from "Type: AWS::Lambda::Function" to "Type: AWS::Serverless::Function", ii. comment "Code" property, iii. add Metadata tags expected from AWS Toolkit (not AWS SAM), like "Dockerfile", "DockerContext".

Again, to make sure I'm being clear, if I run "sam local invoke -t template.json" works without any changes (no need to comment the "Code" property, modify the "Metadata", etc.). This is only needed when AWS Toolkit runs the SAM commands for us.

Describe the solution you'd like

AWS Toolkit for Jetbrains should be compatible with AWS SAM. Hence, it should support CloudFormation templates in JSON format and also support native CloudFormation syntax just like the AWS SAM CLI does.

Describe alternatives you've considered

Implementing this temporary workaround described, with the 2 manual steps.
The problem is that everytime that CDK code is compiled into CloudFormation, we need to perform the 2 steps. That's not scalable.

Additional context
None

@marcelokscunha marcelokscunha added the feature-request New feature or enhancement. May require GitHub community feedback. label Nov 8, 2024
@marcelokscunha marcelokscunha changed the title Improve/fix integratation between CDK with AWS SAM for local debugging Improve/fix integration between CDK with AWS SAM for local debugging Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or enhancement. May require GitHub community feedback.
Projects
None yet
Development

No branches or pull requests

1 participant