I’m working with AWS cloudformation I have an autoscaling group for a couple of machines running an API server, and I would like to set up an application load balancer as a single entry point, so that client application only sees one URL. I was able to create the load balancer and the autoscaling group but I don’t know how to connect them.
Resources:
NodeLaunchConfig:
Type: AWS::AutoScaling::LaunchConfiguration
Properties:
AssociatePublicIpAddress: false
# IamInstanceProfile: !Ref NodeInstanceProfile
ImageId: !Ref NodeImageId
InstanceType: !Ref NodeInstanceType
KeyName: !Ref KeyName
# SecurityGroups is like this on purpuse, this work, IGNORE the error message if any
SecurityGroups: !Ref NodeSecurityGroup
BlockDeviceMappings:
- DeviceName: /dev/xvda
Ebs:
VolumeSize: 200
VolumeType: gp2
DeleteOnTermination: true
NodeGroup:
Type: AWS::AutoScaling::AutoScalingGroup
DependsOn: LoadBalancer
Properties:
LaunchConfigurationName: !Ref NodeLaunchConfig
DesiredCapacity: "1"
MinSize: "0"
MaxSize: "10"
# TargetGroupARNs:
# - !Ref LoadBalancer
TerminationPolicies:
- NewestInstance
# VPCZoneIdentifier is like this on purpuse, this work, IGNORE the error message if any
VPCZoneIdentifier: !Ref Subnets
Tags:
- Key: Name
Value: !Sub ${AWS::StackName}-node
PropagateAtLaunch: true
- Key: Owner
Value: !Ref Owner
PropagateAtLaunch: true
- Key: Department
Value: AI
PropagateAtLaunch: true
- Key: Env
Value: !Ref Environment
PropagateAtLaunch: true
- Key: Job
Value: KubernetesGroupNode
PropagateAtLaunch: true
UpdatePolicy:
AutoScalingRollingUpdate:
MaxBatchSize: 1
MinInstancesInService: 1
PauseTime: PT5M
LoadBalancer:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Properties:
Name: decrypt-loadbalancer
# SecurityGroups is like this on purpuse, this work, IGNORE the error message if any
SecurityGroups: !Ref NodeSecurityGroup
# Subnets is like this on purpuse, this work, IGNORE the error message if any
Subnets: !Ref Subnets
Tags:
- Key: Name
Value: !Sub ${AWS::StackName}-node
- Key: Owner
Value: !Ref Owner
- Key: Department
Value: AI
- Key: Env
Value: !Ref Environment
- Key: Job
Value: KubernetesGroupNode
Type: application