Skip to content

Provider Scaffolding (skaff)#

skaff is a Terraform AWS Provider scaffolding command line tool. It generates resource, data source, or function source files, along with test files which adhere to the latest best practices. These files are heavily commented with instructions, serving as the best way to get started with provider development.

Overview workflow steps#

  1. Figure out what you're trying to do:
    • Resource, data source, or function?
    • Name it.

    Tip

    Net-new resources should be implemented with Terraform Plugin Framework (i.e. the default skaff settings). See Terraform Plugin Development Packages and this issue for additional information.

  2. Use skaff to generate provider code.
  3. Go through the generated code, customizing as necessary.
  4. Run, test, refine.
  5. Remove "TIP" comments.
  6. Submit a pull request.

Running skaff#

  1. Clone the Terraform AWS Provider repository.
  2. Install skaff.

    make skaff
    
  3. Change into the appropriate directory.

    • For resources, data sources, ephemeral resources, and list resources this is the service directory where the new entity will reside, e.g. internal/service/mq.
    • For functions, this is internal/functions.
  4. Generate the code scaffolding. For example,
    • skaff resource --name BrokerReboot.
    • skaff datasource --name IAMRole.
    • skaff function --name ARNParse.
    • skaff list --name EBSVolume.

To get help, enter skaff without arguments.

Usage#

Help#

skaff --help
Create scaffolding for the Terraform AWS Provider

Usage:
  skaff [command]

Available Commands:
  completion  Generate the autocompletion script for the specified shell
  datasource  Create scaffolding for a data source
  ephemeral   Create scaffolding for an ephemeral resource
  function    Create scaffolding for a function
  help        Help about any command
  list        Create scaffolding for a list resource
  resource    Create scaffolding for a resource

Flags:
  -h, --help   help for skaff

Autocompletion#

Generate the autocompletion script for skaff for the specified shell.

skaff completion --help
Usage:
  skaff completion [command]

Available Commands:
  bash        Generate the autocompletion script for bash
  fish        Generate the autocompletion script for fish
  powershell  Generate the autocompletion script for powershell
  zsh         Generate the autocompletion script for zsh

Flags:
  -h, --help   help for completion

Data Source#

Create scaffolding for a data source.

skaff datasource --help
Create scaffolding for a data source

Usage:
  skaff datasource [flags]

Flags:
  -c, --clear-comments     do not include instructional comments in source
  -f, --force              force creation, overwriting existing files
  -h, --help               help for datasource
  -t, --include-tags       Indicate that this resource has tags and the code for tagging should be generated
  -n, --name string        name of the entity
  -s, --snakename string   if skaff doesn't get it right, explicitly give name in snake case (e.g., db_vpc_instance)

Ephemeral Resource#

Create scaffolding for an ephemeral resource.

% skaff ephemeral --help
Create scaffolding for an ephemeral resource

Usage:
  skaff ephemeral [flags]

Flags:
  -c, --clear-comments     do not include instructional comments in source
  -f, --force              force creation, overwriting existing files
  -h, --help               help for ephemeral
  -n, --name string        name of the entity
  -s, --snakename string   if skaff doesn't get it right, explicitly give name in snake case (e.g., db_vpc_instance)

Function#

Create scaffolding for a function.

skaff function --help
Create scaffolding for a function

Usage:
  skaff function [flags]

Flags:
  -c, --clear-comments       do not include instructional comments in source
  -d, --description string   description of the function
  -f, --force                force creation, overwriting existing files
  -h, --help                 help for function
  -n, --name string          name of the function
  -s, --snakename string     if skaff doesn't get it right, explicitly give name in snake case (e.g., arn_build)

List Resource#

Create scaffolding for a list resource.

% skaff list --help
Create scaffolding for a list resource

Usage:
  skaff list [flags]

Flags:
  -c, --clear-comments     do not include instructional comments in source
  -f, --force              force creation, overwriting existing files
  -p, --framework          use scaffolding for resources written using framework
  -h, --help               help for list
  -n, --name string        name of the entity
  -s, --snakename string   if skaff doesn't get it right, explicitly give name in snake case (e.g., db_vpc_instance)

Resource#

Create scaffolding for a resource.

skaff resource --help
Create scaffolding for a resource

Usage:
  skaff resource [flags]

Flags:
  -c, --clear-comments     do not include instructional comments in source
  -f, --force              force creation, overwriting existing files
  -h, --help               help for resource
  -t, --include-tags       Indicate that this resource has tags and the code for tagging should be generated
  -n, --name string        name of the entity
  -s, --snakename string   if skaff doesn't get it right, explicitly give name in snake case (e.g., db_vpc_instance)