-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlaunchTemplate.yaml
More file actions
53 lines (48 loc) · 1.48 KB
/
launchTemplate.yaml
File metadata and controls
53 lines (48 loc) · 1.48 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
AWSTemplateFormatVersion: '2010-09-09'
Description: CloudFormation template for an EC2 Launch Template with t3.micro instance
Parameters:
InstanceType:
Description: EC2 instance type
Type: String
Default: t3.micro
AllowedValues:
- t3.micro
- t2.micro
ConstraintDescription: Must be a valid EC2 instance type.
AmiId:
Description: Amazon Machine Image ID for the instance (e.g., Amazon Linux 2)
Type: String
Default: ami-02801556a781a4499
Resources:
MySecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Allow SSH and HTTP access
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 22
ToPort: 22
CidrIp: 0.0.0.0/0 # Allow SSH from any IP
- IpProtocol: tcp
FromPort: 80
ToPort: 80
CidrIp: 0.0.0.0/0 # Allow HTTP from any IP
MyLaunchTemplate:
Type: AWS::EC2::LaunchTemplate
Properties:
LaunchTemplateName: MyLaunchTemplate
LaunchTemplateData:
InstanceType: !Ref InstanceType
# KeyName: !Ref KeyName
ImageId: !Ref AmiId
SecurityGroups:
- !Ref MySecurityGroup
TagSpecifications:
- ResourceType: instance
Tags:
- Key: Name
Value: LaunchTemplateInstance
Outputs:
LaunchTemplateID:
Description: ID of the created Launch Template
Value: !Ref MyLaunchTemplate