Skip to content

Commit c710b4a

Browse files
committed
chore: fleet do not play well with ELB
With ElasticLoadBalancingV2 we need to define a TargetGroup and our instances must be part of this TargetGroup. When we create our instances with EC2Fleet, we have no way to declare that we want them to be attached to some TargetGroup. The only way to attach these instances would be to have some lambda reacting to their creation and dynamically attaching them to some TargetGroup... that does not look like something we want to do and maintain. Since we only want two instances, let's switch to a more static approach that can then be integrated with TargetGroup. See: * https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-elasticloadbalancingv2-targetgroup.html * https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-ec2-ec2fleet.html
1 parent cb489a2 commit c710b4a

File tree

1 file changed

+31
-18
lines changed

1 file changed

+31
-18
lines changed

resources.template

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Mappings:
1717
SubnetId: subnet-08fe76b5c6dc035d0
1818
- AvailabilityZone: us-east-2b
1919
SubnetId: subnet-0797a471ba5029682
20+
Subnet1: 'subnet-08fe76b5c6dc035d0'
21+
Subnet2: 'subnet-0797a471ba5029682'
2022
cardano-tom:
2123
Image: 'ami-07feb56dadb897a30'
2224
Snapshot: 'snap-047e50379c2d1fce9'
@@ -202,21 +204,32 @@ Resources:
202204
- Key: sundae-labs:cost-allocation:Service
203205
Value: sundae-sync-v2
204206

205-
SundaeSyncInstances:
206-
Type: 'AWS::EC2::EC2Fleet'
207-
Properties:
208-
ExcessCapacityTerminationPolicy: 'termination'
209-
TagSpecifications:
210-
- ResourceType: 'instance'
211-
Tags:
212-
- Key: sundae-labs:cost-allocation:Service
213-
Value: sundae-sync-v2
214-
TargetCapacitySpecification:
215-
TotalTargetCapacity: 2
216-
OnDemandTargetCapacity: 1
217-
DefaultTargetCapacityType: 'spot'
218-
LaunchTemplateConfigs:
219-
- LaunchTemplateSpecification:
220-
LaunchTemplateId: !Ref SundaeSyncLaunchTemplate
221-
Version: $Latest
222-
Overrides: !FindInMap [Env, !Ref Env, Subnets]
207+
SundaeSyncInstance1:
208+
Type: AWS::EC2::Instance
209+
Properties:
210+
LaunchTemplate:
211+
LaunchTemplateId: !Ref SundaeSyncLaunchTemplate
212+
Version: $Latest
213+
NetworkInterfaces:
214+
- DeviceIndex: 0
215+
SubnetId: !FindInMap [Env, !Ref Env, Subnet1]
216+
Tags:
217+
- Key: Name
218+
Value: !Sub "${Env}-sundae-sync-1"
219+
- Key: sundae-labs:cost-allocation:Service
220+
Value: sundae-sync-v2
221+
222+
SundaeSyncInstance2:
223+
Type: AWS::EC2::Instance
224+
Properties:
225+
LaunchTemplate:
226+
LaunchTemplateId: !Ref SundaeSyncLaunchTemplate
227+
Version: $Latest
228+
NetworkInterfaces:
229+
- DeviceIndex: 0
230+
SubnetId: !FindInMap [Env, !Ref Env, Subnet1]
231+
Tags:
232+
- Key: Name
233+
Value: !Sub "${Env}-sundae-sync-2"
234+
- Key: sundae-labs:cost-allocation:Service
235+
Value: sundae-sync-v2

0 commit comments

Comments
 (0)