我可以使用 Terraform 从本地 ZIP 文件而不是 S3 对象部署 Elastic Beanstalk 应用程序吗?

Can I deploy an Elastic Beanstalk application from a local ZIP file not a S3 object with Terraform?

有没有办法使用 Terraform 基于本地 ZIP 文件部署 AWS Elastic Beanstalk Node.js 应用程序?

我看到的所有示例都是基于 S3 的。

到目前为止,这是我的代码:

resource "aws_iam_policy" "nodejs" {
  name = "NodeJSPolicy"
  policy = file("policy.json")
}

resource "aws_iam_role" "nodejs" {
  name = "iam_for_lambda"
  assume_role_policy = file("assumerole.json")
}

resource "aws_iam_role_policy_attachment" "nodejs" {
  policy_arn = aws_iam_policy.nodejs.arn
  role = aws_iam_role.nodejs.name
}

data "archive_file" "package"{
  type = "zip"
  source_file = "../app"
  output_path = "../build/package.zip"
}

resource "aws_elastic_beanstalk_application" "nodejs" {
  name = "nodejs-app"
  description = "Noodle JP Application"
}

resource "aws_elastic_beanstalk_application_version" "nodejs" {
  name = "v0.01"
  application = aws_elastic_beanstalk_application.nodejs.name
  //**??????? HOW CAN I HAVE THE SOURCE HERE?**
}

resource "aws_elastic_beanstalk_environment" "nodejs" {
  application = aws_elastic_beanstalk_application.nodejs.name
  name = "noodle-jp"
  solution_stack_name = "Node.js 14 AL2 version 5.4.6"
}

Is there a way to deploy an AWS Elastic Beanstalk Node.js application based on a local ZIP file with Terraform?

不,Terraform 目前不支持此功能。

aws_elastic_beanstalk_application_version Terraform 资源是用于指向应用程序源包的资源。

只接受bucket&key分别作为S3 bucket name和S3 object name参数定义source

bucket - (Required) S3 bucket that contains the Application Version source bundle.

key - (Required) S3 object that is the Application Version source bundle.

不支持定义本地路径