crossplane-contrib / provider-upjet-aws

Official AWS Provider for Crossplane by Upbound.
https://marketplace.upbound.io/providers/upbound/provider-aws
Apache License 2.0
137 stars 112 forks source link

Use custom Terraform provider release to generate schema.json #1318

Closed mergenci closed 1 month ago

mergenci commented 1 month ago

Description of your changes

Code generation depends on JSON schema of terraform-provider-aws (config/schema.json). Converting a Terraform provider's schema to JSON is performed by Terraform CLI, which requires a provider binary. Therefore, when we introduce a new resource, such as MQ User, to our fork of terraform-provider-aws, we also release the provider as binary. This PR introduces necessary changes to download custom provider release and let Terraform CLI use it instead of the official provider.

The following is an example .terraformrc configuration generated by make:

provider_installation {
  filesystem_mirror {
    path = ".cache/tools/darwin_arm64"
    include = ["hashicorp/aws"]
  }
  direct {
    exclude = ["hashicorp/aws"]
  }
}

When using the above configuration, Terraform CLI locates the provider binary at registry.terraform.io/hashicorp/aws/5.31.0/darwin_arm64/terraform-provider-aws, where 5.31.0 is the example provider version, inside the filesystem mirror directory.

Custom provider release is installed at .cache/tools/darwin_arm64/registry.terraform.io/hashicorp/aws/5.31.0/darwin_arm64/terraform-provider-aws on an Apple Silicon Mac. On other platforms, installation location is the equivalent path, for instance .cache/tools/linux_amd64/registry.terraform.io/hashicorp/aws/5.31.0/linux_amd64/terraform-provider-aws on an Intel/AMD Linux).

I have:

How has this code been tested

  1. Remove config/schema.json.
  2. Run make config/schema.json.
  3. Observe that config/schema.json is created.

Above steps will not result in any difference in config/schema.json. During development, I used a development build of the provider that has a new resource, aws_mq_user, added. In that case, I observed that aws_mq_user schema exists in the output, config/schema.json.

mergenci commented 1 month ago

Thank you for your valuable reviews @ulucinar 🙏