-
Notifications
You must be signed in to change notification settings - Fork 13
/
template-ecr-buildimage.yaml
54 lines (51 loc) · 1.63 KB
/
template-ecr-buildimage.yaml
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
#
# This template creates the ECR Repo and perm needed for the Deployer's codebuild image.
# You are still required to build the image and push it to the repo built by this stack!
#
---
AWSTemplateFormatVersion: '2010-09-09'
Parameters:
RepositoryName:
Description: "The name and/or path you wish to give the ECR Repo. Leave blank if you want it auto-generated."
Type: String
Default: ""
Conditions:
HasRepoName: !Not [!Equals [!Ref RepositoryName, ""]]
Resources:
CFAutomationBuildImage:
Type: "AWS::ECR::Repository"
Properties:
RepositoryName: !If [HasRepoName, !Ref RepositoryName, !Ref "AWS::NoValue"]
RepositoryPolicyText:
Version: "2012-10-17"
Statement:
- Sid: CodeBuildAccess
Effect: Allow
Principal:
Service: "codebuild.amazonaws.com"
Action:
- "ecr:GetDownloadUrlForLayer"
- "ecr:BatchGetImage"
- "ecr:BatchCheckLayerAvailability"
LifecyclePolicy:
LifecyclePolicyText: |
{
"rules": [
{
"rulePriority": 1,
"description": "Expire untagged images older than 14 days",
"selection": {
"tagStatus": "untagged",
"countType": "sinceImagePushed",
"countUnit": "days",
"countNumber": 14
},
"action": {
"type": "expire"
}
}
]
}
Outputs:
CFAutomationBuildImage:
Value: !Ref CFAutomationBuildImage