forked from awslabs/amazon-bedrock-agentcore-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathecr.tf
More file actions
63 lines (55 loc) · 1.46 KB
/
ecr.tf
File metadata and controls
63 lines (55 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# ============================================================================
# ECR Repository - Container Registry for Agent Image
# ============================================================================
resource "aws_ecr_repository" "agent_ecr" {
name = "${var.stack_name}-${var.ecr_repository_name}"
image_tag_mutability = "MUTABLE"
image_scanning_configuration {
scan_on_push = true
}
force_delete = true
tags = {
Name = "${var.stack_name}-ecr-repository"
Module = "ECR"
}
}
# ECR Repository Policy
resource "aws_ecr_repository_policy" "agent_ecr" {
repository = aws_ecr_repository.agent_ecr.name
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Sid = "AllowPullFromAccount"
Effect = "Allow"
Principal = {
AWS = "arn:aws:iam::${data.aws_caller_identity.current.id}:root"
}
Action = [
"ecr:BatchGetImage",
"ecr:GetDownloadUrlForLayer"
]
}
]
})
}
# ECR Lifecycle Policy - Keep last 5 images
resource "aws_ecr_lifecycle_policy" "agent_ecr" {
repository = aws_ecr_repository.agent_ecr.name
policy = jsonencode({
rules = [
{
rulePriority = 1
description = "Keep last 5 images"
selection = {
tagStatus = "any"
countType = "imageCountMoreThan"
countNumber = 5
}
action = {
type = "expire"
}
}
]
})
}