Promote from beta to GA#
This document describes how to promote an existing resource or field that uses MMv1 and/or handwritten code from the google-beta provider to the google (also known as “GA”) provider.
Handwritten code (including custom_code) commonly uses “version guards” in the form of {{- if ne $.TargetVersionName "ga" }}...{{- end }} to wrap code that is beta-specific, which need to be removed during promotion.
For more information about types of resources and the generation process overall, see How Magic Modules works.
Before you begin#
- Complete the steps in Set up your development environment to set up your environment and your Google Cloud project.
- Ensure that your
magic-modules,terraform-provider-google, andterraform-provider-google-betarepositories are up to date.cd ~/magic-modules git checkout main && git clean -f . && git checkout -- . && git pull cd $GOPATH/src/github.com/hashicorp/terraform-provider-google git checkout main && git clean -f . && git checkout -- . && git pull cd $GOPATH/src/github.com/hashicorp/terraform-provider-google-beta git checkout main && git clean -f . && git checkout -- . && git pull
Promote fields and resources#
- In
product.yaml(located inmmv1/products/<product_name>/product.yaml), ensure that theversionslist includes thegaversion and its correspondingbase_url. If the product was previously beta-only, this entry will be missing and must be added before any resources can be promoted. Keep the existingbetaentry: if it is removed, thegoogle-betaprovider silently falls back to the GAbase_url. - Remove
min_version: 'beta'from the resource’s or field’s configuration inResourceName.yaml. - If necessary, remove version guards from resource-level
custom_code. - Add
min_version: 'beta'on any fields or subfields that should not be promoted. - If necessary, add
{{- if ne $.TargetVersionName "ga" }}...{{- end }}version guards to resource-levelcustom_codethat should not be promoted. - Update API versions hardcoded outside
product.yaml, for example in a resource-levelbase_url/self_link,custom_codeURLs (usetransport_tpg.BaseUrl), orreferenceslinks.
- Remove version guards from the resource’s implementation for any functionality being promoted. Be sure to check:
- The overall resource (if the entire resource was beta-only)
- The resource schema
- For top-level fields, the resource’s
Create,Update, andReadmethods - For other fields, expanders and flatteners
- Any other resource-specific code
- Related files without the resource’s name: handwritten data sources, sweepers,
bootstrap_test_utils.go, and schema helpers shared with sibling resources (e.g.google_compute_instanceandgoogle_compute_instance_template)
- Add
{{- if ne $.TargetVersionName "ga" }}...{{- end }}version guards to any parts of the resource or field implementation that should not be promoted. Be sure to check:- The resource schema
- For top-level fields, the resource’s
Create,Update, andReadmethods - For other fields, expanders and flatteners
- Any other resource-specific code
- If a
.go.tmplfile no longer contains any version guards, rename it to.goand format it withgofmt.
Promote tests#
- Remove
min_version: betafrom any samples in aResourceName.yamlwhich only test fields and resources that are present in thegoogleprovider. This includes fields on other resources in the configuration: a test with a beta-only dependency can’t run ingoogle. - Remove version guards from any handwritten code related to fields and resources that are present in the
googleprovider. - Delete
provider = google-betafrom any test configurations (from MMv1 samples or handwritten) which have been promoted. Don’t replace it withprovider = google. - Replace
ProtoV5ProviderBetaFactorieswithProtoV5ProviderFactoriesin all promoted handwritten tests. - Ensure that there is at least one test that will run for the
googleprovider that covers any promoted fields and resources. - Run the promoted tests against the
googleprovider (see Run tests) and include the results in your pull request. Presubmit VCR tests only run againstgoogle-beta.
Promote documentation#
For handwritten resources, modify the documentation as appropriate for your change:
If the entire resource has been promoted to
google, remove the beta warning at the top of the documentation.Remove the
Betaannotation for any fields that have been promoted.Add
Betaas an annotation on any fields or subfields that remained beta-only. For example:* `FIELD_NAME` - (Optional, [Beta](../guides/provider_versions.html.markdown)) FIELD_DESCRIPTIONReplace
FIELD_NAMEandFIELD_DESCRIPTIONwith the field’s name and description.