AWS Elastic Load Balancing V2 Deployment with CloudFormation: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 46: Line 46:
       [[AWS_Elastic_Load_Balancing_Concepts#Target_Group_Name|Name]]: !Ref ProjectID
       [[AWS_Elastic_Load_Balancing_Concepts#Target_Group_Name|Name]]: !Ref ProjectID
       [[AWS_Elastic_Load_Balancing_Concepts#Target_Group_VPC_Association|VpcId]]: !Ref VPCId
       [[AWS_Elastic_Load_Balancing_Concepts#Target_Group_VPC_Association|VpcId]]: !Ref VPCId
       Protocol: TCP
       [[AWS_Elastic_Load_Balancing_Concepts#Target_Group_Protocol|Protocol]]: TCP
       Port: !Ref Port
       Port: !Ref Port
       TargetType: ip
       TargetType: ip

Revision as of 20:28, 2 April 2019

External

Internal

Resource Types

AWS::ElasticLoadBalancingV2::LoadBalancer

Resources:
  ALoadBalancer:
    Type: AWS::ElasticLoadBalancingV2::LoadBalancer
    Properties:
      Name: blue
      Scheme: 'internet-facing'|'internal'
      Type: 'application'|'network'
      IpAddressType: 'ipv4'
      LoadBalancerAttributes:
        - Key: 'access_logs.s3.enabled'
          Value: true|false
        - Key: 'access_logs.s3.bucket'
          Value: ...
        - Key: 'access_logs.s3.prefix'
          Value: ...
      Subnets:
        - blue-subnet-id
        - red-subnet-id
      SubnetMappings:
        - ...
      SecurityGroups:
        - some-security-group-for-application-load-balancer

AWS::ElasticLoadBalancingV2::TargetGroup

Network Load Balancer TargetGroup

Resources:
  TargetGroup:
    Type: AWS::ElasticLoadBalancingV2::TargetGroup
    Properties:
      Name: !Ref ProjectID
      VpcId: !Ref VPCId
      Protocol: TCP
      Port: !Ref Port
      TargetType: ip
      HealthCheckIntervalSeconds: 30
      # TODO ba23q enable actuator
      #HealthCheckPath: '/themyscira/actuator/health'
      HealthCheckProtocol: TCP
      HealthCheckTimeoutSeconds: 10
      HealthyThresholdCount: 3
      UnhealthyThresholdCount: 3

Application Load Balancer TargetGroup

Resources:
 TargetGroup:
    Type: AWS::ElasticLoadBalancingV2::TargetGroup
    Properties:
      HealthCheckIntervalSeconds: 60
      HealthCheckPath: '/myservice/actuator/health'
      HealthCheckProtocol: HTTP
      HealthCheckTimeoutSeconds: 5
      HealthyThresholdCount: 2
      TargetType: ip
      Name: myservice
      Port: 8086
      Protocol: HTTP
      UnhealthyThresholdCount: 10
      VpcId: !Ref MyVpcId

AWS::ElasticLoadBalancingV2::Listener

Network Load Balancer Listener

Application Load Balancer Listener

Resources:
  LoadBalancerListener:
    Type: AWS::ElasticLoadBalancingV2::Listener
    DependsOn:
      - TargetGroup
    Properties:
      DefaultActions:
        - TargetGroupArn: !Ref 'TargetGroup'
          Type: 'forward'
      LoadBalancerArn:
        Fn::ImportValue: !Join [':', [!Ref 'DeploymentStackName', 'ServiceALB']]
      Port: 10002
      Protocol: HTTP