AWSTemplateFormatVersion: 2010-09-09
Resources:
  ApplicationLoadBalancer:
    Type: 'AWS::ElasticLoadBalancingV2::LoadBalancer'
    Properties:
      Subnets:
        - !Ref pubnet1id
        - !Ref pubnet2id
      SecurityGroups:
        - !Ref elbgroupid
    Metadata:
      'AWS::CloudFormation::Designer':
        id: 01cf8a1b-c08c-4410-b833-5bab98a4cc0d
  ALBListener:
    Type: 'AWS::ElasticLoadBalancingV2::Listener'
    Properties:
      DefaultActions:
        - Type: forward
          TargetGroupArn: !Ref ALBTargetGroup
      LoadBalancerArn: !Ref ApplicationLoadBalancer
      Port: '81'
      Protocol: HTTP
    Metadata:
      'AWS::CloudFormation::Designer':
        id: cf883cbd-fd01-45a1-b42e-3cc732475a48
  ALBListenerRule:
    Type: 'AWS::ElasticLoadBalancingV2::ListenerRule'
    Properties:
      Actions:
        - Type: forward
          TargetGroupArn: !Ref ALBTargetGroup
      Conditions:
        - Field: path-pattern
          Values:
            - /
      ListenerArn: !Ref ALBListener
      Priority: 1
    Metadata:
      'AWS::CloudFormation::Designer':
        id: bfa5c894-73f0-40e1-a0ad-7a6d83d61f84
  ALBTargetGroup:
    Type: 'AWS::ElasticLoadBalancingV2::TargetGroup'
    Properties:
      HealthCheckIntervalSeconds: 30
      HealthCheckPath: /
      HealthCheckProtocol: HTTP
      HealthCheckTimeoutSeconds: 5
      HealthyThresholdCount: 3
      Port: 80
      Protocol: HTTP
      UnhealthyThresholdCount: 5
      VpcId: !Ref vpc1id 
    Metadata:
      'AWS::CloudFormation::Designer':
        id: da90ade6-53eb-497d-a36a-b4ab683f9948
Parameters:
  vpc1id:
    Type: String
  elbgroupid:
    Type: String
  pubnet1id:
    Type: String
  pubnet2id:
    Type: String