You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/README.md
-1Lines changed: 0 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,4 +17,3 @@ Resource listing is done using cloud providers SDK. Resource details retrieval i
17
17
-`Remote` is a representation of a cloud provider
18
18
-`Resource` is an abstract representation of a cloud provider resource (e.g. S3 bucket, EC2 instance, etc ...)
19
19
-`Enumerator` is used to list resources of a given type from a given remote and return a resource list, it should exist only one Enumerator per resource
20
-
-`DetailsFetcher` is used to retrieve resource's details of a given type, this is an optional layer and is used only in deep mode.
Copy file name to clipboardExpand all lines: docs/new-resource.md
+2-41Lines changed: 2 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,22 +13,12 @@ Then, you'll find below a more detailed flow of how we handle the enumeration an
13
13
First step would be to add a file called `pkg/resource/<providername>/<resourcetype>.go`.
14
14
This file will define a string constant that will be the resource type identifier in driftctl.
15
15
16
-
Optionally, if your resource is to be supported by driftctl experimental deep mode, you can add a function that will be applied to this resource at creation.
17
-
This allows to prevent useless diffs to be displayed.
18
-
You can also add metadata to fields so that they are compared or displayed differently.
19
-
20
16
For example this defines the `aws_iam_role` resource:
@@ -57,17 +47,12 @@ var supportedTypes = map[string]struct{}{
57
47
All resources inside driftctl are `resource.Resource` structs.
58
48
All the other attributes are represented inside a `map[string]interface`
59
49
60
-
## Repository, Enumerator and DetailsFetcher
50
+
## Repository, Enumerator
61
51
62
-
Then you will have to implement two interfaces:
52
+
Then you will have to implement one interface:
63
53
64
54
- Repositories are the way we decided to hide direct calls to SDK and pagination logic. It's a common abstraction pattern for data retrieval.
65
55
-`remote.common.Enumerator` is used to enumerate resources. It will call the cloud provider SDK to get the list of resources.
66
-
For some resource it could make other call to enrich the resource with additional attributes when driftctl is used in deep mode
67
-
-`remote.common.DetailsFetcher` is used to retrieve resource's details. It makes a call to Terraform provider `ReadResource`.
68
-
This implementation is optional and is only needed if your resource type is to be supported by experimental deep mode.
69
-
Please also note that it exists a generic implementation called `remote.common.GenericDetailsFetcher` that can be used with most resource types.
70
-
71
56
72
57
### Repository
73
58
@@ -126,7 +111,6 @@ Most of the resource returned by enumerator have empty attributes: they only rep
126
111
127
112
**There are exceptions to this**:
128
113
- Sometimes, you will need more information about resources for them to be fetched in the `DetailsFetcher`. For those cases, you will add specific attributes to the map of data.
129
-
- For complex cases (e.g. middlewares) where you would need driftctl to run as expected in deep and non-deep mode, you would need to enumerate resources as well as to fetch manually specific attributes, using the remote SDK, before adding them to the map of data.
130
114
131
115
You can use an already implemented Enumerator as example.
132
116
@@ -192,26 +176,3 @@ Once the enumerator is written you have to add it to the remote initialization l
DetailsFetchers are only used by driftctl experimental deep mode.
199
-
200
-
This is the component that call Terraform provider to retrieve all attributes for each resource.
201
-
We do not want to reimplement what has already been done in each Terraform provider. Thus, you should not call the remote SDK there.
202
-
203
-
If `common.GenericDetailsFetcher` satisfies your needs you should always prefer using it instead of implementing a custom `DetailsFetcher` in a new struct.
204
-
205
-
The `DetailsFetcher` should also be added to `pkg/remote/<providername>/init.go` even if you use the generic version:
0 commit comments