From 489df0a447332a3a275370b35ad095883db40e10 Mon Sep 17 00:00:00 2001 From: Murat Ugur Eminoglu Date: Fri, 10 May 2024 14:47:41 +0300 Subject: [PATCH] Remove static TargetName --- aws-custom-cluster/template.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/aws-custom-cluster/template.yaml b/aws-custom-cluster/template.yaml index cb3659da..7a757c89 100644 --- a/aws-custom-cluster/template.yaml +++ b/aws-custom-cluster/template.yaml @@ -275,7 +275,7 @@ Resources: ALBTargetGroupLambda: Type: 'AWS::ElasticLoadBalancingV2::TargetGroup' Properties: - Name: ALBTargetGroupLambda + # Name: ALBTargetGroupLambda TargetType: lambda Targets: - Id: !GetAtt LambdaFunctionTrigger.Arn @@ -819,6 +819,7 @@ Resources: def lambda_handler(event, context): listener_arn = os.environ['LISTENER_ARN'] origin_asg = os.environ['ORIGIN_ASG'] + target_group_arn = os.environ['TARGETGROUP_ARN'] autoscaling_client = boto3.client('autoscaling') elb_client = boto3.client('elbv2') asg_names = autoscaling_client.describe_auto_scaling_groups() @@ -832,9 +833,6 @@ Resources: ) - target_group_name = elb_client.describe_target_groups(Names=['ALBTargetGroupLambda']) - target_group_arn= target_group_name['TargetGroups'][0]['TargetGroupArn'] - create_rule = elb_client.create_rule( Actions=[ { @@ -868,6 +866,7 @@ Resources: Variables: ORIGIN_ASG: !Sub "${AWS::StackName}-OriginGroup" LISTENER_ARN: !Ref ALBListener443 + TARGETGROUP_ARN: !Ref ALBTargetGroupLambda LambdaGetApiKey: Type: AWS::Lambda::Function DependsOn: ApiGatewayApiKey