crossplane / crossplane/upjet

Utilize native schema.Schema.ConflictsWith in late-initialization configuration

Open
#197 1 comment 1 reaction 0 assignees View on GitHub
codegen enhancement is:triaged v2
Dominant language
Go
Stars
481
Forks
131
Avg merge
2d 1h
Merged PRs (30d)
11

Description

### What problem are you facing?

We intermittently need to do some late initialization configuration for [`Terraformed`](https://github.com/upbound/upjet/blob/645d7260d814cb67db2280e92988051d30774a09/pkg/resource/interfaces.go#L43) resources because the native Terraform provider we are using defines some mutually exclude configuration arguments, i.e., arguments in the Terraform resource configuration that you cannot specify together. Let's assume argument `a` & `b` are mutually exclusive in this regard and we've set `a`. If the external resource has `b` also set, then the upjet runtime late-initializes the corresponding managed resource field and upon the next reconciliation, the generated Terraform configuration has both `a` & `b` set and this configuration is rejected by Terraform.

Currently, we attack this category of issues by adding some manual resource configuration so that the late-initialization library skips initializing the mutually exclusive managed resource fields as determined by the Terraform native provider implementation. An example of such manual configuration is [here](https://github.com/upbound/provider-aws/blob/6caff788dc90b7ee7f7f8fe3632d0325e496d5aa/config/iam/config.go#L120).

### How could Upjet help solve your problem?

The mutually exclusive arguments for a Terraform resource are exposed via the [`schema.Schema.ConflictsWith`](https://github.com/hashicorp/terraform-plugin-sdk/blob/6b60c91fdd316c50bf4f4de675e29fbc85f62f0d/helper/schema/schema.go#L265) API in the native schema. We may utilize this information to automatically configure the upjet late-initialization library and prevent the runtime issues that necessitate manual resource configuration to be resolved. An example in the native schema is [here](https://github.com/hashicorp/terraform-provider-aws/blob/ced858a361a9942f365d64faa5e2fe358cc4f4c5/internal/service/ec2/ec2_instance.go#L410) and a recent issue in the corresponding managed resource is [here](https://github.com/upbound/provider-aws/pull/109).

The current implementation blocker here is that `ConflictsWith` is currently not available in the JSON (native) schema we are utilizing in upjet's code generation pipelines.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.