Closed magodo closed 11 months ago
Fix #68
/tmp/restful via π default π€ cat main.tf terraform { required_providers { restful = { source = "magodo/restful" } } } provider "restful" { base_url = "http://localhost:3000" } resource "restful_resource" "test" { path = "/posts" body = jsonencode({ author = "magodo" title = "foobar" }) read_path = "$(path)/$(body.id)" } data "restful_resource" "all" { id = "/posts" depends_on = [restful_resource.test] } data "restful_resource" "filter" { id = "/posts" output_attrs = [ "#.id", "#.title", ] depends_on = [restful_resource.test] } /tmp/restful via π default π€ tf show # data.restful_resource.all: data "restful_resource" "all" { id = "/posts" output = jsonencode( [ { author = "typicode" id = 1 title = "json-server" }, { author = "magodo" id = 2 title = "foobar" }, ] ) } # data.restful_resource.filter: data "restful_resource" "filter" { id = "/posts" output = jsonencode( [ { id = 1 title = "json-server" }, { id = 2 title = "foobar" }, ] ) output_attrs = [ "#.id", "#.title", ] } # restful_resource.test: resource "restful_resource" "test" { body = jsonencode( { author = "magodo" title = "foobar" } ) id = "/posts/2" output = jsonencode( { author = "magodo" id = 2 title = "foobar" } ) path = "/posts" read_path = "$(path)/$(body.id)" }
Fix #68
Test