-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathec2.yaml
57 lines (54 loc) · 1.49 KB
/
ec2.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
---
AWSTemplateFormatVersion: '2010-09-09'
Description: 'Create SecurityGroups that import values from a specified stack'
Parameters:
VpcStack:
Description: >
The name of the CloudFormation stack to import VPC resources from.
Type: String
Resources:
ExternalSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupName:
!Sub "${AWS::StackName}-external"
GroupDescription: External security group
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: '80'
ToPort: '80'
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: '443'
ToPort: '443'
CidrIp: 0.0.0.0/0
Tags:
- Key: Name
Value: !Sub "${AWS::StackName}-external"
VpcId:
Fn::ImportValue:
!Sub "${VpcStack}-vpc"
InternalSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupName:
!Sub "${AWS::StackName}-internal"
GroupDescription: Internal security group
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: '8080'
ToPort: '8080'
CidrIp: 10.0.0.0/8
- IpProtocol: tcp
FromPort: '8080'
ToPort: '8080'
CidrIp: 172.16.0.0/12
- IpProtocol: tcp
FromPort: '8080'
ToPort: '8080'
CidrIp: 192.168.0.0/16
Tags:
- Key: Name
Value: !Sub "${AWS::StackName}-internal"
VpcId:
Fn::ImportValue: !Sub "${VpcStack}-vpc"