AWS와 Azure 기반 하이브리드 멀티클라우드 DevOps/AWS
2025-12-03_스택에서 인스턴스 생성
dltjgus00
2025. 1. 3. 18:10
create.yml
더보기
Parameters:
KeyName:
Description: Name of an existing EC2 KeyPair to enable SSH access to the instances. Linked to AWS Parameter
Type: AWS::EC2::KeyPair::KeyName
ConstraintDescription: must be the name of an existing EC2 KeyPair.
Resources:
CloudNetVPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 10.0.0.0/16
Tags:
- Key: Name
Value: CloudNeta-VPC
CloudNetIGW:
Type: AWS::EC2::InternetGateway
Properties:
Tags:
- Key: Name
Value: CloudNeta-IGW
CloudNetaIGWAttachment:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
InternetGatewayId: !Ref CloudNetIGW
VpcId: !Ref CloudNetVPC
CloudNetaPublicRT:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref CloudNetVPC
Tags:
- Key: Name
Value: CloudNeta-Public-RT
DefaultPublicRoute:
Type: AWS::EC2::Route
DependsOn: CloudNetaIGWAttachment
Properties:
RouteTableId: !Ref CloudNetaPublicRT
DestinationCidrBlock: 0.0.0.0/0
GatewayId: !Ref CloudNetIGW
CloudNetaPublicSN1:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref CloudNetVPC
AvailabilityZone: !Select [ 0, !GetAZs '' ]
CidrBlock: 10.0.0.0/24
Tags:
- Key: Name
Value: CloudNeta-Public-SN-1
CloudNetaPublicSNRouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
RouteTableId: !Ref CloudNetaPublicRT
SubnetId: !Ref CloudNetaPublicSN1
CloudNetaSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Enable HTTP access via port 80 and SSH access via port 22
VpcId: !Ref CloudNetVPC
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 80
ToPort: 80
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: 22
ToPort: 22
CidrIp: 0.0.0.0/0
- IpProtocol: icmp
FromPort: -1
ToPort: -1
CidrIp: 0.0.0.0/0
CloudNetaPublicEC2:
Type: AWS::EC2::Instance
Properties:
InstanceType: t2.micro
ImageId: ami-048c8b90bfe9b49b8
KeyName: !Ref KeyName
Tags:
- Key: Name
Value: CloudNeta-Public-EC2
NetworkInterfaces:
- DeviceIndex: 0
SubnetId: !Ref CloudNetaPublicSN1
GroupSet:
- !Ref CloudNetaSecurityGroup
AssociatePublicIpAddress: true
UserData:
Fn::Base64:
!Sub |
#! /bin/bash
amazon-linux-extras install epel -y
yum install httpd -y
systemctl enable --now httpd
echo "<h1> ho </h1>" > /var/www/html/