-
Notifications
You must be signed in to change notification settings - Fork 82
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
Add SAM templating capability #42
Comments
@EliaBoschiero Can you provide a Cloudformation template that works correctly but fails for As far as I know, you can only reference parameters and resources in the current template. Here is the Cloudformation documentation for Ref where it says:
I understand that certain resources like |
Can't upload yml files but this should work, it just creates the lambda, but I can reference both the Role and the live alias
With the resource having a logical ID I can reference it even if it's not explicitly declared
|
@EliaBoschiero I will have to deploy this and test it, but if it works, it's some bizarre undocumented feature in Cloudformation. I'm not sure how I will be able to fix this in Thanks for opening this bug report 👍 |
@shadycuz I did some research and this is actually a SAM feature (Note the transform in the first line of my template. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/transform-aws-serverless.html), so basically an AWS hosted macro (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-macros.html), the best way would be to look for the transform before starting the conversion, execute |
@EliaBoschiero ahh I missed that I dont think actually transforming the template is the correct way to implement this feature because it would require working AWS credentials. Instead, we should inject the required additional terraform resources whenever we see a SAM function. This is not currently possible but the ability to override the default behavior for a specific resource is on the roadmap. So hopefully we will be able to fix this in the future. For now, perhaps you could try transforming the template and then converting it with |
@shadycuz Yes that's right I didn't think about the credentials. Yes that's what I ended up doing in the end! I think a quick mention of this in the README would be useful for many people seeing as a serverless template is not actually considered compliant (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/transform-aws-serverless.html)
|
@EliaBoschiero If you want to submit a PR to add SAM templates to the roadmap in the README that would be great. If not I will get to it eventually. I actually don't think we need to rework the return values functions. The way it works right now should work once we "inject" the missing resources into Terraform. When Basically, on the first pass, we convert all the Cloudformation resources to Terraform resources but we keep all the Cloudformation expesssions. Then on the second pass, we convert the expressions to terraform equivalent. Edit: Thanks so much for all your help digging into this issue. I do think it will be fixed one day. |
Some resources are created automatically by cloudformation (Ex. Lambda Role https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html) but the cloudformation/functions/ref function can't find the explicit value in the template, this is not the only case of non explicit resource creation by cloudformation, off the top of my head there's also the FunctionAlias
The text was updated successfully, but these errors were encountered: