Skip to content
This repository has been archived by the owner on Jan 6, 2020. It is now read-only.

Initial app-cluster module development. #1

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Local .terraform directories
**/.terraform/*

# .tfstate files
*.tfstate
*.tfstate.*

**/.idea/*
.idea
.idea/workspace.xml
14 changes: 14 additions & 0 deletions configuration/app_ecs_service_role.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"Version": "2008-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": [
"ecs.amazonaws.com"
]
},
"Effect": "Allow"
}
]
}
95 changes: 95 additions & 0 deletions configuration/app_ecs_task_definition_magento2.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
[
{
"name": "magento2",
"image": "${data.aws_ecr_repository.magento2.repository_url}",
"mountPoints": [
{
"containerPath": "/var/www/html/pub/media",
"sourceVolume": "media",
"readOnly": null
}
],
"essential": true,
"environment": [
{
"name": "ENVIRONMENT",
"value": "${terraform.workspace}"
},
{
"name": "MAGE_MODE",
"value": "production"
},
{
"name": "CACHE_PREFIX",
"value": "1_"
},
{
"name": "MYSQL_HOST",
"value": "${aws_route53_record.db.fqdn}"
},
{
"name": "MYSQL_DATABASE",
"value": "${var.env_mysql_database}"
},
{
"name": "MYSQL_USER",
"value": "${var.env_mysql_user}"
},
{
"name": "MYSQL_PASSWORD",
"value": "${lookup(var.rds_password, terraform.workspace)}"
},
{
"name": "REDIS_CACHE_HOST",
"value": "${aws_route53_record.redis_cache.fqdn}"
},
{
"name": "REDIS_SESSION_HOST",
"value": "${aws_route53_record.redis_session.fqdn}"
}
],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "${terraform.workspace}-app",
"awslogs-region": "us-east-1",
"awslogs-stream-prefix": "magento2"
}
},
"cpu": 0,
"memoryReservation": 768
},
{
"name": "nginx",
"volumesFrom": [
{
"readOnly": true,
"sourceContainer": "magento2"
}
],
"portMappings": [
{
"hostPort": 80,
"containerPort": 80,
"protocol": "tcp"
}
],
"essential": true,
"environment": [],
"links": [
"magento2:phpfpm"
],
"image": "${data.aws_ecr_repository.nginx.repository_url}",
"command": [],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "${terraform.workspace}-app",
"awslogs-region": "us-east-1",
"awslogs-stream-prefix": "nginx"
}
},
"cpu": 0,
"memoryReservation": 512
}
]
13 changes: 13 additions & 0 deletions configuration/app_ecs_task_role.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"Service": "ecs-tasks.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
14 changes: 14 additions & 0 deletions configuration/ecs_autoscale_role.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": [
"application-autoscaling.amazonaws.com"
]
},
"Effect": "Allow"
}
]
}
15 changes: 15 additions & 0 deletions configuration/ecs_role.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"Version": "2008-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": [
"ecs.amazonaws.com",
"ec2.amazonaws.com"
]
},
"Effect": "Allow"
}
]
}
15 changes: 15 additions & 0 deletions configuration/logs-policy.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"Id": "${var.project_name}-${terraform.workspace}-logs-policy",
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1484671540333",
"Action": "s3:PutObject",
"Effect": "Allow",
"Resource": "arn:aws:s3:::${var.project_name}-${terraform.workspace}-logs/*",
"Principal": {
"AWS": "arn:aws:iam::${lookup(var.default_log_account_ids, var.aws_region)}:root"
}
}
]
}
Empty file.
Empty file.
14 changes: 14 additions & 0 deletions modules/app-cluster/aws/ecs-service/app_ecs_service_role.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"Version": "2008-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": [
"ecs.amazonaws.com"
]
},
"Effect": "Allow"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
[
{
"name": "magento2",
"image": "${data.aws_ecr_repository.magento2.repository_url}",
"mountPoints": [
{
"containerPath": "/var/www/html/pub/media",
"sourceVolume": "media",
"readOnly": null
}
],
"essential": true,
"environment": [
{
"name": "ENVIRONMENT",
"value": "${terraform.workspace}"
},
{
"name": "MAGE_MODE",
"value": "production"
},
{
"name": "CACHE_PREFIX",
"value": "1_"
},
{
"name": "MYSQL_HOST",
"value": "${aws_route53_record.db.fqdn}"
},
{
"name": "MYSQL_DATABASE",
"value": "${var.env_mysql_database}"
},
{
"name": "MYSQL_USER",
"value": "${var.env_mysql_user}"
},
{
"name": "MYSQL_PASSWORD",
"value": "${lookup(var.rds_password, terraform.workspace)}"
},
{
"name": "REDIS_CACHE_HOST",
"value": "${aws_route53_record.redis_cache.fqdn}"
},
{
"name": "REDIS_SESSION_HOST",
"value": "${aws_route53_record.redis_session.fqdn}"
}
],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "${terraform.workspace}-app",
"awslogs-region": "us-east-1",
"awslogs-stream-prefix": "magento2"
}
},
"cpu": 0,
"memoryReservation": 768
},
{
"name": "nginx",
"volumesFrom": [
{
"readOnly": true,
"sourceContainer": "magento2"
}
],
"portMappings": [
{
"hostPort": 80,
"containerPort": 80,
"protocol": "tcp"
}
],
"essential": true,
"environment": [],
"links": [
"magento2:phpfpm"
],
"image": "${data.aws_ecr_repository.nginx.repository_url}",
"command": [],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "${terraform.workspace}-app",
"awslogs-region": "us-east-1",
"awslogs-stream-prefix": "nginx"
}
},
"cpu": 0,
"memoryReservation": 512
}
]
13 changes: 13 additions & 0 deletions modules/app-cluster/aws/ecs-service/app_ecs_task_role.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"Service": "ecs-tasks.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
14 changes: 14 additions & 0 deletions modules/app-cluster/aws/ecs-service/ecs_autoscale_role.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": [
"application-autoscaling.amazonaws.com"
]
},
"Effect": "Allow"
}
]
}
15 changes: 15 additions & 0 deletions modules/app-cluster/aws/ecs-service/ecs_role.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"Version": "2008-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": [
"ecs.amazonaws.com",
"ec2.amazonaws.com"
]
},
"Effect": "Allow"
}
]
}
15 changes: 15 additions & 0 deletions modules/app-cluster/aws/ecs-service/logs-policy.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"Id": "${var.project_name}-${terraform.workspace}-logs-policy",
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1484671540333",
"Action": "s3:PutObject",
"Effect": "Allow",
"Resource": "arn:aws:s3:::${var.project_name}-${terraform.workspace}-logs/*",
"Principal": {
"AWS": "arn:aws:iam::${lookup(var.default_log_account_ids, var.aws_region)}:root"
}
}
]
}
Loading