forked from aws-samples/non-profit-blockchain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfabric-client-node.yaml
218 lines (202 loc) · 10.2 KB
/
fabric-client-node.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
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license" file accompanying this file. This file is distributed
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied. See the License for the specific language governing
# permissions and limitations under the License.
AWSTemplateFormatVersion: '2010-09-09'
Description: >
This template creates a Fabric client node, which will run the Fabric CLI and
interact with a Fabric network. The client node is an EC2 instance, and will be created in
its own VPC. Private VPC Endpoints will also be created, pointing to the Fabric service.
Parameters:
KeyName:
Type: AWS::EC2::KeyPair::KeyName
Description: Name of an existing EC2 key pair to enable SSH access to the EC2 instance
BlockchainVpcEndpointServiceName:
Type: String
Description: Name of the Blockchain VPC Endpoint. Obtained from running 'aws managedblockchain get-network'
Resources:
BlockchainWorkshopRootRole:
Type: "AWS::IAM::Role"
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
-
Effect: "Allow"
Principal:
Service:
- "ec2.amazonaws.com"
Action:
- "sts:AssumeRole"
Path: "/"
MaxSessionDuration: 10800
Policies:
-
PolicyName: "root"
PolicyDocument:
Version: "2012-10-17"
Statement:
-
Effect: "Allow"
Action: "*"
Resource: "*"
BlockchainWorkshopRootInstanceProfile:
Type: "AWS::IAM::InstanceProfile"
Properties:
Path: "/"
Roles:
-
Ref: "BlockchainWorkshopRootRole"
BlockchainWorkshopVPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 10.0.0.0/16
EnableDnsSupport: True
EnableDnsHostnames: True
InstanceTenancy: default
Tags:
- Key: ReInventBlockchainWorkshop
Value: VPC
BlockchainWorkshopPublicSubnet:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref BlockchainWorkshopVPC
MapPublicIpOnLaunch: false
CidrBlock: 10.0.0.0/16
Tags:
- Key: ReInventBlockchainWorkshop
Value: PublicSubnet
BlockchainWorkshopSecurityGroupBase:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Base Security Group
VpcId: !Ref BlockchainWorkshopVPC
SecurityGroupIngress:
- IpProtocol: tcp
CidrIp: 0.0.0.0/0
FromPort: 22
ToPort: 22
- IpProtocol: tcp
CidrIp: 0.0.0.0/0
FromPort: 0
ToPort: 65535
Tags:
- Key: ReInventBlockchainWorkshop
Value: BaseSecurityGroup
BlockchainWorkshopSecurityGroupBaseIngress:
Type: AWS::EC2::SecurityGroupIngress
Properties:
IpProtocol: -1
FromPort: -1
GroupId: !GetAtt BlockchainWorkshopSecurityGroupBase.GroupId
ToPort: -1
SourceSecurityGroupId: !GetAtt BlockchainWorkshopSecurityGroupBase.GroupId
Tags:
- Key: ReInventBlockchainWorkshop
Value: BaseSecurityGroupIngress
BlockchainWorkshopInternetGateway:
Type: "AWS::EC2::InternetGateway"
Properties:
Tags:
- Key: ReInventBlockchainWorkshop
Value: InternetGateway
BlockchainWorkshopAttachGateway:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
VpcId: !Ref BlockchainWorkshopVPC
InternetGatewayId: !Ref BlockchainWorkshopInternetGateway
BlockchainWorkshopRouteTable:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref BlockchainWorkshopVPC
Tags:
- Key: ReInventBlockchainWorkshop
Value: RouteTable
BlockchainWorkshopRoute:
Type: AWS::EC2::Route
Properties:
RouteTableId: !Ref BlockchainWorkshopRouteTable
DestinationCidrBlock: 0.0.0.0/0
GatewayId: !Ref BlockchainWorkshopInternetGateway
BlockchainWorkshopSubnetRouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref BlockchainWorkshopPublicSubnet
RouteTableId: !Ref BlockchainWorkshopRouteTable
BlockchainWorkshopVPCEndpoint:
Type: AWS::EC2::VPCEndpoint
Properties:
VpcId: !Ref BlockchainWorkshopVPC
PrivateDnsEnabled: True
ServiceName: !Ref BlockchainVpcEndpointServiceName
VpcEndpointType: Interface
SubnetIds: [!Ref BlockchainWorkshopPublicSubnet]
SecurityGroupIds: [!Ref BlockchainWorkshopSecurityGroupBase]
BlockchainWorkshopEC2:
Type: AWS::EC2::Instance
Properties:
KeyName: !Ref KeyName
ImageId: 'ami-0434d5878c6ad6d4c'
InstanceType: 't2.small'
IamInstanceProfile: !Ref BlockchainWorkshopRootInstanceProfile
NetworkInterfaces:
- AssociatePublicIpAddress: true
DeviceIndex: 0
GroupSet: [!Ref BlockchainWorkshopSecurityGroupBase]
SubnetId: !Ref BlockchainWorkshopPublicSubnet
Tags:
- Key: Name
Value: ManagedBlockchainWorkshopEC2ClientInstance
BlockchainWorkshopELB:
Type: AWS::ElasticLoadBalancing::LoadBalancer
Properties:
SecurityGroups: [!Ref BlockchainWorkshopSecurityGroupBase]
Subnets: [!Ref BlockchainWorkshopPublicSubnet]
Instances:
- !Ref BlockchainWorkshopEC2
Listeners:
- LoadBalancerPort: '80'
InstancePort: '3000'
Protocol: TCP
HealthCheck:
Target: HTTP:3000/health
HealthyThreshold: '3'
UnhealthyThreshold: '5'
Interval: '10'
Timeout: '5'
Tags:
- Key: Name
Value: ELB
Outputs:
VPCID:
Description: VPC ID
Value:
!Ref BlockchainWorkshopVPC
PublicSubnetID:
Description: Public Subnet ID
Value:
!Ref BlockchainWorkshopPublicSubnet
SecurityGroupID:
Description: Security Group ID
Value:
!GetAtt BlockchainWorkshopSecurityGroupBase.GroupId
EC2URL:
Description: Public DNS of the EC2 instance
Value:
!GetAtt BlockchainWorkshopEC2.PublicDnsName
ELBDNS:
Description: Public DNS of the ELB
Value:
!GetAtt BlockchainWorkshopELB.DNSName
BlockchainVPCEndpoint:
Description: VPC Endpoint ID
Value:
!Ref BlockchainWorkshopVPCEndpoint