diff --git a/.gitignore b/.gitignore index 4f2675a..428afbd 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ scim.env *.deploy *.bak .idea/ +.terraform/ +terraform.tfstate +terraform.tfstate.backup \ No newline at end of file diff --git a/aws-terraform/ecs/task-definitions/scim.json b/aws-terraform/ecs/task-definitions/scim.json index fe27f1a..5f94211 100644 --- a/aws-terraform/ecs/task-definitions/scim.json +++ b/aws-terraform/ecs/task-definitions/scim.json @@ -17,13 +17,13 @@ "hostPort": 3002 } ], - "entrypoint": ["/op-scim/op-scim", "--redis-host=localhost", "--redis-port=6379"], + "entrypoint": ["/op-scim/op-scim", "--redis-host=localhost"], "environment": [ { "name": "OP_REDIS_URL", "value": "localhost" }, { "name": "OP_LETSENCRYPT_DOMAIN", "value": "" } ], "secrets": [ - {"name": "OP_SESSION", "valueFrom": "arn:aws:secretsmanager:us-east-1:729119775555:secret:amanda/scim-bridge/scimsession-ukalr5"} + {"name": "OP_SESSION", "valueFrom": "arn:aws:secretsmanager:us-east-1:729119775555:secret:ecs/scim-bridge/amanda-HF09CT"} ], "logConfiguration": { "logDriver": "awslogs", diff --git a/aws-terraform/ecs/terraform.tf b/aws-terraform/ecs/terraform.tf index 8795cee..1ac528a 100644 --- a/aws-terraform/ecs/terraform.tf +++ b/aws-terraform/ecs/terraform.tf @@ -1,6 +1,6 @@ provider "aws" { version = "~> 2.0" - region = "us-east-1" + region = var.region } resource "aws_ecs_cluster" "scim-bridge" { @@ -49,12 +49,10 @@ resource "aws_iam_role_policy" "scim_secret_policy" { { "Effect": "Allow", "Action": [ - "secretsmanager:GetSecretValue", - "ssm:GetParameters" + "secretsmanager:GetSecretValue" ], "Resource": [ - "arn:aws:secretsmanager:us-east-1:729119775555:secret:amanda/scim-bridge/scimsession-ukalr5", - "arn:aws:ssm:us-east-1:729119775555:parameter/*" + "${var.secret_arn}" ] } ] @@ -67,6 +65,7 @@ resource "aws_ecs_service" "scim_bridge_service" { cluster = aws_ecs_cluster.scim-bridge.id task_definition = aws_ecs_task_definition.scim-bridge.arn launch_type = "FARGATE" + platform_version = "1.4.0" desired_count = 1 depends_on = [aws_lb_listener.listener_https] @@ -76,12 +75,6 @@ resource "aws_ecs_service" "scim_bridge_service" { container_port = 3002 # Specifying the container port } - /*load_balancer { - target_group_arn = aws_lb_target_group.target_group_https.arn - container_name = aws_ecs_task_definition.scim-bridge.family - container_port = 8443 # Specifying the container port - }*/ - network_configuration { subnets = [aws_default_subnet.default_subnet_a.id, aws_default_subnet.default_subnet_b.id, aws_default_subnet.default_subnet_c.id] assign_public_ip = true # Providing our containers with public IPs @@ -154,17 +147,6 @@ resource "aws_lb_target_group" "target_group_http" { } } -/*resource "aws_lb_target_group" "target_group_https" { - name = "target-group-https" - port = 8443 - protocol = "HTTPS" - target_type = "ip" - vpc_id = aws_default_vpc.default_vpc.id # Referencing the default VPC - health_check { - matcher = "200,301,302" - path = "/" - } -}*/ resource "aws_lb_listener" "listener_https" { load_balancer_arn = aws_alb.scim-bridge-alb.arn # Referencing our load balancer port = 443 @@ -176,34 +158,24 @@ resource "aws_lb_listener" "listener_https" { } } -/*resource "aws_lb_listener" "listener_http" { - load_balancer_arn = aws_alb.scim-bridge-alb.arn # Referencing our load balancer - port = 80 - protocol = "HTTP" - default_action { - type = "forward" - target_group_arn = aws_lb_target_group.target_group_http.arn # Referencing our target group - } -}*/ - # Providing a reference to our default VPC resource "aws_default_vpc" "default_vpc" { } resource "aws_default_subnet" "default_subnet_a" { - availability_zone = "us-east-1a" + availability_zone = "${var.region}a" } resource "aws_default_subnet" "default_subnet_b" { - availability_zone = "us-east-1b" + availability_zone = "${var.region}b" } resource "aws_default_subnet" "default_subnet_c" { - availability_zone = "us-east-1c" + availability_zone = "${var.region}c" } resource "aws_acm_certificate" "scim_bridge_cert" { - domain_name = "scim-bridge-amanda.play.agilebits.net" + domain_name = var.domain_name validation_method = "DNS" lifecycle { @@ -225,12 +197,12 @@ resource "aws_route53_record" "scim_bridge_cert_validation" { records = [each.value.record] ttl = 60 type = each.value.type - zone_id = "Z3V3UMKDNQGJ7A" + zone_id = var.dns_zone_id } resource "aws_route53_record" "scim_bridge" { - zone_id = "Z3V3UMKDNQGJ7A" - name = "scim-bridge-amanda.play.agilebits.net" + zone_id = var.dns_zone_id + name = var.domain_name type = "A" alias { diff --git a/aws-terraform/ecs/terraform.tfvars b/aws-terraform/ecs/terraform.tfvars new file mode 100644 index 0000000..12e9aed --- /dev/null +++ b/aws-terraform/ecs/terraform.tfvars @@ -0,0 +1,4 @@ +domain_name = "scim-bridge-amanda.play.agilebits.net" +region = "us-east-1" +dns_zone_id = "Z3V3UMKDNQGJ7A" +secret_arn = "arn:aws:secretsmanager:us-east-1:729119775555:secret:ecs/scim-bridge/amanda-HF09CT" \ No newline at end of file diff --git a/aws-terraform/ecs/variables.tf b/aws-terraform/ecs/variables.tf new file mode 100644 index 0000000..eaf2ae3 --- /dev/null +++ b/aws-terraform/ecs/variables.tf @@ -0,0 +1,33 @@ +variable "region" { + type = string + description = "" + default = "us-east-1" +} + +variable "prefix" { + type = string + description = "" + default = "scim-bridge" +} + +variable "secret_arn" { + type = string + description = "" +} + +variable "domain_name" { + type = string + description = "" +} + +variable "dns_zone_id" { + type = string + description = "" + default = "Z3V3UMKDNQGJ7A" +} + +variable "aws_logs_group" { + type = string + description = "" + default = "/ecs/scim-bridge" +} \ No newline at end of file