Skip to content

Commit 41f1fc5

Browse files
committed
Updates to "simple example provider" following feedback (#418)
1 parent bda6ee7 commit 41f1fc5

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

website/docs/plugin/framework/getting-started/example-provider.mdx

+14-18
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,35 @@ description: >-
66

77
# Simple Example Provider
88

9-
[Terraform providers](/terraform/language/providers) allow Terraform core to communicate with 3rd parties such as cloud providers, SaaS providers, and other APIs.
10-
Communication between Terraform core and Terraform providers uses gRPC, with core operating as a gRPC client and providers operating as gRPC servers, respectively.
11-
Terraform provider resources are used to manage infrastructure objects, such as virtual networks and compute instances.
12-
Terraform provider data sources give a read-only view of infrastructure objects.
9+
[Terraform providers](/terraform/language/providers) let Terraform communicate with third parties, such as cloud providers, SaaS providers, and other APIs. Terraform and Terraform providers use gRPC to communicate. Terraform operates as a gRPC client and providers operate as gRPC servers.
1310

14-
The purpose of this example is to show the relationship between the components that are required to build a minimal Terraform provider.
15-
In a real provider the resource and data source would typically interact with a cloud provider via an API but in this example we are simply storing values in state.
16-
Stripping the Terraform provider back to the bare essentials allows us to focus on the minimum requirements needed to build a functional provider.
11+
Each provider defines resources that let Terraform manage infrastructure objects and data sources that let Terraform read data. Terraform practitioners then write configuration to define resources, such as compute storage or networking resources. Terraform then communicates this configuration to the provider, and the provider creates the infrastructure.
1712

18-
A Terraform plugin provider requires the following as a minimum:
13+
This example provider shows the relationship between the required provider components. The resources and data sources in a typical provider interact with a cloud provider through an API, but the example only stores values in state.
1914

20-
* provider server
21-
* provider
22-
* resource (and/or data source)
23-
* data source (and/or resource)
15+
## Core Provider Components
2416

25-
A provider server is the gRPC server that the Terraform core gRPC client communicates with.
17+
A Terraform plugin provider requires at least the following components:
18+
19+
- [provider server](#provider-server)
20+
- [provider](#provider)
21+
- [resource](#resource) or [data source](#data-source)
22+
23+
Every provider also requires a provider server, which is the gRPC server that communicates with the Terraform gRPC client.
2624
The provider wraps the resource(s) and/or data source(s), and can be used to configure a client which communicates with a 3rd party service via an API.
2725
Resources are used to manage infrastructure objects.
2826
Data sources are used to read infrastructure objects.
2927

3028
## Provider Server
3129

32-
Each provider must implement a gRPC server that supports Terraform-specific connection and handshake handling on startup.
30+
Each provider must implement a gRPC server that supports Terraform-specific connection and handshake handling on startup. A [provider server](/plugin/framework/provider-servers) is required in order for a Terraform provider to:
3331

34-
A [provider server](/plugin/framework/provider-servers) is required in order for a Terraform provider to:
3532
* expose resources that can be managed by Terraform core.
3633
* expose data sources that can be read by Terraform core.
3734

3835
The `main()` function is used for defining a provider server.
3936

40-
The `provider.New()` returns a function which returns a type that satisfies the `provider.Provider` interface.
41-
The `provider.Provider` interface defines functions for obtaining the resource(s) and/or data source(s) from a provider.
37+
The `provider.New()` returns a function which returns a type that satisfies the `provider.Provider` interface. The `provider.Provider` interface defines functions for obtaining the resource(s) and/or data source(s) from a provider.
4238

4339
```go
4440
package main
@@ -146,7 +142,7 @@ A resource is typically used to manage infrastructure objects such as virtual ne
146142

147143
In this example the resource simply interacts with Terraform state.
148144

149-
`NewResource()` returns a function which returns a type that satisfies the `resource.Resource` interface. The `NewResource()` function is used within the `provider.Resources` function to make the resource available to the provider.
145+
`NewResource()` returns a function which returns a type that satisfies the `resource.Resource` interface. The provider calls the `NewResource()` function within `provider.Resources` to obtain an instance of the resource.
150146

151147
The `exampleResource` struct implements the `resource.Resource` interface. This interface defines the following functions:
152148

0 commit comments

Comments
 (0)