forked from hashicorp/terraform-provider-aws
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata_source_aws_api_gateway_vpc_link_test.go
100 lines (79 loc) · 2.56 KB
/
data_source_aws_api_gateway_vpc_link_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package aws
import (
"fmt"
"testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccDataSourceAwsApiGatewayVpcLink(t *testing.T) {
rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandString(8))
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccDataSourceAwsApiGatewayVpcLinkConfig(rName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrPair("data.aws_api_gateway_vpc_link.vpc_link", "name", "aws_api_gateway_vpc_link.vpc_link", "name"),
resource.TestCheckResourceAttrPair("data.aws_api_gateway_vpc_link.vpc_link", "id", "aws_api_gateway_vpc_link.vpc_link", "id"),
),
},
},
})
}
func testAccDataSourceAwsApiGatewayVpcLinkConfig(r string) string {
return fmt.Sprintf(`
resource "aws_vpc" "apigateway_vpclink_test" {
cidr_block = "10.0.0.0/16"
tags = {
Name = "terraform-testacc-lb-apigateway-vpc-link"
}
}
resource "aws_lb" "apigateway_vpclink_test" {
name = "%s"
subnets = [
"${aws_subnet.apigateway_vpclink_test_subnet1.id}"
]
load_balancer_type = "network"
internal = true
idle_timeout = 60
enable_deletion_protection = false
enable_cross_zone_load_balancing = false
tags = {
Name = "testAccDataSourceAwsApiGatewayVpcLinkConfig_networkLoadbalancer"
}
}
resource "aws_lb" "apigateway_vpclink_test2" {
name = "%s-wrong"
subnets = [
"${aws_subnet.apigateway_vpclink_test_subnet1.id}"
]
load_balancer_type = "network"
internal = true
idle_timeout = 60
enable_deletion_protection = false
enable_cross_zone_load_balancing = false
tags = {
Name = "testAccDataSourceAwsApiGatewayVpcLinkConfig_networkLoadbalancer"
}
}
resource "aws_subnet" "apigateway_vpclink_test_subnet1" {
vpc_id = "${aws_vpc.apigateway_vpclink_test.id}"
cidr_block = "10.0.1.0/24"
tags = {
Name = "tf-acc-lb-apigateway-vpclink"
}
}
resource "aws_api_gateway_vpc_link" "vpc_link" {
name = "%s"
target_arns = ["${aws_lb.apigateway_vpclink_test.arn}"]
}
resource "aws_api_gateway_vpc_link" "vpc_link2" {
name = "%s-wrong"
target_arns = ["${aws_lb.apigateway_vpclink_test2.arn}"]
}
data "aws_api_gateway_vpc_link" "vpc_link" {
name = "${aws_api_gateway_vpc_link.vpc_link.name}"
}
`, r, r, r, r)
}