AWSTemplateFormatVersion: '2010-09-09'
Description: O11y vpc endpoint service

Parameters:
  NLBArn:
    Type: String
  NLBAllowedPrincipals:
    Type: List<String>
  ResourceOwnerTag:
    Type: String
    Description: Tag value for the resource owner

Resources:
  VpcEndpointService:
    Type: AWS::EC2::VPCEndpointService
    Properties:
      AcceptanceRequired: false
      NetworkLoadBalancerArns: 
        - !Ref NLBArn
      Tags:
        - Key: tidbcloud-auto-deploy-owner
          Value: !Ref ResourceOwnerTag

  VPCEndpointServicePermissions:
    Type: AWS::EC2::VPCEndpointServicePermissions
    Properties:
      ServiceId: !Ref VpcEndpointService
      AllowedPrincipals: !Ref NLBAllowedPrincipals

Outputs:
  VpcEndpointServiceId:
    Value: !Ref VpcEndpointService
