Skip to content

Commit

Permalink
feat!: add_common_capabilities (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
mfroembgen authored Jul 26, 2023
1 parent 2da6583 commit 850e210
Show file tree
Hide file tree
Showing 17 changed files with 564 additions and 275 deletions.
102 changes: 59 additions & 43 deletions README.md

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions alb.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module "alb_ingress" {
count = length(var.alb_name) > 0 ? 1 : 0
source = "cloudposse/alb-ingress/aws"
version = "0.25.1"

label_order = var.label_orders.ec2

context = module.this.context
vpc_id = data.aws_vpc.default.id
target_type = "instance"

unauthenticated_priority = var.alb_unauthenticated_priority
unauthenticated_paths = var.alb_unauthenticated_paths
unauthenticated_hosts = var.alb_unauthenticated_hosts
unauthenticated_listener_arns = [data.aws_lb_listener.http[0].arn, data.aws_lb_listener.https[0].arn]

health_check_path = var.alb_health_check_path
health_check_matcher = var.alb_health_check_matcher
health_check_interval = var.alb_health_check_interval

stickiness_enabled = var.alb_stickiness_enabled
}
22 changes: 11 additions & 11 deletions autoscaling.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ locals {
}

module "cloudwatch_label" {
source = "cloudposse/label/null"
version = "0.25.0"
source = "justtrackio/label/null"
version = "0.26.0"

delimiter = "/"
label_order = var.label_orders.cloudwatch
Expand All @@ -34,12 +34,12 @@ module "cloudwatch_label" {
module "ecs_service_task_predefined_autoscaling" {
count = local.predefined_autoscaling_enabled ? 1 : 0
source = "justtrackio/ecs-autoscaling/aws"
version = "1.0.0"
version = "1.1.0"

context = module.this.context

aws_account_id = var.aws_account_id
cluster_name = var.ecs_cluster_name
aws_account_id = module.this.aws_account_id
cluster_name = data.aws_ecs_cluster.default.cluster_name
service_name = module.this.id
enabled = var.autoscaling_enabled
min_capacity = var.autoscaling_min_capacity
Expand All @@ -63,12 +63,12 @@ module "ecs_service_task_predefined_autoscaling" {
module "ecs_service_task_customized_autoscaling" {
count = local.customized_autoscaling_enabled ? 1 : 0
source = "justtrackio/ecs-autoscaling/aws"
version = "1.0.0"
version = "1.1.0"

context = module.this.context

aws_account_id = var.aws_account_id
cluster_name = var.ecs_cluster_name
aws_account_id = module.this.aws_account_id
cluster_name = data.aws_ecs_cluster.default.cluster_name
service_name = module.this.id
enabled = var.autoscaling_enabled
min_capacity = var.autoscaling_min_capacity
Expand All @@ -94,12 +94,12 @@ module "ecs_service_task_customized_autoscaling" {
module "ecs_service_task_schedule" {
count = var.autoscaling_enabled && length(var.autoscaling_schedule) > 0 ? 1 : 0
source = "justtrackio/ecs-autoscaling/aws"
version = "1.0.0"
version = "1.1.0"

context = module.this.context

aws_account_id = var.aws_account_id
cluster_name = var.ecs_cluster_name
aws_account_id = module.this.aws_account_id
cluster_name = data.aws_ecs_cluster.default.cluster_name
service_name = module.this.id
enabled = var.autoscaling_enabled
schedule = var.autoscaling_schedule
Expand Down
39 changes: 37 additions & 2 deletions data.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module "ssm_label" {
source = "cloudposse/label/null"
version = "0.25.0"
source = "justtrackio/label/null"
version = "0.26.0"

delimiter = "/"
label_order = var.label_orders.ssm
Expand All @@ -22,3 +22,38 @@ data "aws_ssm_parameter" "container_tag" {
count = var.app_image_tag == null ? 1 : 0
name = "/${module.ssm_label.id}/container_tag"
}

data "aws_ecs_cluster" "default" {
cluster_name = module.this.environment
}

data "aws_ssm_parameter" "sentry_token" {
name = "/sentry/token"
}

data "aws_vpc" "default" {
tags = {
account_name = "${module.this.organizational_unit}-${module.this.namespace}"
}
}

data "aws_ssm_parameter" "grafana_token" {
name = "/grafana/token"
}

data "aws_lb" "default" {
count = length(var.alb_name) > 0 ? 1 : 0
name = "${module.this.environment}-${var.alb_name}"
}

data "aws_lb_listener" "http" {
count = length(var.alb_name) > 0 ? 1 : 0
load_balancer_arn = data.aws_lb.default[0].arn
port = 80
}

data "aws_lb_listener" "https" {
count = length(var.alb_name) > 0 ? 1 : 0
load_balancer_arn = data.aws_lb.default[0].arn
port = 443
}
50 changes: 50 additions & 0 deletions ecr.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
module "ecr_label" {
source = "justtrackio/label/null"
version = "0.26.0"

label_order = var.label_orders.ecr
delimiter = "/"

context = module.this.context
}

module "ecr" {
source = "terraform-aws-modules/ecr/aws"
version = "1.6.0"

repository_name = module.ecr_label.id
tags = module.ecr_label.tags

attach_repository_policy = false
repository_image_scan_on_push = false
repository_image_tag_mutability = "MUTABLE"
repository_force_delete = true
repository_lifecycle_policy = jsonencode({
rules = [
{
rulePriority = 1,
description = "Remove untagged images",
selection = {
countNumber = 1
countType = "imageCountMoreThan"
tagStatus = "untagged"
},
action = {
type = "expire"
}
},
{
rulePriority = 2,
description = "Keep last 30 images",
selection = {
tagStatus = "any",
countType = "imageCountMoreThan",
countNumber = 30
},
action = {
type = "expire"
}
}
]
})
}
28 changes: 0 additions & 28 deletions examples/basic/main.tf

This file was deleted.

Empty file removed examples/basic/outputs.tf
Empty file.
3 changes: 0 additions & 3 deletions examples/basic/providers.tf

This file was deleted.

Empty file removed examples/basic/variables.tf
Empty file.
9 changes: 0 additions & 9 deletions examples/basic/versions.tf

This file was deleted.

Loading

0 comments on commit 850e210

Please sign in to comment.