- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.2k
 
Open
Labels
stage/needs-triageAutomatically applied to new issues and PRs, indicating they haven't been looked at.Automatically applied to new issues and PRs, indicating they haven't been looked at.
Description
Description:
When using sam build --hook-name terraform with a null_resource configured for IMAGE_LAMBDA_FUNCTION
(container-based Lambda), SAM CLI fails to detect the metadata resource and generates an empty CloudFormation template
with no Resources section.
Steps to reproduce:
- Create a Terraform/OpenTofu configuration with a container-based Lambda function
 - Add a 
null_resourcefor SAM metadata following the documentation exactly - Run 
sam build --hook-name terraform - SAM outputs: "There is no sam metadata resources, no enrichment or Makefile is required"
 - Error: [InvalidTemplateException("'Resources' section is required")]
 
Observed result:
SAM CLI successfully runs terraform plan and sees the null_resource in the plan output, but does not recognize it
as SAM metadata. The generated template at .aws-sam-iacs/iacs_metadata/template.json contains:
{"AWSTemplateFormatVersion": "2010-09-09", "Resources": {}, "Metadata": {"AWS::SAM::Hook": {"HookName": "terraform"}}}
Terraform/OpenTofu configuration
provider.tf:
terraform {
  required_version = "~> 1.2"
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 6.0"
    }
    null = {
      source  = "hashicorp/null"
      version = "~> 3.0"
    }
  }
}
provider "aws" {
  region = "us-west-2"
}
main.tf (relevant portions):
resource "aws_lambda_function" "chatrix" {
  function_name = "chatrix"
  role          = aws_iam_role.chatrix_lambda.arn
  package_type  = "Image"
  image_uri     = "${aws_ecr_repository.chatrix.repository_url}:latest"
  timeout       = 30
  memory_size   = 512
}
# SAM Metadata - following
https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/terraform-sam-metadata.html
locals {
  lambda_src_path = "${path.root}/.."
}
resource "null_resource" "sam_metadata_function" {
  triggers = {
    resource_name      = "aws_lambda_function.chatrix"
    resource_type      = "IMAGE_LAMBDA_FUNCTION"
    docker_context     = local.lambda_src_path
    docker_file        = "Dockerfile"
    docker_build_args  = jsonencode({})
    docker_tag         = "latest"
  }
}
Debug output excerpt
2025-11-02 18:05:21,005 | Parsing module resources
2025-11-02 18:05:21,005 | Skip processing the attribute image_scanning_configuration as its value is a map.
2025-11-02 18:05:21,005 | Skip processing the attribute environment as its value is a map.
2025-11-02 18:05:21,005 | Skip processing the attribute cors as its value is a map.
2025-11-02 18:05:21,005 | Parsing module outputs
2025-11-02 18:05:21,005 | Parsing module calls
2025-11-02 18:05:21,005 | Mapping S3 object sources to corresponding functions
2025-11-02 18:05:21,005 | There is no sam metadata resources, no enrichment or Makefile is required
The Terraform plan shows the null_resource:
# null_resource.sam_metadata_function will be created
resource "null_resource" "sam_metadata_function" {
  id       = (known after apply)
  triggers = {
    "docker_context"     = "/Users/.../chatrix"
    "docker_file"        = "Dockerfile"
    "docker_build_args"  = "{}"
    "docker_tag"         = "latest"
    "resource_name"      = "aws_lambda_function.chatrix"
    "resource_type"      = "IMAGE_LAMBDA_FUNCTION"
  }
}
### Expected result:
SAM CLI should detect the `null_resource` with `resource_type = "IMAGE_LAMBDA_FUNCTION"` and generate a valid
CloudFormation template with the Lambda function in the Resources section.
### Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
<!-- Either provide the following info (for AWS SAM CLI v1.68.0 or before) or paste the output of `sam --info` (AWS SAM CLI v1.69.0 or after). -->
1. OS: macos
2. `sam --version`: 1.145.2
3. AWS region: us-west-2
Paste the output of sam --info here
sam --info
{
  "version": "1.145.2",
  "system": {
    "python": "3.11.10",
    "os": "macOS-15.5-arm64-arm-64bit"
  },
  "additional_dependencies": {
    "container_engine": "Not available",
    "aws_cdk": "Not available",
    "terraform": "1.9.0"
  },
  "available_beta_feature_env_vars": [
    "SAM_CLI_BETA_FEATURES",
    "SAM_CLI_BETA_BUILD_PERFORMANCE",
    "SAM_CLI_BETA_TERRAFORM_SUPPORT",
    "SAM_CLI_BETA_PACKAGE_PERFORMANCE",
    "SAM_CLI_BETA_RUST_CARGO_LAMBDA"
  ]
}
`Add --debug flag to command you are running`
2025-11-02 18:10:58,087 | No config file found in this directory.
2025-11-02 18:10:58,087 | OSError occurred while reading TOML file: [Errno 2] No such file or directory: '/Users/satishtripathi/Documents/infinitePi-io/xxx/iac/samconfig.toml'
2025-11-02 18:10:58,087 | Config file location: /Users/satishtripathi/Documents/infinitePi-io/xxx/iac/samconfig.toml
2025-11-02 18:10:58,087 | Config file '/Users/satishtripathi/Documents/infinitePi-io/xxx/iac/samconfig.toml' does not exist
2025-11-02 18:10:58,088 | Looking for internal hook package
2025-11-02 18:10:58,088 | Loaded internal hook package "terraform"
2025-11-02 18:10:58,091 | Running Prepare Hook to prepare the current application
2025-11-02 18:10:58,091 | Executing prepare hook of hook "terraform"
2025-11-02 18:10:58,099 | Normalize the terraform application root module directory path /Users/satishtripathi/Documents/infinitePi-io/xxx/iac
2025-11-02 18:10:58,099 | Normalize the project root directory path /Users/satishtripathi/Documents/infinitePi-io/xxx/iac
2025-11-02 18:10:58,099 | Normalize the OutputDirPath /Users/satishtripathi/Documents/infinitePi-io/xxx/iac/.aws-sam-iacs/iacs_metadata
2025-11-02 18:10:58,099 | Initializing Terraform application
2025-11-02 18:10:58,306 | 
2025-11-02 18:10:58,306 | �[0m�[1mInitializing the backend...�[0m
2025-11-02 18:10:58,966 | 
2025-11-02 18:10:58,966 | �[0m�[1mInitializing provider plugins...�[0m
2025-11-02 18:10:58,966 | - Reusing previous version of hashicorp/aws from the dependency lock file
2025-11-02 18:10:59,201 | - Reusing previous version of hashicorp/null from the dependency lock file
2025-11-02 18:10:59,692 | - Using previously-installed hashicorp/aws v6.19.0
2025-11-02 18:10:59,700 | - Using previously-installed hashicorp/null v3.2.4
2025-11-02 18:10:59,700 | 
2025-11-02 18:10:59,700 | �[0m�[1m�[32mOpenTofu has been successfully initialized!�[0m�[32m�[0m
2025-11-02 18:10:59,701 | �[0m�[32m
2025-11-02 18:10:59,701 | You may now begin working with OpenTofu. Try running "tofu plan" to see
2025-11-02 18:10:59,701 | any changes that are required for your infrastructure. All OpenTofu commands
2025-11-02 18:10:59,701 | should now work.
2025-11-02 18:10:59,701 | 
2025-11-02 18:10:59,701 | If you ever set or change modules or backend configuration for OpenTofu,
2025-11-02 18:10:59,701 | rerun this command to reinitialize your working directory. If you forget, other
2025-11-02 18:10:59,701 | commands will detect it and remind you to do so if necessary.�[0m
2025-11-02 18:10:59,702 | Creating terraform plan and getting JSON output
2025-11-02 18:11:03,240 | �[0m�[1maws_ecr_repository.xxx: Refreshing state... [id=infinite-pi/xxx]�[0m
2025-11-02 18:11:03,242 | �[0m�[1mdata.aws_secretsmanager_secret.xxx_api_key: Reading...�[0m�[0m
2025-11-02 18:11:03,243 | �[0m�[1maws_iam_role.xxx_lambda: Refreshing state... [id=xxx-lambda-role]�[0m
2025-11-02 18:11:04,483 | �[0m�[1mdata.aws_secretsmanager_secret.xxx_api_key: Read complete after 1s [id=arn:aws:secretsmanager:us-west-2:xxxxx:secret:prod/xxx/api-key-neVOYz]�[0m
2025-11-02 18:11:04,487 | �[0m�[1maws_iam_policy.xxx_permissions: Refreshing state... [id=arn:aws:iam::xxxxx:policy/xxx-permissions]�[0m
2025-11-02 18:11:05,904 | 
2025-11-02 18:11:05,904 | OpenTofu used the selected providers to generate the following execution
2025-11-02 18:11:05,904 | plan. Resource actions are indicated with the following symbols:
2025-11-02 18:11:05,904 | �[32m+�[0m create�[0m
2025-11-02 18:11:05,904 | 
2025-11-02 18:11:05,904 | OpenTofu will perform the following actions:
2025-11-02 18:11:05,904 | 
2025-11-02 18:11:05,904 | �[1m  # aws_cloudwatch_log_group.xxx�[0m will be created
2025-11-02 18:11:05,904 | �[0m  �[32m+�[0m�[0m resource "aws_cloudwatch_log_group" "xxx" {
2025-11-02 18:11:05,904 | �[32m+�[0m�[0m arn               = (known after apply)
2025-11-02 18:11:05,904 | �[32m+�[0m�[0m id                = (known after apply)
2025-11-02 18:11:05,904 | �[32m+�[0m�[0m log_group_class   = (known after apply)
2025-11-02 18:11:05,904 | �[32m+�[0m�[0m name              = "/aws/lambda/xxx"
2025-11-02 18:11:05,904 | �[32m+�[0m�[0m name_prefix       = (known after apply)
2025-11-02 18:11:05,904 | �[32m+�[0m�[0m region            = "us-west-2"
2025-11-02 18:11:05,904 | �[32m+�[0m�[0m retention_in_days = 7
2025-11-02 18:11:05,904 | �[32m+�[0m�[0m skip_destroy      = false
2025-11-02 18:11:05,904 | �[32m+�[0m�[0m tags_all          = {
2025-11-02 18:11:05,904 | �[32m+�[0m�[0m "Environment"     = "Production"
2025-11-02 18:11:05,904 | �[32m+�[0m�[0m "ManagedBy"       = "Terraform"
2025-11-02 18:11:05,904 | �[32m+�[0m�[0m "SpendAllocation" = "Infrastructure"
2025-11-02 18:11:05,904 | }
2025-11-02 18:11:05,904 | }
2025-11-02 18:11:05,904 | 
2025-11-02 18:11:05,904 | �[1m  # aws_ecr_lifecycle_policy.xxx�[0m will be created
2025-11-02 18:11:05,904 | �[0m  �[32m+�[0m�[0m resource "aws_ecr_lifecycle_policy" "xxx" {
2025-11-02 18:11:05,904 | �[32m+�[0m�[0m id          = (known after apply)
2025-11-02 18:11:05,904 | �[32m+�[0m�[0m policy      = jsonencode(
2025-11-02 18:11:05,904 | {
2025-11-02 18:11:05,904 | �[32m+�[0m�[0m rules = [
2025-11-02 18:11:05,904 | �[32m+�[0m�[0m {
2025-11-02 18:11:05,904 | �[32m+�[0m�[0m action       = {
2025-11-02 18:11:05,904 | �[32m+�[0m�[0m type = "expire"
2025-11-02 18:11:05,904 | }
2025-11-02 18:11:05,904 | �[32m+�[0m�[0m description  = "Keep last 10 images"
2025-11-02 18:11:05,904 | �[32m+�[0m�[0m rulePriority = 1
2025-11-02 18:11:05,904 | �[32m+�[0m�[0m selection    = {
2025-11-02 18:11:05,904 | �[32m+�[0m�[0m countNumber = 5
2025-11-02 18:11:05,904 | �[32m+�[0m�[0m countType   = "imageCountMoreThan"
2025-11-02 18:11:05,904 | �[32m+�[0m�[0m tagStatus   = "any"
2025-11-02 18:11:05,904 | }
2025-11-02 18:11:05,904 | },
2025-11-02 18:11:05,904 | ]
2025-11-02 18:11:05,904 | }
2025-11-02 18:11:05,904 | )
2025-11-02 18:11:05,904 | �[32m+�[0m�[0m region      = "us-west-2"
2025-11-02 18:11:05,904 | �[32m+�[0m�[0m registry_id = (known after apply)
2025-11-02 18:11:05,904 | �[32m+�[0m�[0m repository  = "infinite-pi/xxx"
2025-11-02 18:11:05,904 | }
2025-11-02 18:11:05,904 | 
2025-11-02 18:11:05,904 | �[1m  # aws_iam_role_policy_attachment.xxx_permissions�[0m will be created
2025-11-02 18:11:05,904 | �[0m  �[32m+�[0m�[0m resource "aws_iam_role_policy_attachment" "xxx_permissions" {
2025-11-02 18:11:05,904 | �[32m+�[0m�[0m id         = (known after apply)
2025-11-02 18:11:05,904 | �[32m+�[0m�[0m policy_arn = "arn:aws:iam::xxxxx:policy/xxx-permissions"
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m role       = "xxx-lambda-role"
2025-11-02 18:11:05,905 | }
2025-11-02 18:11:05,905 | 
2025-11-02 18:11:05,905 | �[1m  # aws_iam_role_policy_attachment.lambda_basic�[0m will be created
2025-11-02 18:11:05,905 | �[0m  �[32m+�[0m�[0m resource "aws_iam_role_policy_attachment" "lambda_basic" {
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m id         = (known after apply)
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m role       = "xxx-lambda-role"
2025-11-02 18:11:05,905 | }
2025-11-02 18:11:05,905 | 
2025-11-02 18:11:05,905 | �[1m  # aws_lambda_function.xxx�[0m will be created
2025-11-02 18:11:05,905 | �[0m  �[32m+�[0m�[0m resource "aws_lambda_function" "xxx" {
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m architectures                  = (known after apply)
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m arn                            = (known after apply)
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m code_sha256                    = (known after apply)
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m function_name                  = "xxx"
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m id                             = (known after apply)
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m image_uri                      = "xxxxx.dkr.ecr.us-west-2.amazonaws.com/infinite-pi/xxx:latest"
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m invoke_arn                     = (known after apply)
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m last_modified                  = (known after apply)
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m memory_size                    = 512
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m package_type                   = "Image"
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m publish                        = false
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m qualified_arn                  = (known after apply)
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m qualified_invoke_arn           = (known after apply)
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m region                         = "us-west-2"
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m reserved_concurrent_executions = -1
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m role                           = "arn:aws:iam::xxxxx:role/xxx-lambda-role"
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m signing_job_arn                = (known after apply)
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m signing_profile_version_arn    = (known after apply)
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m skip_destroy                   = false
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m source_code_hash               = (known after apply)
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m source_code_size               = (known after apply)
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m tags_all                       = {
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m "Environment"     = "Production"
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m "ManagedBy"       = "Terraform"
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m "SpendAllocation" = "Infrastructure"
2025-11-02 18:11:05,905 | }
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m timeout                        = 30
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m version                        = (known after apply)
2025-11-02 18:11:05,905 | 
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m environment {
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m variables = {
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m "AWS_REGION" = "us-west-2"
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m "SecretName" = "prod/xxx/api-key"
2025-11-02 18:11:05,905 | }
2025-11-02 18:11:05,905 | }
2025-11-02 18:11:05,905 | 
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m ephemeral_storage (known after apply)
2025-11-02 18:11:05,905 | 
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m logging_config (known after apply)
2025-11-02 18:11:05,905 | 
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m tracing_config (known after apply)
2025-11-02 18:11:05,905 | }
2025-11-02 18:11:05,905 | 
2025-11-02 18:11:05,905 | �[1m  # aws_lambda_function_url.xxx�[0m will be created
2025-11-02 18:11:05,905 | �[0m  �[32m+�[0m�[0m resource "aws_lambda_function_url" "xxx" {
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m authorization_type = "NONE"
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m function_arn       = (known after apply)
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m function_name      = "xxx"
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m function_url       = (known after apply)
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m id                 = (known after apply)
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m invoke_mode        = "BUFFERED"
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m region             = "us-west-2"
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m url_id             = (known after apply)
2025-11-02 18:11:05,905 | 
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m cors {
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m allow_credentials = true
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m allow_headers     = [
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m "*",
2025-11-02 18:11:05,905 | ]
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m allow_methods     = [
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m "*",
2025-11-02 18:11:05,905 | ]
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m allow_origins     = [
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m "*",
2025-11-02 18:11:05,905 | ]
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m max_age           = 86400
2025-11-02 18:11:05,905 | }
2025-11-02 18:11:05,905 | }
2025-11-02 18:11:05,905 | 
2025-11-02 18:11:05,905 | �[1m  # null_resource.sam_metadata_aws_lambda_function_xxx_image�[0m will be created
2025-11-02 18:11:05,905 | �[0m  �[32m+�[0m�[0m resource "null_resource" "sam_metadata_aws_lambda_function_xxx_image" {
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m id       = (known after apply)
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m triggers = {
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m "docker_context" = "/Users/satishtripathi/Documents/infinitePi-io/xxx"
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m "docker_file"    = "Dockerfile"
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m "docker_tag"     = "latest"
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m "resource_name"  = "aws_lambda_function.xxx"
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m "resource_type"  = "IMAGE_LAMBDA_FUNCTION"
2025-11-02 18:11:05,905 | }
2025-11-02 18:11:05,905 | }
2025-11-02 18:11:05,905 | 
2025-11-02 18:11:05,905 | �[1mPlan:�[0m 7 to add, 0 to change, 0 to destroy.
2025-11-02 18:11:05,905 | �[0m
2025-11-02 18:11:05,905 | Changes to Outputs:
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m cloudwatch_log_group = "/aws/lambda/xxx"
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m lambda_function_arn  = (known after apply)
2025-11-02 18:11:05,905 | �[32m+�[0m�[0m lambda_function_name = "xxx"
2025-11-02 18:11:05,906 | �[32m+�[0m�[0m lambda_function_url  = (known after apply)
2025-11-02 18:11:05,906 | �[90m
2025-11-02 18:11:05,906 | ─────────────────────────────────────────────────────────────────────────────�[0m
2025-11-02 18:11:05,906 | 
2025-11-02 18:11:05,906 | Saved the plan to:
2025-11-02 18:11:05,906 | /var/folders/ps/26c8bwr92dz8zxcq7jcfkj780000gn/T/tmpo7hr_4cf
2025-11-02 18:11:05,906 | 
2025-11-02 18:11:05,906 | To perform exactly these actions, run the following command to apply:
2025-11-02 18:11:05,906 | tofu apply "/var/folders/ps/26c8bwr92dz8zxcq7jcfkj780000gn/T/tmpo7hr_4cf"
2025-11-02 18:11:07,443 | Generating metadata file
2025-11-02 18:11:07,443 | Mapping Lambda functions to their corresponding layers.
2025-11-02 18:11:07,443 | Parsing module:` root
2025-11-02 18:11:07,443 | Parsing module variables
2025-11-02 18:11:07,444 | Parsing module resources
2025-11-02 18:11:07,444 | Skip processing the attribute image_scanning_configuration as its value is a map.
2025-11-02 18:11:07,444 | Skip processing the attribute environment as its value is a map.
2025-11-02 18:11:07,444 | Skip processing the attribute cors as its value is a map.
2025-11-02 18:11:07,444 | Parsing module outputs
2025-11-02 18:11:07,444 | Parsing module calls
2025-11-02 18:11:07,444 | Mapping S3 object sources to corresponding functions
2025-11-02 18:11:07,444 | There is no sam metadata resources, no enrichment or Makefile is required
2025-11-02 18:11:07,444 | Finished generating metadata file. Storing in /Users/satishtripathi/Documents/infinitePi-io/xxx/iac/.aws-sam-iacs/iacs_metadata/template.json
2025-11-02 18:11:07,444 | Metadata file location - /Users/satishtripathi/Documents/infinitePi-io/xxx/iac/.aws-sam-iacs/iacs_metadata/template.json
2025-11-02 18:11:07,444 | Prepare hook completed and metadata file generated at: /Users/satishtripathi/Documents/infinitePi-io/xxx/iac/.aws-sam-iacs/iacs_metadata/template.json
2025-11-02 18:11:07,445 | Using SAM Template at /Users/satishtripathi/Documents/infinitePi-io/xxx/iac/.aws-sam-iacs/iacs_metadata/template.json
2025-11-02 18:11:07,486 | OSError occurred while reading TOML file: [Errno 2] No such file or directory: '/Users/satishtripathi/Documents/infinitePi-io/xxx/iac/.aws-sam-iacs/iacs_metadata/samconfig.toml'
2025-11-02 18:11:07,487 | Using config file: samconfig.toml, config environment: default
2025-11-02 18:11:07,487 | Expand command line arguments to:
2025-11-02 18:11:07,487 | --template_file=/Users/satishtripathi/Documents/infinitePi-io/xxx/iac/.aws-sam-iacs/iacs_metadata/template.json --hook_name=terraform --mount_with=READ --build_dir=.aws-sam/build --cache_dir=.aws-sam/cache 
2025-11-02 18:11:07,529 | 'build' command is called
2025-11-02 18:11:07,529 | No Parameters detected in the template
2025-11-02 18:11:07,538 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2025-11-02 18:11:07,584 | No container socket path in global storage, falling back to DOCKER_HOST detection: 
2025-11-02 18:11:07,584 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2025-11-02 18:11:07,585 | Unable to find Click Context for getting session_id.
2025-11-02 18:11:07,585 | No container socket path in global storage, falling back to DOCKER_HOST detection: 
2025-11-02 18:11:07,585 | Sending Telemetry: {'metrics': [{'events': {'requestId': '66ed6124-28e2-46d1-abb2-e3ff4e1f230e', 'installationId': '74fb7237-97ae-417a-9d9a-834a8372bc9e', 'sessionId': 'e8fd0fba-18eb-4ca3-9dd5-3b74feb7fc33', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.11.10', 'samcliVersion': '1.145.2', 'osPlatform': 'Darwin', 'commandName': 'sam build', 'metricSpecificAttributes': {'events': [{'event_name': 'SamConfigFileExtension', 'event_value': '.toml', 'thread_id': '0e42b0b49b43443abf5b4f80867b073f', 'time_stamp': '2025-11-02 12:40:58.087771+00', 'exception_name': None}, {'event_name': 'SamConfigFileExtension', 'event_value': '.toml', 'thread_id': '128e70df7b594975a431882285e5ccef', 'time_stamp': '2025-11-02 12:41:07.487545+00', 'exception_name': None}], 'containerEngine': 'docker-default'}}}]}
2025-11-02 18:11:07,585 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId': '6290c2f4-3073-498f-9dfc-375eb8624834', 'installationId': '74fb7237-97ae-417a-9d9a-834a8372bc9e', 'sessionId': 'e8fd0fba-18eb-4ca3-9dd5-3b74feb7fc33', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.11.10', 'samcliVersion': '1.145.2', 'osPlatform': 'Darwin', 'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam build', 'metricSpecificAttributes': {'projectType': 'Terraform', 'hookPackageId': 'terraform', 'hookPackageVersion': '1.0.0', 'gitOrigin': None, 'projectName': 'e914d68f72dbeaa29a91a4c2f9f3108f4cc6f4630a3712982fee13cfb45169fe', 'initialCommit': None, 'containerEngine': 'docker-default', 'adminContainerPreference': None}, 'duration': 51, 'exitReason': 'InvalidSamDocumentException', 'exitCode': 255}}]}
2025-11-02 18:11:08,269 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
2025-11-02 18:11:08,300 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
Error: [InvalidTemplateException("'Resources' section is required")] 'Resources' section is required
Traceback:
  File "click/core.py", line 1082, in main
  File "click/core.py", line 1697, in invoke
  File "click/core.py", line 1443, in invoke
  File "click/core.py", line 788, in invoke
  File "samcli/cli/cli_config_file.py", line 366, in wrapper
  File "click/decorators.py", line 92, in new_func
  File "click/core.py", line 788, in invoke
  File "samcli/lib/telemetry/metric.py", line 190, in wrapped
  File "samcli/lib/telemetry/metric.py", line 155, in wrapped
  File "samcli/lib/utils/version_checker.py", line 43, in wrapped
  File "samcli/cli/main.py", line 95, in wrapper
  File "samcli/commands/build/command.py", line 172, in cli
  File "samcli/commands/build/command.py", line 239, in do_cli
  File "samcli/commands/build/build_context.py", line 189, in __enter__
  File "samcli/commands/build/build_context.py", line 195, in set_up
  File "samcli/lib/providers/sam_stack_provider.py", line 270, in get_stacks
  File "samcli/lib/providers/sam_stack_provider.py", line 62, in __init__
  File "samcli/lib/providers/sam_base_provider.py", line 193, in get_template
  File "samcli/lib/samlib/wrapper.py", line 75, in run_plugins
An unexpected error was encountered while executing "sam build".
Search for an existing issue:
https://github.com/aws/aws-sam-cli/issues?q=is%3Aissue+is%3Aopen+Bug%3A%20sam%20build%20-%20InvalidSamDocumentException
Or create a bug report:
https://github.com/aws/aws-sam-cli/issues/new?template=Bug_report.md&title=Bug%3A%20sam%20build%20-%20InvalidSamDocumentException
 - No working examples of IMAGE_LAMBDA_FUNCTION exist in aws-samples/aws-sam-terraform-examples
  - The terraform-aws-modules/lambda module only creates ZIP_LAMBDA_FUNCTION metadata, not IMAGE
Metadata
Metadata
Assignees
Labels
stage/needs-triageAutomatically applied to new issues and PRs, indicating they haven't been looked at.Automatically applied to new issues and PRs, indicating they haven't been looked at.