@@ -157,6 +157,96 @@ func TestAccIPAMIP_WithTags(t *testing.T) {
157157 })
158158}
159159
160+ func TestAccIPAMIP_WithCustomResource (t * testing.T ) {
161+ tt := acctest .NewTestTools (t )
162+ defer tt .Cleanup ()
163+ resource .ParallelTest (t , resource.TestCase {
164+ PreCheck : func () { acctest .PreCheck (t ) },
165+ ProviderFactories : tt .ProviderFactories ,
166+ CheckDestroy : ipamchecks .CheckIPDestroy (tt ),
167+ Steps : []resource.TestStep {
168+ {
169+ Config : `
170+ resource scaleway_vpc vpc01 {
171+ name = "my vpc"
172+ }
173+
174+ resource scaleway_vpc_private_network pn01 {
175+ vpc_id = scaleway_vpc.vpc01.id
176+ ipv4_subnet {
177+ subnet = "172.16.32.0/22"
178+ }
179+ }
180+
181+ resource scaleway_ipam_ip ip01 {
182+ source {
183+ private_network_id = scaleway_vpc_private_network.pn01.id
184+ }
185+ custom_resource {
186+ mac_address = "bc:24:11:74:d0:5a"
187+ }
188+ }
189+ ` ,
190+ Check : resource .ComposeTestCheckFunc (
191+ testAccCheckIPAMIPExists (tt , "scaleway_ipam_ip.ip01" ),
192+ resource .TestCheckResourceAttr ("scaleway_ipam_ip.ip01" , "custom_resource.0.mac_address" , "bc:24:11:74:d0:5a" ),
193+ ),
194+ },
195+ {
196+ Config : `
197+ resource scaleway_vpc vpc01 {
198+ name = "my vpc"
199+ }
200+
201+ resource scaleway_vpc_private_network pn01 {
202+ vpc_id = scaleway_vpc.vpc01.id
203+ ipv4_subnet {
204+ subnet = "172.16.32.0/22"
205+ }
206+ }
207+
208+ resource scaleway_ipam_ip ip01 {
209+ source {
210+ private_network_id = scaleway_vpc_private_network.pn01.id
211+ }
212+ custom_resource {
213+ mac_address = "bc:24:11:74:d0:5b"
214+ }
215+ }
216+ ` ,
217+ Check : resource .ComposeTestCheckFunc (
218+ testAccCheckIPAMIPExists (tt , "scaleway_ipam_ip.ip01" ),
219+ resource .TestCheckResourceAttr ("scaleway_ipam_ip.ip01" , "custom_resource.0.mac_address" , "bc:24:11:74:d0:5b" ),
220+ ),
221+ },
222+ {
223+ Config : `
224+ resource scaleway_vpc vpc01 {
225+ name = "my vpc"
226+ }
227+
228+ resource scaleway_vpc_private_network pn01 {
229+ vpc_id = scaleway_vpc.vpc01.id
230+ ipv4_subnet {
231+ subnet = "172.16.32.0/22"
232+ }
233+ }
234+
235+ resource scaleway_ipam_ip ip01 {
236+ source {
237+ private_network_id = scaleway_vpc_private_network.pn01.id
238+ }
239+ }
240+ ` ,
241+ Check : resource .ComposeTestCheckFunc (
242+ testAccCheckIPAMIPExists (tt , "scaleway_ipam_ip.ip01" ),
243+ resource .TestCheckNoResourceAttr ("scaleway_ipam_ip.ip01" , "custom_resource.0.mac_address" ),
244+ ),
245+ },
246+ },
247+ })
248+ }
249+
160250func testAccCheckIPAMIPExists (tt * acctest.TestTools , n string ) resource.TestCheckFunc {
161251 return func (s * terraform.State ) error {
162252 rs , ok := s .RootModule ().Resources [n ]
0 commit comments