-
Notifications
You must be signed in to change notification settings - Fork 6
/
lambda-template.yaml
138 lines (130 loc) · 3.92 KB
/
lambda-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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
---
AWSTemplateFormatVersion: 2010-09-09
Description: 'Lambda resources'
Parameters:
NameTag:
Type: String
Resources:
VPCPeeringRole:
Type: 'AWS::IAM::Role'
Properties:
RoleName: 'VPCPeeringRole'
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
AWS:
- !Sub '${AWS::AccountId}'
Action: sts:AssumeRole
Path: '/'
ManagedPolicyArns:
- !Sub 'arn:${AWS::Partition}:iam::aws:policy/ReadOnlyAccess'
Policies:
- PolicyName: AmazonEC2Policy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- 'ec2:AcceptVpcPeeringConnection'
- 'ec2:CreateRoute'
- 'ec2:Deleteroute'
- 'ec2:CreateTags'
- 'ec2:DeleteTags'
- 'ec2:RevokeSecurityGroup*'
- 'ec2:UpdateSecurityGroup*'
- 'ec2:AuthorizeSecurityGroup*'
Resource: '*'
CustomResourceLambdaRole:
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action: 'sts:AssumeRole'
Principal:
Service: lambda.amazonaws.com
ManagedPolicyArns:
- !Sub 'arn:${AWS::Partition}:iam::aws:policy/ReadOnlyAccess'
- !Sub 'arn:${AWS::Partition}:iam::aws:policy/AWSBackupAdminPolicy'
Policies:
- PolicyName: AmazonPCAPolicy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action: 'acm-pca:*'
Resource: '*'
- PolicyName: AmazonBackupPolicy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action: 'iam:PassRole'
Resource: !Sub 'arn:${AWS::Partition}:iam::${AWS::AccountId}:role/service-role/AWSBackupDefaultServiceRole'
- PolicyName: AmazonCloudWatchPolicy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- 'logs:CreateLogGroup'
- 'logs:CreateLogStream'
- 'logs:PutLogEvents'
Resource: !Sub 'arn:${AWS::Partition}:logs:*:*:*'
- PolicyName: AmazonEC2Policy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- 'ec2:*ClientVpn*'
Resource: '*'
- PolicyName: AmazonCognitoPolicy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- 'cognito-idp:*UserPool*'
- 'cognito-idp:*ResourceServer'
- 'cognito-idp:*IdentityProvider'
Resource: '*'
- PolicyName: AmazonSTSPolicy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- 'sts:AssumeRole'
- 'sts:PassRole'
Resource:
- !Sub 'arn:${AWS::Partition}:iam::${AWS::AccountId}:role/VPCPeeringRole'
CustomResourceLambda:
Type: 'AWS::Lambda::Function'
Properties:
FunctionName: 'generic-custom-resource-provider'
Handler: generic_provider.lambda_handler
Code: 'generic_provider/build'
Runtime: python3.7
Role: !Sub '${CustomResourceLambdaRole.Arn}'
Description: 'CloudFormation custom generic resource provider.'
Timeout: 900
Environment:
# debug, set to 0 or remove in production
Variables:
VERBOSE: 1
Tags:
- Key: Name
Value: !Sub '${NameTag}'
Outputs:
StackName:
Value: !Sub '${AWS::StackName}'
Export:
Name: !Sub 'StackName-${AWS::StackName}'
CustomResourceLambdaArn:
Value: !Sub '${CustomResourceLambda.Arn}'
Export:
Name: !Sub 'CustomResourceLambdaArn-${AWS::StackName}'