I am simply trying to deploy a sample awscc lambda function using the code as below - reference- Terraform Registry
my main.tf-
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0
terraform {
required_version = ">= 0.12"
}
provider "aws" {
region = var.aws_region
}
provider "awscc" {
region = var.aws_region
}
resource "awscc_iam_role" "main" {
description = "AWS IAM role for lambda function"
assume_role_policy_document = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = "sts:AssumeRole"
Effect = "Allow"
Sid = ""
Principal = {
Service = "lambda.amazonaws.com"
}
},
]
})
}
data "archive_file" "main" {
type = "zip"
source_file = "main.py"
output_path = "lambda_function_payload.zip"
}
resource "awscc_lambda_function" "main" {
function_name = "lambda_function_name"
description = "AWS Lambda function"
code = {
zip_file = data.archive_file.main.output_path
}
package_type = "Zip"
handler = "main.lambda_handler"
runtime = "python3.10"
timeout = "300"
memory_size = "128"
role = awscc_iam_role.main.arn
architectures = ["arm64"]
}
The lambda creates and runs fine when I use inline code in my main.tf. but I want to be able to use a zip file that is located in the same folder as my main.tf. As soon as I do terraform apply and my lambda gets created, I see in the lambda console that the file is now -
is there any solution or workaround for this?
(lambda_function_payload.zip is the name of my zipfile that is in the same folder as main.tf. It only contains one file which is main.py)
I want to be able to deploy the lambda using the zip file using the awscc provider. I tried the same thing using the aws provider and it works file.