Cloudformation: setting Availability Zone in target group creation

0

Hi, I’m working on creating a target group of type IP(for a NLB) that points to a private IP address located in a different VPC within the same AWS account. However, when writing the CloudFormation code, I’m encountering an issue.

Resource handler returned message: "The Availability Zone is required for IP address '10.33.0.12' because it is not in the VPC (Service: ElasticLoadBalancingV2, Status Code: 400, Request ID: 92f48469-8445-49aa-a8e8-07037esgfsdg)"

This issue occurs because, in CloudFormation, I'm unable to specify the Availability Zone for the IP address. Is there a way to resolve this, or is it a limitation of CloudFormation?

I tried this solution from the GUI Concole and I can do this. Enter image description here

my cloudformation code:

...
Type: AWS::ElasticLoadBalancingV2::TargetGroup
      Properties:
        HealthCheckEnabled: true
        HealthCheckPort: 8888
        HealthCheckProtocol: TCP
        Name: !Sub "${Project}-myMachineTG-tg"
        TargetType: ip
        Protocol: TCP
        Port: 8888
        VpcId:
          Fn::ImportValue:
            !Sub "${Project}igress"
        Targets:
        - Id: !Ref PrivateIp-vm
preguntada hace 2 meses88 visualizaciones
1 Respuesta
2
Respuesta aceptada

Hello.

How about setting "AvailabilityZone: all" as shown below?
https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/aws-properties-elasticloadbalancingv2-targetgroup-targetdescription.html

TargetGroup1: 
    Type: AWS::ElasticLoadBalancingV2::TargetGroup
    Properties:
      HealthCheckEnabled: true
      HealthCheckIntervalSeconds: 30
      HealthCheckPort: traffic-port
      HealthCheckProtocol: TCP
      HealthyThresholdCount: 5
      IpAddressType: ipv4
      Name: !Sub ${SystemPrefix}-${Environment}-tg
      Port: 80
      Protocol: TCP
      TargetGroupAttributes: 
        - Key: preserve_client_ip.enabled
          Value: false
      Targets:
        - AvailabilityZone: all
          Id: !Ref TargetIP
          Port: 80
      TargetType: ip
      UnhealthyThresholdCount: 2
      VpcId: !Ref VPCID
profile picture
EXPERTO
respondido hace 2 meses
profile picture
EXPERTO
revisado hace 2 meses
EXPERTO
revisado hace 2 meses

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas