-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrepository.tf
More file actions
37 lines (33 loc) · 954 Bytes
/
repository.tf
File metadata and controls
37 lines (33 loc) · 954 Bytes
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
// This is a bit odd - we're creating a repository for every environment
// We need to find a better way to do this
resource "aws_ecr_repository" "this" {
name = local.resource_name
tags = local.tags
image_tag_mutability = "IMMUTABLE"
force_delete = true
encryption_configuration {
encryption_type = "KMS"
kms_key = aws_kms_key.this.arn
}
image_scanning_configuration {
scan_on_push = true
}
}
resource "aws_ecr_repository_policy" "this" {
policy = data.aws_iam_policy_document.ecr_lambda_access.json
repository = aws_ecr_repository.this.name
}
data "aws_iam_policy_document" "ecr_lambda_access" {
statement {
sid = "LambdaECRImageRetrievalPolicy"
effect = "Allow"
principals {
identifiers = ["lambda.amazonaws.com"]
type = "Service"
}
actions = [
"ecr:BatchGetImage",
"ecr:GetDownloadUrlForLayer"
]
}
}