This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
terraform { | |
required_providers { | |
aws = { | |
source = "hashicorp/aws" | |
version = "~> 3.46.0" | |
} | |
random = { | |
source = "hashicorp/random" | |
version = "~> 3.1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
output "wordpress_admin_password" { | |
description = "The Wordpress admin password" | |
value = random_string.wordpress_admin_password.result | |
sensitive = true | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_iam_role" "ecs_task_execution_role" { | |
name = "ecs-execution-role" | |
assume_role_policy = <<EOF | |
{ | |
"Version": "2008-10-17", | |
"Statement": [ | |
{ | |
"Sid": "", | |
"Effect": "Allow", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
locals { | |
name = "${var.tags["environment"]}-${var.tags["project"]}" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable "tags" { | |
type = map(string) | |
description = "(Required) Tags for resources" | |
} | |
variable "region" { | |
type = string | |
description = "(Required) AWS region" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable "tags" { | |
type = map(string) | |
description = "(Required) Tags for resources" | |
} | |
variable "region" { | |
type = string | |
description = "(Required) AWS region" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
terraform { | |
required_providers { | |
aws = { | |
source = "hashicorp/aws" | |
version = "~> 3.45.0" | |
} | |
} | |
} | |
provider "aws" { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
output "cluster_id" { | |
description = "The ECS cluster ID" | |
value = aws_ecs_cluster.default.id | |
} | |
output "cloudwatch_group_name" { | |
description = "The Cloudwatch group name to store container logs" | |
value = aws_cloudwatch_log_group.default.name | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_ecs_cluster" "default" { | |
name = local.name | |
tags = merge({ | |
name = local.name | |
}, var.tags) | |
} | |
resource "aws_cloudwatch_log_group" "default" { | |
name = local.name | |
tags = merge({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
locals { | |
name = "${var.tags["environment"]}-${var.tags["project"]}-ecs" | |
} |