Skip to content

Commit

Permalink
Merge pull request #189 from cloudnativedaysjp/stg_harvestjob
Browse files Browse the repository at this point in the history
add resources for harvestjob (scheduled task) in stg
  • Loading branch information
jacopen authored Oct 26, 2024
2 parents 1ed464f + 5bbaeb8 commit 629ccb6
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 7 deletions.
75 changes: 68 additions & 7 deletions dreamkast_infra/dev/ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,29 @@ resource "aws_iam_role" "task-execution-role" {
#}
}

# for ECS scheduled task
resource "aws_iam_role" "ecs-scheduled-task-target-role" {
name = "${var.prj_prefix}-ecs-scheduled-task-target-role"

assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = "sts:AssumeRole"
Effect = "Allow"
Sid = ""
Principal = {
Service = "events.amazonaws.com"
}
}
]
})

managed_policy_arns = [
data.aws_iam_policy.AmazonEC2ContainerServiceEventsRole.arn
]
}

# ------------------------------------------------------------#
# for dreamkast
# ------------------------------------------------------------#
Expand Down Expand Up @@ -263,13 +286,13 @@ resource "aws_iam_role" "ecs-dreamkast-fifo-worker" {
"ssm:AddTagsToResource",
"ssm:DeleteParameters",
"ssm:DescribeParameters",
"ssm:GetParameter",
"ssm:GetParameterHistory",
"ssm:GetParameters",
"ssm:GetParametersByPath"
],
Resource = "*"
},
"ssm:GetParameter",
"ssm:GetParameterHistory",
"ssm:GetParameters",
"ssm:GetParametersByPath"
],
Resource = "*"
},
{
Effect = "Allow"
Action = [
Expand Down Expand Up @@ -496,3 +519,41 @@ resource "aws_security_group" "ecs-mysql" {
# Environment = "${var.prj_prefix}"
#}
}

# ------------------------------------------------------------#
# for harvestjob
# ------------------------------------------------------------#
resource "aws_iam_role" "ecs-harvestjob" {
name = "${var.prj_prefix}-ecs-harvestjob"

assume_role_policy = data.aws_iam_policy_document.assume_role_policy_ecs.json

managed_policy_arns = [
data.aws_iam_policy.AmazonSSMManagedInstanceCore.arn,
data.aws_iam_policy.AmazonS3FullAccess.arn,
data.aws_iam_policy.AWSElementalMediaPackageFullAccess.arn,
data.aws_iam_policy.AWSElementalMediaPackageV2FullAccess.arn,
]

#tags = {
# Environment = "${var.prj_prefix}"
#}
}

resource "aws_security_group" "ecs-harvestjob" {
name = "${var.prj_prefix}-ecs-harvestjob"
vpc_id = module.vpc.vpc_id

ingress = []
egress {
description = "allow all"
protocol = "all"
from_port = 0
to_port = 0
cidr_blocks = ["0.0.0.0/0"]
}

#tags = {
# Environment = "${var.prj_prefix}"
#}
}
4 changes: 4 additions & 0 deletions dreamkast_infra/dev/iam_policies.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ data "aws_iam_policy" "AmazonEC2ContainerRegistryReadOnly" {
arn = "arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly"
}

data "aws_iam_policy" "AmazonEC2ContainerServiceEventsRole" {
arn = "arn:aws:iam::aws:policy/service-role/AmazonEC2ContainerServiceEventsRole"
}

data "aws_iam_policy" "AmazonEKSWorkerNodePolicy" {
arn = "arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy"
}
Expand Down

0 comments on commit 629ccb6

Please sign in to comment.