Skip to content

Commit

Permalink
Merge pull request #4 from depot/auto-upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobwgillespie authored Nov 21, 2022
2 parents 30bd393 + b94c01c commit ae19ba9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ data "aws_region" "current" {}
# Locals

locals {
version = "1.1.1"
version = "1.1.1"
service-name = "depot-connection-${var.connection-id}-cloud-agent"
}

# VPC
Expand Down Expand Up @@ -350,6 +351,13 @@ resource "aws_iam_role" "cloud-agent" {
}
},

{
Action = ["ecs:ListTasks", "ecs:DescribeTasks", "ecs:StopTask"],
Effect = "Allow",
Resource = ["*"],
Condition = { ArnEquals = { "ecs:cluster" = aws_ecs_cluster.cloud-agent[0].arn } }
},

{
Action = ["iam:PassRole"]
Effect = "Allow"
Expand Down Expand Up @@ -393,7 +401,9 @@ resource "aws_ecs_task_definition" "cloud-agent" {
{ name = "CLOUD_AGENT_AWS_SG_BUILDKIT", value = aws_security_group.instance-buildkit[0].id },
{ name = "CLOUD_AGENT_AWS_SG_DEFAULT", value = aws_security_group.instance-default[0].id },
{ name = "CLOUD_AGENT_AWS_SUBNET_ID", value = aws_subnet.public[0].id },
{ name = "CLOUD_AGENT_CLUSTER_ARN", value = aws_ecs_cluster.cloud-agent[0].arn },
{ name = "CLOUD_AGENT_CONNECTION_ID", value = var.connection-id },
{ name = "CLOUD_AGENT_SERVICE_NAME", value = local.service-name },
{ name = "CLOUD_AGENT_TF_MODULE_VERSION", value = local.version },

# This environment variable is unused, but causes ECS to redeploy if the connection token changes
Expand All @@ -415,7 +425,7 @@ resource "aws_ecs_task_definition" "cloud-agent" {

resource "aws_ecs_service" "cloud-agent" {
count = var.create ? 1 : 0
name = "depot-connection-${var.connection-id}-cloud-agent"
name = local.service-name
cluster = aws_ecs_cluster.cloud-agent[0].id
task_definition = aws_ecs_task_definition.cloud-agent[0].arn
desired_count = 1
Expand Down
2 changes: 1 addition & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ variable "availability-zone" {
variable "cloud-agent-version" {
type = string
description = "Version tag for ghcr.io/depot/cloud-agent container"
default = "2.2.2"
default = "2"
}

variable "create" {
Expand Down

0 comments on commit ae19ba9

Please sign in to comment.