Create Provider
Subcommand provider
of terragen create
generates scaffolds for a specified provider under the directory it is invoked or under specified directory.
terragen create provider --help
would help in listing all available flags of terragen create provider
.
Command to generate scaffolds for terraform provider and its other components.
This includes creation of provider, resource, datasource.
Usage:
terragen create provider [args] [flags]
Flags:
-d, --data-source strings name of the data scaffold
--datasource-required enable if data_source requires scaffold
-h, --help help for provider
-i, --importer string name of the importer scaffold
--importer-required enable if importer requires scaffold
-g, --repo-group string repo group to which the terraform provider to be part of
-r, --resource strings name of the resource scaffold
--resource-required enable if resource requires scaffold
Global Flags:
--dry-run dry-run the process of provider scaffold creation
-p, --path string path where the templates has to be generated (default ".")
Usage
- Let us understand how can we generate scaffolds for a project hashicups (recreating Hashicorp’s demo provider).
- Initial scaffolds for the provider can be generated by running
terragen create provider hashicups
. - Be sure about the folder under which the command is executed. Since no flag
--path
is used, it generates scaffolds under the directory from where the command is fired. - Once scaffolds are generated, it can be verified by looking at metadata file
terragen.yml
for all information about scaffolded provider. - If datasource or resources needs to be created during initial scaffold generation, make sure you invoke
terragen create provider hashicups
with flags--data-source
,resource
. - Both flags
--data-source
,resource
accepts list, When more than one of kind is required pass multiple instances of it.- With multiple data-sources:
terragen create provider hashicups --data-source hashicups_coffees --data-source hashicups_ingredients
- With resources:
terragen create provider hashicups --resource hashicups_order
- Note: For generating all of these scaffolds
repo-group
github.com/nikhilsbhat
is being used.
- With multiple data-sources:
- With all of these now the metadata for the project looks like:
version: 1.0.0
repo-group: github.com/nikhilsbhat
project-module: github.com/nikhilsbhat/terraform-provider-hashicups
provider: hashicups
provider-path: /Users/sample/my-opensource/terraform-provider-test
resources:
- hashicups_order
data-sources:
- hashicups_coffees
- hashicups_ingredients
importers:
- ""
- More
data-sources
andresources
can be scaffolded to the existing provider, to achieve the same use appropriate sub-commands.
Configuration
Flags | Type | Description | Defaults |
---|---|---|---|
data-source | list | name of terraform data source for which scaffold to be created. | NA |
resource | list | name of terraform resource for which scaffold to be created. | NA |
importer | list | name of terraform importer for which scaffold to be created. | NA |
repo-group | string | name of the project repo, this would be used while defining go mod . | name of provider |