Open bitdivine opened 5 months ago
I've just added better support for args in https://github.com/dfinity/terraform-provider-ic/pull/26.
The arg
parameter now supports strings and records (of records and strings) instead of just strings:
resource "ic_canister" "my-app" {
arg = { greeter = "hello" } # interpreted as (record { greeter = "hello" } )
}
I've added some functions (needs Terraform 1.8.0+) for encoding Terraform values to candid. So very similar to the above:
resource "ic_canister" "my-app" {
arg_hex = provider::ic::did_encode({ greeter = "hello" })
}
(note the use of arg_hex
instead of arg
here; arg
effectively applies did_encode
to its TF parameter)
@q-uint (more or less) suggested we could also have a function that encodes a didc string, like this:
resource "ic_canister" "my-app" {
arg_hex = provider::ic::did_didc("(record { greeter = "hello" })")
}
That might give practitioners more flexibility without having to rely on local-exec
. Thoughts @bitdivine ?
Thank you for the provider. It worked when I provided args as a hex string but I am struggling to generate the args dynamically with
local-exec
anddidc
(see my futile attempt).If you have an example of how to do this, that would be very helpful.