Is there a way to deploy an AWS Elastic Beanstalk Node.js application based on a local ZIP file with Terraform?
All examples I have seen are S3 based.
Here is my code so far:
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"
}
CodePudding user response:
Is there a way to deploy an AWS Elastic Beanstalk Node.js application based on a local ZIP file with Terraform?
No, this is not supported by Terraform currently.
The aws_elastic_beanstalk_application_version
Terraform resource is the resource that is used to point to the application source bundle.
It only takes in bucket
& key
as the S3 bucket name and S3 object name parameters respectively for defining the source.
bucket
- (Required) S3 bucket that contains the Application Version source bundle.
key
- (Required) S3 object that is the Application Version source bundle.
It does not support defining a local path.