Skip to content

Commit

Permalink
Use CloudFront properly
Browse files Browse the repository at this point in the history
  • Loading branch information
takano32 committed Feb 22, 2024
1 parent 25a5d42 commit 6036711
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 21 deletions.
2 changes: 1 addition & 1 deletion cloudfront.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module "acm" {

resource "aws_cloudfront_distribution" "this" {
origin {
domain_name = var.public_alb_domain
domain_name = module.alb.lb_dns_name
origin_id = "alb"

custom_origin_config {
Expand Down
26 changes: 7 additions & 19 deletions fargate.tf
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ resource "aws_security_group" "wordpress" {
}

resource "aws_ecs_service" "this" {
name = "${var.prefix}-${var.environment}"
cluster = aws_ecs_cluster.this.id
task_definition = aws_ecs_task_definition.this.arn
desired_count = var.desired_count
launch_type = "FARGATE"
name = "${var.prefix}-${var.environment}"
cluster = aws_ecs_cluster.this.id
task_definition = aws_ecs_task_definition.this.arn
desired_count = var.desired_count
launch_type = "FARGATE"
network_configuration {
security_groups = [aws_security_group.alb.id, aws_security_group.db.id, aws_security_group.efs.id]
subnets = module.vpc.private_subnets
Expand Down Expand Up @@ -167,11 +167,11 @@ resource "aws_ecs_task_definition" "this" {
memory = var.task_memory

runtime_platform {
cpu_architecture = "ARM64" # Indicate Graviton2 processor architecture
cpu_architecture = "ARM64" # Indicate Graviton2 processor architecture
operating_system_family = "LINUX"
}

container_definitions = <<CONTAINER_DEFINITION
container_definitions = <<CONTAINER_DEFINITION
[
{
"secrets": [
Expand Down Expand Up @@ -354,15 +354,3 @@ resource "aws_appautoscaling_policy" "scale_down" {
}
}
}

resource "aws_route53_record" "wordpress" {
zone_id = data.aws_route53_zone.this.zone_id
name = var.public_alb_domain
type = "A"

alias {
name = module.alb.lb_dns_name
zone_id = module.alb.lb_zone_id
evaluate_target_health = true
}
}
1 change: 0 additions & 1 deletion route53.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ resource "aws_route53_record" "ipv4" {
zone_id = aws_cloudfront_distribution.this.hosted_zone_id
evaluate_target_health = false
}
allow_overwrite = true
}

# Add an IPv6 DNS record pointing to the CloudFront distribution
Expand Down

0 comments on commit 6036711

Please sign in to comment.