最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

amazon web services - awscc Terraform provider changing the lambda file structure on terraform apply - Stack Overflow

programmeradmin1浏览0评论

I am simply trying to deploy a sample awscc lambda function using the code as below - reference-

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"
        }
      },
    ]
  })
}

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.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论