English 中文(简体)
AWS支持ALB Listener的多个目标群体
原标题:AWS support multiple Target Groups per ALB Listener

我试图为我的非洲妇女论坛建立一个听众,并利用“名单名单”指挥,把我的2个目标团体附属于该听众,但有一些问题使听众与这2个目标群体一起。

在创建美国女权协会的听众和附属于这两个目标群体时,它按照预期开展工作,或者在使用上述各目标群体的硬编码收入时发挥作用:

listener=$(aws elbv2 create-listener --load-balancer-arn $lb_arn --protocol HTTP --port $http_external_port --default-actions  [{"Type": "forward", "Order": 1, "ForwardConfig": {"TargetGroups": [{"TargetGroupArn": "HARDCODED_FIRST_TG_ARN", "Weight": 50}, {"TargetGroupArn": "HARDCODED_SECOND_TG_ARN", "Weight": 50}]}}] )

然而,在将ARN作为变量(发挥作用)使用时,设定名单的指挥没有上述错误信息:

first_tg_arn=$(aws elbv2 describe-target-groups --names $first_tg_name --query "TargetGroups[*][TargetGroupArn]" --output text)
second_tg_arn=$(aws elbv2 describe-target-groups --names $second_tg_name --query "TargetGroups[*][TargetGroupArn]" --output text)

listener=$(aws elbv2 create-listener --load-balancer-arn $lb_arn --protocol HTTP --port $http_external_port --default-actions  [{"Type": "forward", "Order": 1, "ForwardConfig": {"TargetGroups": [{"TargetGroupArn": "${first_tg_arn}", "Weight": 50}, {"TargetGroupArn": "${second_tg_arn}", "Weight": 50}]}}] )

An error occurred (ValidationError) when calling the CreateListener operation: ${first_tg_arn} is not a valid target group ARN

Above attached both ways running the command (with hardcoded ARNs and using the ARNs variables). enter image description here

问题是什么? 谢谢。

问题回答

Your issue is about Linux variable expansion, not exactly about AWS CLI usage.
On your command that is failing you are using single quote , which will not expand variables to its value.
To expand variables you need to use double quote " or no quote at all, as you did in your second example.

以下指挥部门将开展工作:

aws elbv2 create-listener --load-balancer-arn <alb arn> --protocol HTTPS --port 443 --certificates CertificateArn=value --default-actions  Type=forward,ForwardConfig={TargetGroups=[{TargetGroupArn=value,Weight=1},{TargetGroupArn=value,Weight=1},{TargetGroupArn=value,Weight=1}]} 




相关问题
Mount windows shared drive to MWAA in bootscript

In MWAA startup script sudo yum install samba-client cifs-utils -y sudo mount.cifs //dev/test/drop /mnt/dev/test-o username=testuser,password= pwd ,domain=XX Executing above commonds giving error - ...

How to get Amazon Seller Central orders programmatically?

We have been manually been keying Amazon orders into our system and would like to automate it. However, I can t seem to figure out how to go about it. Their documentation is barely there. There is: ...

Using a CDN like Amazon S3 to control access to media

I want to use Amazon S3/CloudFront to store flash files. These files must be private as they will be accessed by members. This will be done by storing each file with a link to Amazon using a mysql ...

unable to connect to database on AWS

actually I have my website build with Joomla hosted on hostmonster but all Joomla website need a database support to run this database is on AWS configuration files need to be updated for that I ...

Using EC2 Load Balancing with Existing Wordpress Blog

I currently have a virtual dedicated server through Media Temple that I use to run several high traffic Wordpress blogs. Both tend to receive sudden StumbleUpon traffic surges that (I m assuming) ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

热门标签