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/res/security_group_rule: Fix hardcoded region #16626

Merged
merged 1 commit into from
Dec 11, 2020
Merged
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
23 changes: 13 additions & 10 deletions aws/resource_aws_security_group_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ func TestAccAWSSecurityGroupRule_PrefixListEgress(t *testing.T) {
testAccCheckAWSSecurityGroupRuleExists("aws_security_group.egress", &group),
// lookup info on the VPC Endpoint created, to populate the expected
// IP Perm
testAccCheckVpcEndpointExists("aws_vpc_endpoint.s3-us-west-2", &endpoint),
testAccCheckVpcEndpointExists("aws_vpc_endpoint.s3_endpoint", &endpoint),
setupSG,
testAccCheckAWSSecurityGroupRuleAttributes("aws_security_group_rule.egress_1", &group, &p, "egress"),
),
Expand Down Expand Up @@ -1075,7 +1075,7 @@ func TestAccAWSSecurityGroupRule_MultiDescription(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSSecurityGroupRuleExists("aws_security_group.worker", &group),
testAccCheckAWSSecurityGroupRuleExists("aws_security_group.nat", &nat),
testAccCheckVpcEndpointExists("aws_vpc_endpoint.s3-us-west-2", &endpoint),
testAccCheckVpcEndpointExists("aws_vpc_endpoint.s3_endpoint", &endpoint),

testAccCheckAWSSecurityGroupRuleAttributes("aws_security_group_rule.rule_1", &group, &rule1, "ingress"),
resource.TestCheckResourceAttr("aws_security_group_rule.rule_1", "description", "CIDR Description"),
Expand Down Expand Up @@ -1111,7 +1111,7 @@ func TestAccAWSSecurityGroupRule_MultiDescription(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSSecurityGroupRuleExists("aws_security_group.worker", &group),
testAccCheckAWSSecurityGroupRuleExists("aws_security_group.nat", &nat),
testAccCheckVpcEndpointExists("aws_vpc_endpoint.s3-us-west-2", &endpoint),
testAccCheckVpcEndpointExists("aws_vpc_endpoint.s3_endpoint", &endpoint),

testAccCheckAWSSecurityGroupRuleAttributes("aws_security_group_rule.rule_1", &group, &rule1, "egress"),
resource.TestCheckResourceAttr("aws_security_group_rule.rule_1", "description", "CIDR Description"),
Expand Down Expand Up @@ -1588,9 +1588,11 @@ resource "aws_vpc" "tf_sgrule_description_test" {
}
}

resource "aws_vpc_endpoint" "s3-us-west-2" {
data "aws_region" "current" {}

resource "aws_vpc_endpoint" "s3_endpoint" {
vpc_id = aws_vpc.tf_sgrule_description_test.id
service_name = "com.amazonaws.us-west-2.s3"
service_name = "com.amazonaws.${data.aws_region.current.name}.s3"
}

resource "aws_security_group" "worker" {
Expand Down Expand Up @@ -1649,7 +1651,7 @@ resource "aws_security_group_rule" "rule_4" {
protocol = "tcp"
from_port = 22
to_port = 22
prefix_list_ids = [aws_vpc_endpoint.s3-us-west-2.prefix_list_id]
prefix_list_ids = [aws_vpc_endpoint.s3_endpoint.prefix_list_id]
}
`)
}
Expand Down Expand Up @@ -1798,7 +1800,6 @@ resource "aws_security_group_rule" "other_ingress" {
}

const testAccAWSSecurityGroupRulePrefixListEgressConfig = `

resource "aws_vpc" "tf_sg_prefix_list_egress_test" {
cidr_block = "10.0.0.0/16"

Expand All @@ -1811,9 +1812,11 @@ resource "aws_route_table" "default" {
vpc_id = aws_vpc.tf_sg_prefix_list_egress_test.id
}

resource "aws_vpc_endpoint" "s3-us-west-2" {
data "aws_region" "current" {}

resource "aws_vpc_endpoint" "s3_endpoint" {
vpc_id = aws_vpc.tf_sg_prefix_list_egress_test.id
service_name = "com.amazonaws.us-west-2.s3"
service_name = "com.amazonaws.${data.aws_region.current.name}.s3"
route_table_ids = [aws_route_table.default.id]

policy = <<POLICY
Expand Down Expand Up @@ -1843,7 +1846,7 @@ resource "aws_security_group_rule" "egress_1" {
protocol = "-1"
from_port = 0
to_port = 0
prefix_list_ids = [aws_vpc_endpoint.s3-us-west-2.prefix_list_id]
prefix_list_ids = [aws_vpc_endpoint.s3_endpoint.prefix_list_id]
security_group_id = aws_security_group.egress.id
}
`
Expand Down