小编Mil*_*les的帖子

NLB目标群体健康检查失控

我有一个网络负载均衡器和一个关联的目标组,配置为对EC2实例进行运行状况检查.问题是我看到了很多健康检查请求; 每秒多次.

检查之间的默认间隔应该是30秒,但是它们比它们应该的频率高出约100倍.

我的堆栈是在CloudFormation中构建的,我试过覆盖HealthCheckIntervalSeconds,这没有任何效果.有趣的是,当我尝试在控制台中手动更改间隔时,我发现这些值是灰色的:

编辑健康检查设置

这是模板的相关部分,我尝试更改注释的间隔:

NLB:
  Type: "AWS::ElasticLoadBalancingV2::LoadBalancer"
  Properties:
    Type: network
    Name: api-load-balancer
    Scheme: internal
    Subnets: 
      - Fn::ImportValue: PrivateSubnetA
      - Fn::ImportValue: PrivateSubnetB
      - Fn::ImportValue: PrivateSubnetC

NLBListener:
  Type : AWS::ElasticLoadBalancingV2::Listener
  Properties:
    DefaultActions:
      - Type: forward
        TargetGroupArn: !Ref NLBTargetGroup
    LoadBalancerArn: !Ref NLB
    Port: 80
    Protocol: TCP

NLBTargetGroup:
  Type: AWS::ElasticLoadBalancingV2::TargetGroup
  Properties:
    # HealthCheckIntervalSeconds: 30
    HealthCheckPath: /healthcheck
    HealthCheckProtocol: HTTP
    # HealthyThresholdCount: 2
    # UnhealthyThresholdCount: 5
    # Matcher:
    #   HttpCode: 200-399
    Name: api-nlb-http-target-group
    Port: 80
    Protocol: TCP 
    VpcId: !ImportValue PublicVPC
Run Code Online (Sandbox Code Playgroud)

我的EC2实例位于私有子网中,无法访问外部世界.NLB是内部的,因此没有通过API网关就无法访问它们.API网关没有 …

amazon-ec2 amazon-web-services amazon-elb aws-cloudformation

15
推荐指数
2
解决办法
7346
查看次数

无法在 API Gateway Cloudformation 中设置 Cognito 用户池 AuthorizerId

我成功部署了一个 Cognito 用户池,并使用它来验证我设置为代理到 API 网关中的 API 的方法,现在我正在创建相同堆栈的 Cloudformation 模板。使用 Cloudformation,我设置了我的 API 网关和使用我的用户池的授权方。工作正常。当我尝试部署使用授权器的方法时,它没有说:

Invalid authorizer ID specified. Setting the authorization type to CUSTOM
or COGNITO_USER_POOLS requires a valid authorizer.
Run Code Online (Sandbox Code Playgroud)

这是 Cloudformation 堆栈的相关部分:

TestMethod:
  Type: AWS::ApiGateway::Method
  Properties:
    RestApiId: !Ref RestApi
    ResourceId: !Ref TestResource
    HttpMethod: POST      
    AuthorizationType: COGNITO_USER_POOLS
    AuthorizerId: !Ref ApiAuthorizer
    Integration:
      Type: HTTP_PROXY
      IntegrationHttpMethod: POST
      Uri: https://api.example.com/test

ApiAuthorizer: 
  Type: "AWS::ApiGateway::Authorizer"
  Properties: 
    AuthorizerResultTtlInSeconds: 300
    IdentitySource: method.request.header.Authorization
    Name: CognitoDefaultUserPoolAuthorizer
    ProviderARNs: 
      - !ImportValue DefaultUserPool::Arn
    RestApiId: !Ref RestApi
    Type: "COGNITO_USER_POOLS"
Run Code Online (Sandbox Code Playgroud)

Authorizer 部署得很好,我可以在 Cloudformation 中看到它的 ID,并且该方法在没有添加授权的情况下部署得很好。如果我直接声明 ID …

amazon-web-services aws-cloudformation amazon-cognito aws-api-gateway aws-cognito

5
推荐指数
1
解决办法
1770
查看次数