-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcfn-template.yaml
88 lines (78 loc) · 2.44 KB
/
cfn-template.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
AWSTemplateFormatVersion: 2010-09-09
Description: "Pipeline to build boto3 Lambda Layer."
Parameters:
LayerName:
Type: String
Description: Name of the project.
Default: "boto3"
Resources:
# -- CodeCommit repository
CodeCommitRepo:
Type: AWS::CodeCommit::Repository
Properties:
RepositoryDescription: !Sub "Repository for ${LayerName} Lambda Layer"
RepositoryName: !Sub "${LayerName}-lambda-layer-${AWS::AccountId}"
CodebuildRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Action:
- sts:AssumeRole
Effect: Allow
Principal:
Service:
- codebuild.amazonaws.com
Path: /
Policies:
- PolicyName: DefaultCodeBuildPolicy0
PolicyDocument:
Version: 2012-10-17
Statement:
- Resource: "*"
Effect: Allow
Action:
- codebuild:StartBuild
- Resource: !Sub "arn:aws:codecommit:${AWS::Region}:${AWS::AccountId}:${CodeCommitRepo}"
Effect: Allow
Action:
- codecommit:GitPull
- Resource: "*"
Effect: Allow
Action:
- lambda:DeleteLayerVersion
- lambda:GetLayerVersion
- lambda:ListLayers
- lambda:PublishLayerVersion
- lambda:RemoveLayerVersionPermission
- Resource: "*"
Effect: Allow
Action:
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:PutLogEvents
# -- Codebuild Project
CodeBuildProject:
Type: AWS::CodeBuild::Project
Properties:
Artifacts:
Type: NO_ARTIFACTS
Description: !Sub "${LayerName} Lambda Layer build"
Environment:
ComputeType: BUILD_GENERAL1_SMALL
Image: aws/codebuild/standard:1.0
Type: LINUX_CONTAINER
LogsConfig:
CloudWatchLogs:
Status: ENABLED
Name: !Sub "${LayerName}-lambda-layer-build"
ServiceRole: !Ref CodebuildRole
Source:
Location: !GetAtt CodeCommitRepo.CloneUrlHttp
Type: CODECOMMIT
TimeoutInMinutes: 5
Outputs:
CodeCommitUrlHttp:
Description: Codecommit repository url (http)
Value: !GetAtt CodeCommitRepo.CloneUrlHttp