Skip to content

Commit ae19ba9

Browse files
Merge pull request #4 from depot/auto-upgrade
2 parents 30bd393 + b94c01c commit ae19ba9

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

main.tf

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ data "aws_region" "current" {}
66
# Locals
77

88
locals {
9-
version = "1.1.1"
9+
version = "1.1.1"
10+
service-name = "depot-connection-${var.connection-id}-cloud-agent"
1011
}
1112

1213
# VPC
@@ -350,6 +351,13 @@ resource "aws_iam_role" "cloud-agent" {
350351
}
351352
},
352353

354+
{
355+
Action = ["ecs:ListTasks", "ecs:DescribeTasks", "ecs:StopTask"],
356+
Effect = "Allow",
357+
Resource = ["*"],
358+
Condition = { ArnEquals = { "ecs:cluster" = aws_ecs_cluster.cloud-agent[0].arn } }
359+
},
360+
353361
{
354362
Action = ["iam:PassRole"]
355363
Effect = "Allow"
@@ -393,7 +401,9 @@ resource "aws_ecs_task_definition" "cloud-agent" {
393401
{ name = "CLOUD_AGENT_AWS_SG_BUILDKIT", value = aws_security_group.instance-buildkit[0].id },
394402
{ name = "CLOUD_AGENT_AWS_SG_DEFAULT", value = aws_security_group.instance-default[0].id },
395403
{ name = "CLOUD_AGENT_AWS_SUBNET_ID", value = aws_subnet.public[0].id },
404+
{ name = "CLOUD_AGENT_CLUSTER_ARN", value = aws_ecs_cluster.cloud-agent[0].arn },
396405
{ name = "CLOUD_AGENT_CONNECTION_ID", value = var.connection-id },
406+
{ name = "CLOUD_AGENT_SERVICE_NAME", value = local.service-name },
397407
{ name = "CLOUD_AGENT_TF_MODULE_VERSION", value = local.version },
398408

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

416426
resource "aws_ecs_service" "cloud-agent" {
417427
count = var.create ? 1 : 0
418-
name = "depot-connection-${var.connection-id}-cloud-agent"
428+
name = local.service-name
419429
cluster = aws_ecs_cluster.cloud-agent[0].id
420430
task_definition = aws_ecs_task_definition.cloud-agent[0].arn
421431
desired_count = 1

variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ variable "availability-zone" {
2121
variable "cloud-agent-version" {
2222
type = string
2323
description = "Version tag for ghcr.io/depot/cloud-agent container"
24-
default = "2.2.2"
24+
default = "2"
2525
}
2626

2727
variable "create" {

0 commit comments

Comments
 (0)