Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc request: How to generate args #25

Open
bitdivine opened this issue Jun 7, 2024 · 1 comment
Open

Doc request: How to generate args #25

bitdivine opened this issue Jun 7, 2024 · 1 comment

Comments

@bitdivine
Copy link
Member

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 and didc (see my futile attempt).

If you have an example of how to do this, that would be very helpful.

@nmattia
Copy link
Collaborator

nmattia commented Jun 11, 2024

I've just added better support for args in #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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants