diff --git a/terraform/ecs_capacity_provider.tf b/terraform/ecs_capacity_provider.tf index 84e6d58..321c993 100644 --- a/terraform/ecs_capacity_provider.tf +++ b/terraform/ecs_capacity_provider.tf @@ -1,5 +1,5 @@ resource "aws_ecs_capacity_provider" "customProvider" { - name = "CustomEC2Provider" + name = var.capacity_provider_name auto_scaling_group_provider { auto_scaling_group_arn = aws_autoscaling_group.ASG_config.arn @@ -15,12 +15,12 @@ resource "aws_ecs_capacity_provider" "customProvider" { resource "aws_ecs_cluster_capacity_providers" "Provider_config" { cluster_name = aws_ecs_cluster.fastapi-cluster.name - capacity_providers = ["CustomEC2Provider"] + capacity_providers = [var.capacity_provider_name] default_capacity_provider_strategy { base = 1 weight = 100 - capacity_provider = "CustomEC2Provider" + capacity_provider = var.capacity_provider_name } } diff --git a/terraform/env/dev.tfvars b/terraform/env/dev.tfvars index d92cda1..7484a1e 100644 --- a/terraform/env/dev.tfvars +++ b/terraform/env/dev.tfvars @@ -3,4 +3,5 @@ secondary_region = "us-east-1" env = "dev" repo_name = "dev/irezd/fastapi" ecs_service_name = "dev-fastapi-service" -fqdn = "test.fastapi.dennisowie.com" \ No newline at end of file +fqdn = "test.fastapi.dennisowie.com" +capacity_provider_name = "CustomEC2Provider" \ No newline at end of file diff --git a/terraform/env/prod.tfvars b/terraform/env/prod.tfvars index 3dc5655..faccc4d 100644 --- a/terraform/env/prod.tfvars +++ b/terraform/env/prod.tfvars @@ -3,4 +3,5 @@ secondary_region = "us-east-1" env = "prod" repo_name = "irezd/fastapi" ecs_service_name = "fastapi-service" -fqdn = "fastapi.dennisowie.com" \ No newline at end of file +fqdn = "fastapi.dennisowie.com" +capacity_provider_name = "EC2Provider" \ No newline at end of file diff --git a/terraform/variables.tf b/terraform/variables.tf index 10ac0e1..86ed846 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -56,4 +56,8 @@ variable "ami_id" { variable "instance_type" { description = "Instance type for EC2" default = "t2.micro" +} + +variable "capacity_provider_name" { + description = "Name of EC2 capacity provider for ECS container" } \ No newline at end of file