I'm using a local exec provisioner in terraform to run aws cli commands that get around terraform's lack of support for certain aws features. The command in question is to create a listener-rule
for Application Load Balancer. Here's the call in question (numbers fuzzed):
aws elbv2 create-rule
--listener-arn arn:aws:elasticloadbalancing:us-west-1:394416156998:listener/app/lb-name/22e3a19c3c684f8b/17032dfaae523461
--priority 2
--conditions Field=http-request-method,Values='GET'
--actions Type=forward,TargetGroupArn=arn:aws:elasticloadbalancing:us-west-1:394416159845:targetgroup/target-group-name/2ff8e99a44a24219
This yields the error:
(ValidationError) when calling the CreateRule operation: 'arn:aws:elasticloadbalancing:us-west-1:394416155421:listener/app/alb-name/92e1a32c3c684f2b/64032dfaae753032' must be in ARN format
However, if you examine the example in amazon's own documentation, they use exactly the same ARN format, unless I'm missing the obvious.
Here's my terraform code:
resource "null_resource" "rule-maker" {
provisioner "local-exec" {
command = "aws elbv2 create-rule --listener-arn ${data.aws_arn.listener-arn.arn} --priority 2 --conditions Field=http-request-method,Values='GET' --actions Type=forward,TargetGroupArn=${aws_alb_target_group.name.arn}"
}
}
${data.aws_arn.listener-arn.arn}
in double quotes like:"aws elbv2 create-rule --listener-arn \"${data.aws_arn.listener-arn.arn}\" --priority 2 --conditions Field=http-request-method,Values='GET' --actions Type=forward,TargetGroupArn=${aws_alb_target_group.name.arn}"
– progfan