-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathcloudformation.py
45 lines (35 loc) · 1.18 KB
/
cloudformation.py
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
from troposphere import Template, Ref, Output
import troposphere_dns_certificate.certificatemanager as certificatemanager
def create_template():
template = Template(
Description='DNS Validated ACM Certificate Example'
)
template.set_version()
certificate = template.add_resource(certificatemanager.Certificate(
'ExampleCertificate',
ValidationMethod='DNS',
CertificateAuthorityArn='asdvc',
DomainName='test.example.com',
DomainValidationOptions=[
certificatemanager.DomainValidationOption(
DomainName='test.example.com',
HostedZoneId='Z2KZ5YTUFZNC7H'
)
],
Tags=[{
'Key': 'Name',
'Value': 'Example Certificate'
}]
))
template.add_output(Output(
'CertificateARN',
Value=Ref(certificate),
Description='The ARN of the example certificate'
))
return template
if __name__ == '__main__':
template = create_template()
with open('cloudformation.yaml', 'w') as f:
f.write(template.to_yaml())
with open('cloudformation.json', 'w') as f:
f.write(template.to_json(indent=4))