-
Notifications
You must be signed in to change notification settings - Fork 3
ARC Mono Repo Test - ECS #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,4 +34,4 @@ | |
} | ||
} | ||
} | ||
] | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,23 @@ | ||
############################################### | ||
## imports | ||
################################################ | ||
## network | ||
data "aws_vpc" "vpc" { | ||
# network | ||
data "aws_vpc" "default" { | ||
filter { | ||
name = "tag:Name" | ||
values = ["${var.namespace}-${var.environment}-vpc"] | ||
values = var.vpc_name != null ? [var.vpc_name] : ["${var.namespace}-${var.environment}-vpc"] | ||
} | ||
} | ||
|
||
data "aws_subnets" "private" { | ||
filter { | ||
name = "tag:Name" | ||
|
||
## try the created subnets from the upstream network module, or override with custom names | ||
values = length(var.subnet_names) > 0 ? var.subnet_names : [ | ||
"${var.namespace}-${var.environment}-private-subnet-private-${var.region}a", | ||
"${var.namespace}-${var.environment}-private-subnet-private-${var.region}b" | ||
] | ||
} | ||
filter { | ||
name = "vpc-id" | ||
values = [data.aws_vpc.default.id] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
locals { | ||
security_group_name = "arc-alb-sg" | ||
|
||
ecs_cluster = { | ||
name = "arc-ecs-fargate-poc" | ||
create = true | ||
create_cloudwatch_log_group = true | ||
service_connect_defaults = {} | ||
settings = [] | ||
|
||
configuration = { | ||
execute_command_configuration = { | ||
logging = "OVERRIDE" | ||
log_configuration = { | ||
log_group_name = "arc-poc-cluster-log-group-fargate" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dont hardcode There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. corrections made |
||
} | ||
} | ||
} | ||
} | ||
|
||
capacity_provider = { | ||
autoscaling_capacity_providers = {} | ||
use_fargate = true | ||
fargate_capacity_providers = { | ||
fargate_cp = { | ||
name = "FARGATE" | ||
} | ||
} | ||
} | ||
ecs_service = { | ||
create = false | ||
} | ||
|
||
############################### ECS Services ################################ | ||
|
||
ecs_services = { | ||
service1 = { | ||
ecs_cluster = { | ||
create = false | ||
} | ||
ecs_service = { | ||
cluster_name = "arc-ecs-module-poc-1" | ||
service_name = "arc-ecs-module-service-poc-1" | ||
repository_name = "12345.dkr.ecr.us-east-1.amazonaws.com/arc/arc-poc-ecs" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please get account id from data block There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. corrections made |
||
ecs_subnets = data.aws_subnets.private.ids | ||
enable_load_balancer = true | ||
aws_lb_target_group_name = "arc-poc-alb-tg" | ||
create = true | ||
} | ||
|
||
task = { | ||
tasks_desired = 1 | ||
launch_type = "FARGATE" | ||
network_mode = "awsvpc" | ||
compatibilities = ["FARGATE"] | ||
container_port = 80 | ||
container_memory = 1024 | ||
container_vcpu = 256 | ||
container_definition = "container/container_definition.json.tftpl" | ||
} | ||
|
||
lb_data = { | ||
listener_port = 80 | ||
security_group_id = "sg-0eea352ca0628a2d1" | ||
} | ||
} | ||
} | ||
|
||
############################### Load Balancer Config ################################ | ||
|
||
load_balancer_config = { | ||
name = "arc-load-balancer" | ||
type = "application" | ||
enable_deletion_protection = false | ||
enable_cross_zone_load_balancing = true | ||
enable_http2 = false | ||
enable_xff_client_port = false | ||
enable_zonal_shift = false | ||
preserve_host_header = false | ||
enable_tls_version_and_cipher_suite_headers = false | ||
|
||
subnet_mapping = [ | ||
{ subnet_id = data.aws_subnets.private.ids[0] }, | ||
{ subnet_id = data.aws_subnets.private.ids[1] } | ||
] | ||
|
||
access_logs = { | ||
enabled = false | ||
bucket = "alb-logs" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dont hardcode There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. corrections made |
||
prefix = "alb-logs" | ||
} | ||
|
||
connection_logs = { | ||
enabled = false | ||
bucket = "connection-logs" | ||
prefix = "connection-logs" | ||
} | ||
} | ||
|
||
############################### Security Group Config ################################ | ||
|
||
security_group_data = { | ||
create = true | ||
description = "Security Group for alb" | ||
|
||
ingress_rules = [ | ||
{ | ||
description = "Allow VPC traffic" | ||
cidr_block = "0.0.0.0/0" # Ensure it's a string | ||
from_port = 443 | ||
ip_protocol = "tcp" | ||
to_port = 443 | ||
}, | ||
{ | ||
description = "Allow traffic from self" | ||
self = true | ||
from_port = 80 | ||
ip_protocol = "tcp" | ||
to_port = 80 | ||
} | ||
] | ||
|
||
egress_rules = [ | ||
{ | ||
description = "Allow all outbound traffic" | ||
cidr_block = "0.0.0.0/0" # Ensure it's a string | ||
from_port = 0 | ||
ip_protocol = "-1" | ||
to_port = 0 | ||
} | ||
] | ||
} | ||
|
||
############################### Target Group Config ################################ | ||
|
||
target_group_config = { | ||
name = "arc-poc-alb" | ||
port = 80 | ||
protocol = "HTTP" | ||
target_type = "ip" | ||
|
||
health_check = { | ||
enabled = true | ||
interval = 30 | ||
path = "/" | ||
port = 80 | ||
protocol = "HTTP" | ||
timeout = 5 | ||
unhealthy_threshold = 3 | ||
healthy_threshold = 2 | ||
matcher = "200" | ||
} | ||
} | ||
|
||
############################### Default ALB Action ################################ | ||
|
||
default_action = [ | ||
{ | ||
type = "forward" | ||
forward = { | ||
target_groups = [{ weight = 20 }] | ||
stickiness = { | ||
duration = 300 | ||
enabled = true | ||
} | ||
} | ||
} | ||
] | ||
|
||
############################### ALB Listener ################################ | ||
|
||
alb_listener = { | ||
port = 88 | ||
protocol = "HTTP" | ||
} | ||
|
||
############################### Listener Rules ################################ | ||
|
||
listener_rules = { | ||
rule2 = { | ||
priority = 999 | ||
actions = [ | ||
{ | ||
type = "fixed-response" | ||
order = 1 | ||
fixed_response = { | ||
status_code = "200" | ||
content_type = "text/plain" | ||
message_body = "OK" | ||
} | ||
} | ||
] | ||
conditions = [ | ||
{ | ||
path_pattern = { | ||
values = ["/status"] | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use env and namespace
${var.namespace}-${var.environment}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
corrections made