-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsam.template
More file actions
70 lines (64 loc) · 2.45 KB
/
sam.template
File metadata and controls
70 lines (64 loc) · 2.45 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
64
65
66
67
68
69
70
AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31
Description: |
A Serverless Application that handles seeding a CodeCommit repository with the
contents of a public repository. In practice, it's effectively a fork to CC.
Metadata:
AWS::ServerlessRepo::Application:
Name: CopyRepoToCodeCommit
Description: This SAR app is designed for use in CloudFormation as a Custom Resource to copy the contents from a publicly-accessible Git repository to a CodeCommit repo. In practice, it's very similar to a fork of the repo to CodeCommit.
Author: Andy Hopper
SpdxLicenseId: MIT
ReadmeUrl: README.md
SemanticVersion: 1.0.3
SourceCodeUrl: https://github.com/andyhopp/copy-to-codecommit
Resources:
CodeCommitLambdaRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Sid: ''
Effect: Allow
Principal:
Service: lambda.amazonaws.com
Action: 'sts:AssumeRole'
ManagedPolicyArns: [ 'arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole' ]
Path: /
CodeCommitLambdaPolicy:
Type: AWS::IAM::Policy
Properties:
PolicyName: GrantAccessToCodeCommit
PolicyDocument:
Version: 2012-10-17
Statement:
- Action: [ 'codecommit:GetRepository', 'codecommit:CreateBranch', 'codecommit:GitPush' ]
Resource: '*'
Effect: Allow
- Action: [ 'codecommit:BatchGet*', 'codecommit:BatchDescribe*', 'codecommit:Get*', 'codecommit:Describe*', 'codecommit:List*', 'codecommit:GitPull' ]
Resource: '*'
Effect: Allow
Roles:
- Ref: CodeCommitLambdaRole
CopyToCodeCommit:
Type: AWS::Serverless::Function
DependsOn: [ CodeCommitLambdaRole, CodeCommitLambdaPolicy ]
Properties:
CodeUri: ./functions
Layers:
- !Sub arn:aws:lambda:${AWS::Region}:982831078337:layer:git:5
- !Sub arn:aws:lambda:${AWS::Region}:982831078337:layer:awscli:2
Description: Lambda to copy code from one Git repoitory to CodeCommit
Handler: handler.lambda_handler
MemorySize: 128
Role: !GetAtt CodeCommitLambdaRole.Arn
Runtime: python3.7
Timeout: 600
Outputs:
FunctionName:
Description: The name of the deployed function.
Value: !Ref CopyToCodeCommit
FunctionArn:
Description: The ARN of the deployed function.
Value: !GetAtt CopyToCodeCommit.Arn