From 94dbb22bbc99b909820344fb57f4f1dd4f5a994a Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Thu, 15 Oct 2020 17:45:51 -0400 Subject: [PATCH] tests/provider: Fix hardcoded ARN (LB) --- aws/resource_aws_lb_listener_rule_test.go | 20 ++++++++++++++------ aws/resource_aws_lb_target_group_test.go | 4 ++-- aws/resource_aws_lb_test.go | 4 ++-- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/aws/resource_aws_lb_listener_rule_test.go b/aws/resource_aws_lb_listener_rule_test.go index cc3ab9bde13..5978fa12cf8 100644 --- a/aws/resource_aws_lb_listener_rule_test.go +++ b/aws/resource_aws_lb_listener_rule_test.go @@ -22,17 +22,17 @@ func TestLBListenerARNFromRuleARN(t *testing.T) { }{ { name: "valid listener rule arn", - arn: "arn:aws:elasticloadbalancing:us-east-1:012345678912:listener-rule/app/name/0123456789abcdef/abcdef0123456789/456789abcedf1234", - expected: "arn:aws:elasticloadbalancing:us-east-1:012345678912:listener/app/name/0123456789abcdef/abcdef0123456789", + arn: "arn:aws:elasticloadbalancing:us-east-1:012345678912:listener-rule/app/name/0123456789abcdef/abcdef0123456789/456789abcedf1234", //lintignore:AWSAT003,AWSAT005 + expected: "arn:aws:elasticloadbalancing:us-east-1:012345678912:listener/app/name/0123456789abcdef/abcdef0123456789", //lintignore:AWSAT003,AWSAT005 }, { name: "listener arn", - arn: "arn:aws:elasticloadbalancing:us-east-1:012345678912:listener/app/name/0123456789abcdef/abcdef0123456789", + arn: "arn:aws:elasticloadbalancing:us-east-1:012345678912:listener/app/name/0123456789abcdef/abcdef0123456789", //lintignore:AWSAT003,AWSAT005 expected: "", }, { name: "some other arn", - arn: "arn:aws:elasticloadbalancing:us-east-1:123456:targetgroup/my-targets/73e2d6bc24d8a067", + arn: "arn:aws:elasticloadbalancing:us-east-1:123456:targetgroup/my-targets/73e2d6bc24d8a067", //lintignore:AWSAT003,AWSAT005 expected: "", }, { @@ -3142,8 +3142,12 @@ resource "aws_security_group" "test" { func testAccAWSLBListenerRuleConfig_condition_error(condition string) string { return fmt.Sprintf(` +data "aws_partition" "current" {} + +data "aws_region" "current" {} + resource "aws_lb_listener_rule" "error" { - listener_arn = "arn:aws:elasticloadbalancing:us-west-2:111111111111:listener/app/example/1234567890abcdef/1234567890abcdef" + listener_arn = "arn:${data.aws_partition.current.partition}:elasticloadbalancing:${data.aws_region.current.name}:111111111111:listener/app/example/1234567890abcdef/1234567890abcdef" priority = 100 action { @@ -3372,8 +3376,12 @@ condition { func testAccAWSLBListenerRuleConfig_conditionHttpHeader_invalid() string { return ` +data "aws_partition" "current" {} + +data "aws_region" "current" {} + resource "aws_lb_listener_rule" "static" { - listener_arn = "arn:aws:elasticloadbalancing:us-west-2:111111111111:listener/app/test/xxxxxxxxxxxxxxxx/xxxxxxxxxxxxxxxx" + listener_arn = "arn:${data.aws_partition.current.partition}:elasticloadbalancing:${data.aws_region.current.name}:111111111111:listener/app/test/xxxxxxxxxxxxxxxx/xxxxxxxxxxxxxxxx" priority = 100 action { diff --git a/aws/resource_aws_lb_target_group_test.go b/aws/resource_aws_lb_target_group_test.go index 371ee24f80f..ca29bcba643 100644 --- a/aws/resource_aws_lb_target_group_test.go +++ b/aws/resource_aws_lb_target_group_test.go @@ -68,12 +68,12 @@ func TestLBTargetGroupCloudwatchSuffixFromARN(t *testing.T) { }{ { name: "valid suffix", - arn: aws.String(`arn:aws:elasticloadbalancing:us-east-1:123456:targetgroup/my-targets/73e2d6bc24d8a067`), + arn: aws.String(`arn:aws:elasticloadbalancing:us-east-1:123456:targetgroup/my-targets/73e2d6bc24d8a067`), //lintignore:AWSAT003,AWSAT005 suffix: `targetgroup/my-targets/73e2d6bc24d8a067`, }, { name: "no suffix", - arn: aws.String(`arn:aws:elasticloadbalancing:us-east-1:123456:targetgroup`), + arn: aws.String(`arn:aws:elasticloadbalancing:us-east-1:123456:targetgroup`), //lintignore:AWSAT003,AWSAT005 suffix: ``, }, { diff --git a/aws/resource_aws_lb_test.go b/aws/resource_aws_lb_test.go index 738566b8396..5ca920cf657 100644 --- a/aws/resource_aws_lb_test.go +++ b/aws/resource_aws_lb_test.go @@ -69,12 +69,12 @@ func TestLBCloudwatchSuffixFromARN(t *testing.T) { }{ { name: "valid suffix", - arn: aws.String(`arn:aws:elasticloadbalancing:us-east-1:123456:loadbalancer/app/my-alb/abc123`), + arn: aws.String(`arn:aws:elasticloadbalancing:us-east-1:123456:loadbalancer/app/my-alb/abc123`), //lintignore:AWSAT003,AWSAT005 suffix: `app/my-alb/abc123`, }, { name: "no suffix", - arn: aws.String(`arn:aws:elasticloadbalancing:us-east-1:123456:loadbalancer`), + arn: aws.String(`arn:aws:elasticloadbalancing:us-east-1:123456:loadbalancer`), //lintignore:AWSAT003,AWSAT005 suffix: ``, }, {