diff --git a/modules/aws_ec2_standalone/main.tf b/modules/aws_ec2_standalone/main.tf index 0cd4334..f88553d 100644 --- a/modules/aws_ec2_standalone/main.tf +++ b/modules/aws_ec2_standalone/main.tf @@ -9,6 +9,7 @@ terraform { provider "aws" { region = var.aws_region + alias = "provider-aws-ec2-standalone" } data "aws_ami" "this" { @@ -93,9 +94,13 @@ resource "aws_instance" "this" { cd retool-onpremise # Rewrite Dockerfile - echo FROM tryretool/backend:${var.version_number} > Dockerfile + echo FROM ${var.backend_image_name}:${var.version_number} > Dockerfile echo CMD ./docker_scripts/start_api.sh >> Dockerfile + # Rewrite CodeExecutor.Dockerfile + echo FROM ${var.code_executor_image_name}:${var.version_number} > CodeExecutor.Dockerfile + echo CMD bash start.sh >> CodeExecutor.Dockerfile + # Initialize Docker and Retool Installation ./install.sh @@ -103,3 +108,9 @@ resource "aws_instance" "this" { docker-compose up -d EOF } + +resource "aws_eip" "ec2_attached_elastic_ip" { + count = var.attach_eip ? 1 : 0 + instance = aws_instance.this.id + vpc = true +} \ No newline at end of file diff --git a/modules/aws_ec2_standalone/variables.tf b/modules/aws_ec2_standalone/variables.tf index 93045bb..1b4672a 100644 --- a/modules/aws_ec2_standalone/variables.tf +++ b/modules/aws_ec2_standalone/variables.tf @@ -16,12 +16,30 @@ variable "instance_name" { description = "EC2 instance name. Defaults to `retool`." } +variable "backend_image_name" { + type = string + default = "tryretool/backend" + description = "Docker Hub image name for the main backend image" +} + +variable "code_executor_image_name" { + type = string + default = "tryretool/code-executor-service" + description = "Docker Hub image name for the code executor image" +} + variable "version_number" { type = string default = "2.106.2" description = "Retool version number. Defaults to `2.106.2`." } +variable "code_executor_version_number" { + type = string + default = "2.106.2" + description = "Retool code executor version number. Defaults to `2.106.2`." +} + variable "vpc_id" { type = string default = null @@ -148,3 +166,8 @@ variable "egress_rules" { description = "Egress rules for EC2 security group" } +variable "attach_eip" { + type = bool + default = true + description = "Whether to attach an Elastic IP to the EC2 instance." +} \ No newline at end of file