-
Notifications
You must be signed in to change notification settings - Fork 3
/
Example-AmazonLinux2ImageCustomResource.yaml
101 lines (101 loc) · 3.22 KB
/
Example-AmazonLinux2ImageCustomResource.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
AWSTemplateFormatVersion: 2010-09-09
Description: Example-AmazonLinux2ImageCustomResource Template.
This demonstrates how to dynamically get the most recent Amazon Linux 2 Image.
Parameters:
Region:
Description: Optional Region, specify to select a region other than the current region
Type: String
Default: ''
AllowedValues:
- ''
- us-east-1
- us-east-2
- us-west-1
- us-west-2
- ca-central-1
- eu-west-1
- eu-central-1
- eu-west-2
- eu-west-3
- ap-southeast-1
- ap-southeast-2
- ap-northeast-2
- ap-northeast-1
- ap-south-1
- sa-east-1
ConstraintDescription: Must be a valid AWS region or blank.
Version:
Description: Amazon Linux 2 Version
Type: String
Default: Amazon Linux 2.0
AllowedValues:
- ''
- Amazon Linux 2
- Amazon Linux 2.0
ConstraintDescription: Must be a valid Amazon Linux 2 version or blank.
Date:
Description: Optional Amazon Linux 2 Date, specify to select a specific publication date for the Image
Type: String
Default: 20181008
AllowedPattern: (^$|^20(1[8-9]|[2-9][0-9])(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|3[0-1])$)
ConstraintDescription: Must be a valid date or blank.
Conditions:
ConfigureRegion: !Not [ !Equals [ !Ref Region, '' ]]
ConfigureVersion: !Not [ !Equals [ !Ref Version, '' ]]
ConfigureDate: !Not [ !Equals [ !Ref Date, '' ]]
Resources:
LatestAmazonLinux2Image:
Type: Custom::AmazonLinux2Image
Properties:
ServiceToken: !Sub arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:AmazonLinux2Image
Region: !If
- ConfigureRegion
- !Ref Region
- !Ref AWS::NoValue
LatestVersionedAmazonLinux2Image:
Type: Custom::AmazonLinux2Image
Properties:
ServiceToken: !Sub arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:AmazonLinux2Image
Region: !If
- ConfigureRegion
- !Ref Region
- !Ref AWS::NoValue
OSName: !If
- ConfigureVersion
- !Ref Version
- !Ref AWS::NoValue
SpecificVersionedAmazonLinux2Image:
Type: Custom::AmazonLinux2Image
Properties:
ServiceToken: !Sub arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:AmazonLinux2Image
Region: !If
- ConfigureRegion
- !Ref Region
- !Ref AWS::NoValue
OSName: !If
- ConfigureVersion
- !Ref Version
- !Ref AWS::NoValue
OSDate: !If
- ConfigureDate
- !Ref Date
- !Ref AWS::NoValue
Outputs:
LatestImageId:
Description: The Latest ImageId
Value: !Ref LatestAmazonLinux2Image
LatestName:
Description: The Latest Image Name
Value: !GetAtt LatestAmazonLinux2Image.Name
LatestVersionedImageId:
Description: The Latest Versioned ImageId
Value: !Ref LatestVersionedAmazonLinux2Image
LatestVersionedName:
Description: The Latest Versioned Image Name
Value: !GetAtt LatestVersionedAmazonLinux2Image.Name
SpecificVersionedImageId:
Description: The Specific Versioned ImageId
Value: !Ref SpecificVersionedAmazonLinux2Image
SpecificVersionedName:
Description: The Specific Versioned Image Name
Value: !GetAtt SpecificVersionedAmazonLinux2Image.Name