Native support for Terraform in SAM CLI (now in Beta) #4553
Replies: 9 comments 14 replies
-
What I'm currently missing is a way to support having the Terraform configuration files in a subdirectory, e.g.:
When using e.g. I saw this parameter but not sure if it's configurable with CLI parameters? __ Btw: Link to launch announcement should rather be this one, right? |
Beta Was this translation helpful? Give feedback.
-
I've had a hard time wrapping my head around what it means for "Native Support for Terraform in SAM CLI" I realize what I think of / what we need is very different than what this change does. I now think that "Native Support for Terraform in SAM CLI" means that SAM uses Terraform to at least update the Lambda Function code. Not clear if it also means it would deploy the Lambda infrastructure by triggering Terraform. But in ether case, that's not really what we need / want. We use Terraform as our IaC but we do not use Terraform to normally deploy the Lambda image (code) to the Lambda function from our dev environment. Instead we run Terraform only to build out or update infrastructure and all the terraform code is in a directory tree distinct from our Lambda function code. We currently deploy our Lambda function code as zip images or docker images via our CI/CD pipeline or via some internal tooling. Both deal with the build process (Python, Node or Ruby, but mostly Python), packaging into zip or docker images, and then uploading to the lambda function using AWS CLI/SDK. So I am wondering if SAM in general or Sam for Terraform can be of use for us? We would love to use SAM in our environment in lieu of our internally built tools for doing the dev cycles of development and testing. Would also love to be able to take advantage of the ecosystem of SAM tooling primarily for the development and testing side of SAM, not the deployment so much. Unless we had a way to connect SAM's intentions of deployment to our mechanisms of deployment. |
Beta Was this translation helpful? Give feedback.
-
I love that AWS SAM is heading in this direction. My company requires that we use Terraform for our IaC as they are using Hashicorp's Sentinel for governance. I just found this page after doing a comparison between Couple of issues that I have run into.
When I look at |
Beta Was this translation helpful? Give feedback.
-
I really like the idea that Terraform could the common Infrastructure as Code layer with CDK as an option for cloud-native style applications. To that end it would be really nice if CDK supported CDK for Terraform (CDKTF). Perhaps activated with a flag like |
Beta Was this translation helpful? Give feedback.
-
We would greatly appreciate your input regarding a workaround that we've identified for addressing the known limitations of the Terraform support feature in the AWS SAM CLI repository, as documented in issues #4395 and #4396. This workaround requires customers to run We are interested to hear if this workaround is a visible workaround that you can do, and we are also seeking your feedback on the possibility of AWS SAM CLI running |
Beta Was this translation helpful? Give feedback.
-
I think that the direction is very right. There are probably a few companies that are using TF + AWS in order to be a bit less vendor locked-in. Even if we switch the execution mode temporarily to Local, then we are missing all the variables’ values that we maintain on TFE. |
Beta Was this translation helpful? Give feedback.
-
We release the Terraform support in |
Beta Was this translation helpful? Give feedback.
-
Terraform support in SAM CLI tool is GA now (announcement) in release 1.97.0. |
Beta Was this translation helpful? Give feedback.
-
Hi @moelasmar, Getting the same (as suggested above) via API was also not possible as it requires admin access on the workspace, which is not the common case in bigger organisations. I have also tried the -skip-prepare-infra command but it does not seem to have any effect. One thing also struck me - terraform plan is just the delta between code and infra state. What in the case when there are no changes and you just want to attach SAM to an existing TF project. Plan would be empty then. Wouldn't it make more sense to base everything on a state version? |
Beta Was this translation helpful? Give feedback.
-
Terraform Support
Recently we added native support for CDK applications in the SAM CLI - you can see our launch announcement blog post and download the beta version of the CLI.
We would like to collect the community’s feedback on whether we should add native support for Terraform in the SAM CLI. Terraform users would be able to use the SAM CLI’s build, package, local invoke, and start-api commands. The build and package commands make it easy to create deployment packages or OCI images that are ready to be used in AWS Lambda. The local invoke and start-api commands makes it easy to emulate AWS Lambda and API Gateway in local Docker container for testing purposes.
With this change, the SAM CLI would parse HCL definitions to understand functions and APIs that can be locally tested and built. The SAM CLI would not write HCL, translate to, or force the use of CloudFormation. Deployments should still be performed using the Terraform toolkit.
What feedback are we looking for?
We are moving the beta feedback to discussion for better gathering feedbacks. You can refer to the original issue for the past discussions and feedbacks. Thanks.
Is this something the community is interested in? Vote with 👍🏽 .
The sam build, package, and local invoke commands rely on the CodeUri property of a function resource pointing to a local path where the source code for the Lambda function is stored. The SAM CLI automatically pulls dependencies, compiles if necessary, and prepares a deployment package for AWS Lambda. The package command today produces an output template that contains the S3 URL for the deployment package the SAM CLI prepared. How would you like this work with Terraform?
Beta Was this translation helpful? Give feedback.
All reactions