AWS 시작템플릿(LaunchTemplate) 이란?
AWS::EC2::LaunchTemplate
CloudFormation로,
LaunchTemplate 생성
Description: A sample template
Resources:
MyEC2Template:
Type: AWS::EC2::LaunchTemplate
Properties:
LaunchTemplateName: MyEC2Template
LaunchTemplateData:
BlockDeviceMappings:
- DeviceName: "/dev/xvda"
Ebs:
DeleteOnTermination: 'true'
VolumeSize: 8
VolumeType: gp2
ImageId: ami-0ba5cd124d7a79612(기본 우분투 이미지 아이디)
InstanceType: t2.micro
KeyName: 본인 키페어 이름
SecurityGroupIds:
- 본인 보안그룹 아이디
UserData:
Fn::Base64: !Sub |
#!/bin/bash
apt-get -y update
apt-get install -y apache2
systemctl start apache2
Description: A sample template
Resources:
MyEC2Template:
Type: AWS::EC2::LaunchTemplate
Properties:
LaunchTemplateName: MyEC2Template
LaunchTemplateData:
BlockDeviceMappings:
- DeviceName: "/dev/xvda"
Ebs:
DeleteOnTermination: 'true'
VolumeSize: 8
VolumeType: gp2
ImageId: ami-0ba5cd124d7a79612
InstanceType: t2.micro
KeyName: 본인 키페어 이름
SecurityGroupIds:
- 본인 보안그룹 아이디
UserData:
Fn::Base64: !Sub |
#!/bin/bash
apt-get -y update
apt-get install -y apache2
systemctl start apache2
#### #### #### 요기 아래 추가 #### #### ####
MyEC2Instance:
Type: "AWS::EC2::Instance"
DependsOn: MyEC2Template
Properties:
LaunchTemplate:
LaunchTemplateName: MyEC2Template
Version: !GetAtt MyEC2Template.LatestVersionNumber
Version: !GetAtt MyEC2Template.LatestVersionNumber
![[AWS] CloudFormation으로 시작 템플릿(Launch Template) 만들기](/posts/aws-cloudformation-launch-template/images/image_1.jpg)