@@ -64,6 +64,37 @@ ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCKVmnMOlHKcZK8tpt3MP1lqOLAcqcJzhsvJcjscgVE
6464 },
6565 )
6666}
67+ func TestAccIBMISFlowLog_vni (t * testing.T ) {
68+ var instance string
69+ vpcname := fmt .Sprintf ("flowlog-vpc-%d" , acctest .RandIntRange (10 , 100 ))
70+ flowlogname := fmt .Sprintf ("flowlog-instance-%d" , acctest .RandIntRange (10 , 100 ))
71+ subnetname := fmt .Sprintf ("flowlog-subnet-%d" , acctest .RandIntRange (10 , 100 ))
72+
73+ vniname := fmt .Sprintf ("tf-ssh-%d" , acctest .RandIntRange (10 , 100 ))
74+ bucketName := fmt .Sprintf ("terraform%d" , acctest .RandIntRange (10 , 100 ))
75+ bucketRegion := "us-south"
76+ bucketClass := "standard"
77+ bucketRegionType := "cross_region_location"
78+
79+ resource .Test (t , resource.TestCase {
80+ PreCheck : func () { acc .TestAccPreCheck (t ) },
81+ Providers : acc .TestAccProviders ,
82+ CheckDestroy : testAccCheckIBMISFlowLogDestroy ,
83+ Steps : []resource.TestStep {
84+
85+ {
86+ //Create test case
87+ Config : testAccCheckIBMISFlowLogVniConfig (vpcname , vniname , flowlogname , subnetname , bucketName , bucketRegionType , bucketRegion , bucketClass , true ),
88+ Check : resource .ComposeTestCheckFunc (
89+ testAccCheckIBMISFlowLogExists ("ibm_is_flow_log.test_flow_log" , instance ),
90+ resource .TestCheckResourceAttr ("ibm_is_flow_log.test_flow_log" , "name" , flowlogname ),
91+ resource .TestCheckResourceAttr ("data.ibm_is_flow_log.is_flow_log_name" , "target.0.resource_type" , "virtual_network_interface" ),
92+ ),
93+ },
94+ },
95+ },
96+ )
97+ }
6798
6899func testAccCheckIBMISFlowLogConfig (vpcname , name , flowlogname , sshname , publicKey , subnetname , serviceName , bucketName , bucketRegionType , bucketRegion , bucketClass string , isActive bool ) string {
69100 return fmt .Sprintf (`
@@ -125,6 +156,46 @@ func testAccCheckIBMISFlowLogConfig(vpcname, name, flowlogname, sshname, publicK
125156
126157 ` , vpcname , subnetname , acc .ISZoneName , acc .ISCIDR , sshname , publicKey , name , acc .IsImage , acc .InstanceProfileName , acc .ISZoneName , serviceName , bucketName , bucketRegion , bucketClass , flowlogname , isActive )
127158
159+ }
160+ func testAccCheckIBMISFlowLogVniConfig (vpcname , vniname , flowlogname , subnetname , bucketName , bucketRegionType , bucketRegion , bucketClass string , isActive bool ) string {
161+ return fmt .Sprintf (`
162+
163+ resource "ibm_is_vpc" "testacc_vpc" {
164+ name = "%s"
165+ }
166+
167+ resource "ibm_is_subnet" "testacc_subnet" {
168+ name = "%s"
169+ vpc = ibm_is_vpc.testacc_vpc.id
170+ zone = "%s"
171+ total_ipv4_address_count = 16
172+ }
173+
174+ resource "ibm_is_virtual_network_interface" "testacc_vni"{
175+ name = "%s"
176+ subnet = ibm_is_subnet.testacc_subnet.id
177+ }
178+
179+ resource "ibm_cos_bucket" "bucket2" {
180+ bucket_name = "%s"
181+ resource_instance_id = "%s"
182+ region_location = "%s"
183+ storage_class = "%s"
184+ }
185+ // Authorisation policy is required between vpc Flowlogs and Object Storage
186+
187+ resource "ibm_is_flow_log" "test_flow_log" {
188+ name = "%s"
189+ target = ibm_is_virtual_network_interface.testacc_vni.id
190+ storage_bucket = ibm_cos_bucket.bucket2.bucket_name
191+ active = %v
192+ }
193+ data "ibm_is_flow_log" "is_flow_log_name" {
194+ name = ibm_is_flow_log.test_flow_log.name
195+ }
196+
197+ ` , vpcname , subnetname , acc .ISZoneName , vniname , bucketName , acc .ISResourceCrn , bucketRegion , bucketClass , flowlogname , isActive )
198+
128199}
129200func vpcClient (meta interface {}) (* vpcv1.VpcV1 , error ) {
130201 sess , err := meta .(conns.ClientSession ).VpcV1API ()
0 commit comments