make commands

make commands reference#

magic-modules#

make / make provider#

Generates the code for the downstream google and google-beta providers into the OUTPUT_PATH, overriding and deleting any local changes.

Note: Generation works best if the downstream provider has a commit checked out corresponding to the latest main branch commit that is present in your magic-modules working branch. This can generally be identified based on matching commit messages.

Examples:

make provider VERSION=ga OUTPUT_PATH="$GOPATH/src/github.com/hashicorp/terraform-provider-google"
make provider VERSION=beta OUTPUT_PATH="$GOPATH/src/github.com/hashicorp/terraform-provider-google-beta"

# Only generate a specific product (plus all common files)
make provider VERSION=ga OUTPUT_PATH="$GOPATH/src/github.com/hashicorp/terraform-provider-google" PRODUCT=pubsub

# Only generate only a specific resources for a product
make provider VERSION=ga OUTPUT_PATH="$GOPATH/src/github.com/hashicorp/terraform-provider-google" PRODUCT=pubsub RESOURCE=Topic

# Only generate common files, including all third_party code
make provider VERSION=ga OUTPUT_PATH="$GOPATH/src/github.com/hashicorp/terraform-provider-google" PRODUCT=doesnotexist

Arguments#

Cleaning up old files#

Magic Modules will only generate on top of whatever is in the downstream repository. This means that, from time to time, you may end up with stale files or changes in your downstream that cause compilation or tests to fail.

You can clean up by running the following command in your downstream repositories:

git checkout -- . && git clean -f google/ google-beta/ website/

Container-based environment#

This approach is in beta and still collecting feedback. Please file an issue if you encounter challenges.

./scripts/make-in-container.sh runs make with the provided arguments inside a container with all necessary dependencies preinstalled. It uses Docker if available and Podman otherwise. Like make, this script must be run in the root of a magic-modules repository clone.

If you run into any problems, please file an issue.

Before you begin#

  1. Ensure that GOPATH is set on your host machine.

    printenv | grep GOPATH

    If not, add export GOPATH=$HOME/go to your terminal’s startup script and restart your terminal.

  2. Clone the google and google-beta provider repositories with the following commands:

    git clone https://github.com/hashicorp/terraform-provider-google.git $GOPATH/src/github.com/hashicorp/terraform-provider-google
    git clone https://github.com/hashicorp/terraform-provider-google-beta.git $GOPATH/src/github.com/hashicorp/terraform-provider-google-beta

Example#

To build the google provider, run the following command in the root of a magic-modules repository clone:

./scripts/make-in-container.sh \
  terraform VERSION=ga \
  OUTPUT_PATH="$GOPATH/src/github.com/hashicorp/terraform-provider-google"