-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcertbot-to-acm.yaml.in
146 lines (146 loc) · 5.58 KB
/
certbot-to-acm.yaml.in
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
139
140
141
142
143
144
145
146
AWSTemplateFormatVersion: "2010-09-09"
Mappings:
CertbotLayer:
ap-northeast-1:
python38: "@@{Versions.CertbotLayer.ap-northeast-1.python38}@@"
ap-northeast-2:
python38: "@@{Versions.CertbotLayer.ap-northeast-2.python38}@@"
ap-south-1:
python38: "@@{Versions.CertbotLayer.ap-south-1.python38}@@"
ap-southeast-1:
python38: "@@{Versions.CertbotLayer.ap-southeast-1.python38}@@"
ap-southeast-2:
python38: "@@{Versions.CertbotLayer.ap-southeast-2.python38}@@"
ca-central-1:
python38: "@@{Versions.CertbotLayer.ca-central-1.python38}@@"
eu-central-1:
python38: "@@{Versions.CertbotLayer.eu-central-1.python38}@@"
eu-north-1:
python38: "@@{Versions.CertbotLayer.eu-north-1.python38}@@"
eu-west-1:
python38: "@@{Versions.CertbotLayer.eu-west-1.python38}@@"
eu-west-2:
python38: "@@{Versions.CertbotLayer.eu-west-2.python38}@@"
eu-west-3:
python38: "@@{Versions.CertbotLayer.eu-west-3.python38}@@"
me-south-1:
python38: "@@{Versions.CertbotLayer.me-south-1.python38}@@"
sa-east-1:
python38: "@@{Versions.CertbotLayer.sa-east-1.python38}@@"
us-east-1:
python38: "@@{Versions.CertbotLayer.us-east-1.python38}@@"
us-east-2:
python38: "@@{Versions.CertbotLayer.us-east-2.python38}@@"
us-gov-east-1:
python38: "@@{Versions.CertbotLayer.us-gov-east-1.python38}@@"
us-gov-west-1:
python38: "@@{Versions.CertbotLayer.us-gov-west-1.python38}@@"
us-west-1:
python38: "@@{Versions.CertbotLayer.us-west-1.python38}@@"
us-west-2:
python38: "@@{Versions.CertbotLayer.us-west-2.python38}@@"
CertbotToACMFunctionZIP:
ap-northeast-1:
version: "@@{Versions.CertbotToACMFunctionZIP.ap-northeast-1.version}@@"
ap-northeast-2:
version: "@@{Versions.CertbotToACMFunctionZIP.ap-northeast-2.version}@@"
ap-south-1:
version: "@@{Versions.CertbotToACMFunctionZIP.ap-south-1.version}@@"
ap-southeast-1:
version: "@@{Versions.CertbotToACMFunctionZIP.ap-southeast-1.version}@@"
ap-southeast-2:
version: "@@{Versions.CertbotToACMFunctionZIP.ap-southeast-2.version}@@"
ca-central-1:
version: "@@{Versions.CertbotToACMFunctionZIP.ca-central-1.version}@@"
eu-central-1:
version: "@@{Versions.CertbotToACMFunctionZIP.eu-central-1.version}@@"
eu-north-1:
version: "@@{Versions.CertbotToACMFunctionZIP.eu-north-1.version}@@"
eu-west-1:
version: "@@{Versions.CertbotToACMFunctionZIP.eu-west-1.version}@@"
eu-west-2:
version: "@@{Versions.CertbotToACMFunctionZIP.eu-west-2.version}@@"
eu-west-3:
version: "@@{Versions.CertbotToACMFunctionZIP.eu-west-3.version}@@"
me-south-1:
version: "@@{Versions.CertbotToACMFunctionZIP.me-south-1.version}@@"
sa-east-1:
version: "@@{Versions.CertbotToACMFunctionZIP.sa-east-1.version}@@"
us-east-1:
version: "@@{Versions.CertbotToACMFunctionZIP.us-east-1.version}@@"
us-east-2:
version: "@@{Versions.CertbotToACMFunctionZIP.us-east-2.version}@@"
us-gov-east-1:
version: "@@{Versions.CertbotToACMFunctionZIP.us-gov-east-1.version}@@"
us-gov-west-1:
version: "@@{Versions.CertbotToACMFunctionZIP.us-gov-west-1.version}@@"
us-west-1:
version: "@@{Versions.CertbotToACMFunctionZIP.us-west-1.version}@@"
us-west-2:
version: "@@{Versions.CertbotToACMFunctionZIP.us-west-2.version}@@"
Resources:
CertbotToACMFunctionPolicy:
Type: "AWS::IAM::ManagedPolicy"
Properties:
Description: Allow certbot-to-acm to access ACM.
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- "acm:GetCertificate"
- "acm:ImportCertificate"
- "acm:ListCertificates"
- "route53:ListHostedZones"
- "route53:ListHostedZonesByName"
- "route53:GetHostedZone"
- "route53:GetChange"
- "route53:ChangeResourceRecordSets"
- "route53:ListResourceRecordSets"
- "s3:GetObjectAcl"
- "s3:PutObjectAcl"
- "s3:ListBucket"
- "ssm:GetParameter"
- "ssm:GetParameters"
- "ssm:GetParametersByPath"
- "ssm:PutParameter"
Resource: "*"
CertbotToACMFunctionRole:
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/AWSLambdaExecute"
- !Ref CertbotToACMFunctionPolicy
CertbotToACMFunction:
Type: "AWS::Lambda::Function"
Properties:
Code:
S3Bucket: !Sub "ionosphere-public-${AWS::Region}"
S3Key: "certbot-to-acm.zip"
S3ObjectVersion: !FindInMap [CertbotToACMFunctionZIP, !Ref "AWS::Region", version]
Description: Request a certificate from LetsEncrypt and store it in ACM.
Handler: index.lambda_handler
Layers:
- !FindInMap [CertbotLayer, {"Ref": "AWS::Region"}, python38]
MemorySize: 256
Role: !GetAtt CertbotToACMFunctionRole.Arn
Runtime: python3.8
Timeout: 300
CertbotToACMFunctionPermission:
Type: "AWS::Lambda::Permission"
Properties:
Action: "lambda:InvokeFunction"
FunctionName: !Ref CertbotToACMFunction
Principal: events.amazonaws.com
SourceAccount: !Ref "AWS::AccountId"
Outputs:
CertbotToACMFunctionName:
Value: !Ref CertbotToACMFunction