Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests/provider: Fix hardcoded ARN (LB) #15673

Merged
merged 1 commit into from
Oct 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions aws/resource_aws_lb_listener_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: "",
},
{
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions aws/resource_aws_lb_target_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: ``,
},
{
Expand Down
4 changes: 2 additions & 2 deletions aws/resource_aws_lb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: ``,
},
{
Expand Down