Open skorfmann opened 1 year ago
Hi,
This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!
Here's a use case for fly.io - while there's a Terraform provider, the readme states:
This project is not currently maintained, and is not a recommended method of deployment to Fly.io.
we want to do create a project via Terraform, right now this is shelling out via null_resource
and local-exec
. While this works for creation, it's pretty much a dead-end for destroying - see https://developer.hashicorp.com/terraform/language/resources/provisioners/syntax#destroy-time-provisioners
let resource = new nullProvider.resource.Resource(triggers: { "changed": util.nanoid() }) as "create"
resource.addOverride("provisioner.local-exec.environment", {"FLY_APP_NAME": appName});
resource.addOverride("provisioner.local-exec.command", "
flyctl status -a \$FLY_APP_NAME || flyctl launch --copy-config --no-deploy --name \$FLY_APP_NAME -o ${props.org} -r iad -y
");
// FIXME: We'll have to find another way to do this. Can't reference other resources here. Also, there are drawbacks
// see https://developer.hashicorp.com/terraform/language/resources/provisioners/syntax#destroy-time-provisioners
let destroy = new nullProvider.resource.Resource() as "destroy";
destroy.addOverride("provisioner.local-exec.when", "destroy");
destroy.addOverride("provisioner.local-exec.environment", {"FLY_APP_NAME": appName});
destroy.addOverride("provisioner.local-exec.command", "flyctl status -a \$FLY_APP_NAME && flyctl apps destroy \$FLY_APP_NAME -y");
so, if it was possible to do something like:
bring http;
struct FlyProjectProps {
name: str;
org: str;
region: str;
}
class FlyProject extends CustomResource {
var name: str;
var region: str;
var bucket: str;
init(props: FlyProjectProps) {
this.name = props.name;
this.region = props.region;
this.bucket = props.bucket;
}
// get invoked during terraform apply as normal Terraform resource
pub create(): void {
// Add code here to create the project via http
http.post("https://api.fly.io/v2/projects", ...)
}
pub read(): void {
// Add code here to read the resource
http.get("https://api.fly.io/v2/projects", ...)
}
pub update(): void {
// Add code here to update the resource
http.put("https://api.fly.io/v2/projects", ...)
}
pub delete(): void {
// Add code here to delete the resource
http.delete("https://api.fly.io/v2/projects", ...)
}
}
then this could become
bring fly
new fly.Project(
name: "foo",
region: "iad",
org: "bar"
);
Hi,
This issue hasn't seen activity in 90 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!
Hi,
This issue hasn't seen activity in 90 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!
Feature Spec
With Wing Custom Resources, it's now simple to interface with bespoke APIs and extend the Terraform inflight behaviour with custom code snippets.
or for data fetching / manipulation something like this (inspired by this)
Both, resources and data sources, are build ad-hoc as a Terraform provider when comping this with the Wing CLI transparent to to the user.
In a Wing application, this could be used like:
which would render down to a Terraform HCL (JSON) data source, something like (pseudo HCL code)
Use Cases
Implementation Notes
There are two components to make this work at a high level:
Component
Other
Community Notes