Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
dwilkie committed Jul 27, 2023
1 parent f08f24e commit 3de65ad
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 5 deletions.
14 changes: 9 additions & 5 deletions infrastructure/modules/container_instances/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,19 @@ resource "aws_iam_role_policy_attachment" "ssm" {

# Launch Template
resource "aws_launch_template" "this" {
name_prefix = var.app_identifier
image_id = jsondecode(data.aws_ssm_parameter.this_ami.value).image_id
instance_type = data.aws_ec2_instance_type.this.instance_type
name_prefix = var.app_identifier
image_id = jsondecode(data.aws_ssm_parameter.this_ami.value).image_id
instance_type = data.aws_ec2_instance_type.this.instance_type

iam_instance_profile {
name = aws_iam_instance_profile.this.name
}

vpc_security_group_ids = concat([aws_security_group.this.id], var.security_groups)
network_interfaces {
associate_public_ip_address = var.associate_public_ip_address
security_groups = concat([aws_security_group.this.id], var.security_groups)
}

user_data = base64encode(join("\n", [
"#cloud-config",
yamlencode({
Expand Down Expand Up @@ -115,7 +119,7 @@ resource "aws_autoscaling_group" "this" {
}

vpc_zone_identifier = var.instance_subnets
max_size = 10
max_size = var.max_capacity
min_size = 0
desired_capacity = 0
wait_for_capacity_timeout = 0
Expand Down
4 changes: 4 additions & 0 deletions infrastructure/modules/container_instances/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ variable "security_groups" {
default = []
}

variable associate_public_ip_address {
default = false
}

variable "user_data" {
type = list(
object(
Expand Down
2 changes: 2 additions & 0 deletions infrastructure/modules/somleng_switch/client_gateway.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ module client_gateway_container_instances {
app_identifier = var.client_gateway_identifier
vpc = var.vpc
instance_subnets = var.vpc.public_subnets
associate_public_ip_address = true
max_capacity = var.client_gateway_max_tasks * 2
cluster_name = aws_ecs_cluster.cluster.name
security_groups = [var.db_security_group]
user_data = var.assign_client_gateway_eips ? [
Expand Down
1 change: 1 addition & 0 deletions infrastructure/modules/somleng_switch/media_proxy.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module media_proxy_container_instances {
app_identifier = var.media_proxy_identifier
vpc = var.vpc
instance_subnets = var.vpc.public_subnets
associate_public_ip_address = true
cluster_name = aws_ecs_cluster.cluster.name
max_capacity = var.media_proxy_max_tasks * 2
user_data = var.assign_media_proxy_eips ? [
Expand Down
1 change: 1 addition & 0 deletions infrastructure/modules/somleng_switch/public_gateway.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module public_gateway_container_instances {
app_identifier = var.public_gateway_identifier
vpc = var.vpc
instance_subnets = var.vpc.private_subnets
max_capacity = var.public_gateway_max_tasks * 2
cluster_name = aws_ecs_cluster.cluster.name
}

Expand Down
1 change: 1 addition & 0 deletions infrastructure/modules/somleng_switch/switch.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module switch_container_instances {
vpc = var.vpc
instance_subnets = var.vpc.private_subnets
cluster_name = aws_ecs_cluster.cluster.name
max_capacity = var.switch_max_tasks * 2
}

resource "aws_ecs_capacity_provider" "switch" {
Expand Down

0 comments on commit 3de65ad

Please sign in to comment.