# awscc Terraform provider changing the lambda file structure on terraform apply

**URL:** <https://discuss.hashicorp.com/t/awscc-terraform-provider-changing-the-lambda-file-structure-on-terraform-apply/73006>\
**Category:** Terraform\
**Created:** [February 3, 2025, 6:17pm UTC](https://discuss.hashicorp.com/t/awscc-terraform-provider-changing-the-lambda-file-structure-on-terraform-apply/73006 "2025-02-03T18:17:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kajaldhanotia1997](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/kajaldhanotia1997/32/44681_2.png) [@kajaldhanotia1997](https://discuss.hashicorp.com/u/kajaldhanotia1997)\
**Post date:** [February 3, 2025, 6:17pm UTC](https://discuss.hashicorp.com/t/awscc-terraform-provider-changing-the-lambda-file-structure-on-terraform-apply/73006/1 "2025-02-03T18:17:22Z")

</div>

I am simply trying to deploy a sample awscc lambda function using the code as below - reference- [Terraform Registry](https://registry.terraform.io/providers/hashicorp/awscc/latest/docs/resources/lambda_function#basic-example)

my main.tf-

```auto
# 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?

 ![image](https://global.discourse-cdn.com/hashicorp/original/3X/1/d/1d5cde60fe4fedf8e954fcdeb3d31d4a8155a3f8.png)

(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.

---

<div class="post-metadata">

**Author:** ![quixoticmonk](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/quixoticmonk/32/33056_2.png) [@quixoticmonk](https://discuss.hashicorp.com/u/quixoticmonk)\
**Post date:** [February 4, 2025, 1:27am UTC](https://discuss.hashicorp.com/t/awscc-terraform-provider-changing-the-lambda-file-structure-on-terraform-apply/73006/2 "2025-02-04T01:27:38Z")

</div>

I think the zip\_file reference is incorrect. I will update that in a PR. The way I would handle this is via an S3 bucket reference.

```auto
data "archive_file" "main" {
  type = "zip"
  source_file = "index.py"
  output_path = "index.zip"
}
resource "awscc_s3_bucket" "lambda_assets" {
}

resource "aws_s3_object" "zip" {
  source = data.archive_file.main.output_path
  bucket = awscc_s3_bucket.lambda_assets.id
  key = "index.zip"
}

resource "awscc_lambda_function" "main" {
  function_name = "main"
  description = "AWS Lambda function"
  code = {
    s3_bucket = awscc_s3_bucket.lambda_assets.id
    s3_key = aws_s3_object.zip.key
  }
  package_type = "Zip"
  handler = "index.handler"
  runtime = "python3.10"
  timeout = "300"
  memory_size = "128"
  role = awscc_iam_role.main.arn
  architectures = ["arm64"]
}

```

---

<div class="post-metadata">

**Author:** ![kajaldhanotia1997](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/kajaldhanotia1997/32/44681_2.png) [@kajaldhanotia1997](https://discuss.hashicorp.com/u/kajaldhanotia1997)\
**Post date:** [February 4, 2025, 1:39am UTC](https://discuss.hashicorp.com/t/awscc-terraform-provider-changing-the-lambda-file-structure-on-terraform-apply/73006/3 "2025-02-04T01:39:39Z")

</div>

Okay, so you mean to say that the way I can create the zipfile within the main.tf and reference it in lambda ‘code’ in the aws terraform provider, I cannot do the same way here?

---

<div class="post-metadata">

**Author:** ![quixoticmonk](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/quixoticmonk/32/33056_2.png) [@quixoticmonk](https://discuss.hashicorp.com/u/quixoticmonk)\
**Post date:** [February 4, 2025, 3:22am UTC](https://discuss.hashicorp.com/t/awscc-terraform-provider-changing-the-lambda-file-structure-on-terraform-apply/73006/4 "2025-02-04T03:22:16Z")

</div>

That is right. The zip\_file on the service schema refers to `zipping an inline code reference to upload to lambda` compared to the aws provider.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/hashicorp/original/1X/79bf76adfd92a75631996933098f9ce29d37abf3.svg) [@system](https://discuss.hashicorp.com/u/system)\
**Post date:** [August 3, 2025, 3:23am UTC](https://discuss.hashicorp.com/t/awscc-terraform-provider-changing-the-lambda-file-structure-on-terraform-apply/73006/5 "2025-08-03T03:23:13Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
