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

[WIP] r/aws_security_group_rule: Terraform plan non empty even no change in Description field #2335

Closed
wants to merge 1 commit into from
Closed
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
47 changes: 47 additions & 0 deletions aws/resource_aws_security_group_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,31 @@ func TestAccAWSSecurityGroupRule_EgressDescription_updates(t *testing.T) {
})
}

func TestAccAWSSecurityGroupRule_whenDescriptionWithCount(t *testing.T) {
rInt := acctest.RandInt()

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSSecurityGroupRuleDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSSecurityGroupRuleDescriptionWithCount(rInt),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("aws_security_group_rule.arbitrary.0", "description", "Description0"),
resource.TestCheckResourceAttr("aws_security_group_rule.arbitrary.1", "description", "Description1"),
resource.TestCheckResourceAttr("aws_security_group_rule.arbitrary.2", "description", "Description2"),
),
},
{
Config: testAccAWSSecurityGroupRuleDescriptionWithCount(rInt),
PlanOnly: true,
ExpectNonEmptyPlan: true,
},
},
})
}

func testAccCheckAWSSecurityGroupRuleDestroy(s *terraform.State) error {
conn := testAccProvider.Meta().(*AWSClient).ec2conn

Expand Down Expand Up @@ -960,6 +985,28 @@ func testAccAWSSecurityGroupRuleIngressClassicConfig(rInt int) string {
}`, rInt)
}

func testAccAWSSecurityGroupRuleDescriptionWithCount(rInt int) string {
return fmt.Sprintf(`
resource "aws_security_group" "web" {
name = "terraform_test_%d"
description = "Used in the terraform acceptance tests"
tags {
Name = "tf-acc-test"
}
}

resource "aws_security_group_rule" "arbitrary" {
count = 3
type = "ingress"
protocol = "tcp"
from_port = 80
to_port = 8080
cidr_blocks = ["${element(list("10.0.0.0/8", "11.0.0.0/8", "12.0.0.0/8"), count.index)}"]
security_group_id = "${aws_security_group.web.id}"
description = "Description${count.index}"
}`, rInt)
}

func testAccAWSSecurityGroupRuleEgressConfig(rInt int) string {
return fmt.Sprintf(`
resource "aws_security_group" "web" {
Expand Down