-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmsp-05-dev-server-for-petclinic-app-cfn-template.yml
109 lines (105 loc) · 3.29 KB
/
msp-05-dev-server-for-petclinic-app-cfn-template.yml
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
102
103
104
105
106
107
108
109
AWSTemplateFormatVersion: 2010-09-09
Description: >
This Cloudformation template prepares development environment for Petclinic Microservices Application.
User needs to select appropriate key name when launching the template.
Parameters:
KeyPairName:
Description: Enter the name of your Key Pair for SSH connections.
Type: AWS::EC2::KeyPair::KeyName
ConstraintDescription: Must one of the existing EC2 KeyPair
Resources:
PetclinicDemoSG:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Enable SSH and HTTP for Petclinic Microservices
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: tcp
FromPort: 9090
ToPort: 9090
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: 8080
ToPort: 8080
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: 8081
ToPort: 8081
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: 8082
ToPort: 8082
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: 8083
ToPort: 8083
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: 8888
ToPort: 8888
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: 9411
ToPort: 9411
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: 7979
ToPort: 7979
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: 3000
ToPort: 3000
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: 9091
ToPort: 9091
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: 8761
ToPort: 8761
CidrIp: 0.0.0.0/0
PetclinicServerLT:
Type: "AWS::EC2::LaunchTemplate"
Properties:
LaunchTemplateData:
ImageId: ami-01cc34ab2709337aa
InstanceType: t3.medium
KeyName: !Ref KeyPairName
SecurityGroupIds:
- !GetAtt PetclinicDemoSG.GroupId
UserData:
Fn::Base64: |
#! /bin/bash
yum update -y
hostnamectl set-hostname petclinic-dev-server
amazon-linux-extras install docker -y
systemctl start docker
systemctl enable docker
usermod -a -G docker ec2-user
curl -L "https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m)" \
-o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
yum install git -y
yum install java-11-amazon-corretto -y
git clone https://github.com/clarusway/petclinic-microservices-with-db.git
git checkout dev
PetclinicServer:
Type: AWS::EC2::Instance
Properties:
LaunchTemplate:
LaunchTemplateId: !Ref PetclinicServerLT
Version: !GetAtt PetclinicServerLT.LatestVersionNumber
Tags:
- Key: Name
Value: !Sub Petclinic App Dev Server of ${AWS::StackName}
Outputs:
PetclinicServerDNSName:
Description: Petclinic App URL
Value: !GetAtt PetclinicServer.PublicDnsName