@@ -21,6 +21,8 @@ class Resource extends BaseResource<ResourceModel> {
21
21
* CloudFormation invokes this handler when the resource is initially created
22
22
* during stack create operations.
23
23
*
24
+ * See rules: https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/resource-type-test-contract.html#resource-type-test-contract-create
25
+ *
24
26
* @param session Current AWS session passed through from caller
25
27
* @param request The request object for the provisioning request passed to the implementor
26
28
* @param callbackContext Custom context object to allow the passing through of additional
@@ -62,6 +64,8 @@ class Resource extends BaseResource<ResourceModel> {
62
64
* CloudFormation invokes this handler when the resource is updated
63
65
* as part of a stack update operation.
64
66
*
67
+ * See rules: https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/resource-type-test-contract.html#resource-type-test-contract-update
68
+ *
65
69
* @param session Current AWS session passed through from caller
66
70
* @param request The request object for the provisioning request passed to the implementor
67
71
* @param callbackContext Custom context object to allow the passing through of additional
@@ -90,6 +94,8 @@ class Resource extends BaseResource<ResourceModel> {
90
94
* the resource is deleted from the stack as part of a stack update operation,
91
95
* or the stack itself is deleted.
92
96
*
97
+ * See rules: https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/resource-type-test-contract.html#resource-type-test-contract-delete
98
+ *
93
99
* @param session Current AWS session passed through from caller
94
100
* @param request The request object for the provisioning request passed to the implementor
95
101
* @param callbackContext Custom context object to allow the passing through of additional
@@ -117,6 +123,8 @@ class Resource extends BaseResource<ResourceModel> {
117
123
* CloudFormation invokes this handler as part of a stack update operation when
118
124
* detailed information about the resource's current state is required.
119
125
*
126
+ * See rules: https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/resource-type-test-contract.html#resource-type-test-contract-read
127
+ *
120
128
* @param session Current AWS session passed through from caller
121
129
* @param request The request object for the provisioning request passed to the implementor
122
130
* @param callbackContext Custom context object to allow the passing through of additional
@@ -134,15 +142,27 @@ class Resource extends BaseResource<ResourceModel> {
134
142
typeConfiguration : TypeConfigurationModel ,
135
143
) : Promise < ProgressEvent < ResourceModel , CallbackContext > > {
136
144
const model = new ResourceModel ( request . desiredResourceState ) ;
137
- // TODO: put code here
138
- const progress = ProgressEvent . success < ProgressEvent < ResourceModel , CallbackContext > > ( model ) ;
145
+ model
146
+ /**
147
+ * TODO: put code for getting the specific model from here from just your primary identifier
148
+ * Example:
149
+ *
150
+ * const model = new ResourceModel(request.desiredResourceState);
151
+ * const modelProps = myModelSource.getById(model.getPrimaryIdentifier());
152
+ *
153
+ * const retrievedModel = new ResourceModel(modelProps);
154
+ */
155
+ const retrievedModel = new ResourceModel ( ) ;
156
+ const progress = ProgressEvent . success < ProgressEvent < ResourceModel , CallbackContext > > ( retrievedModel ) ;
139
157
return progress ;
140
158
}
141
159
142
160
/**
143
161
* CloudFormation invokes this handler when summary information about multiple
144
162
* resources of this resource provider is required.
145
163
*
164
+ * See rules: https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/resource-type-test-contract.html#resource-type-test-contract-list
165
+ *
146
166
* @param session Current AWS session passed through from caller
147
167
* @param request The request object for the provisioning request passed to the implementor
148
168
* @param callbackContext Custom context object to allow the passing through of additional
@@ -159,11 +179,26 @@ class Resource extends BaseResource<ResourceModel> {
159
179
logger : LoggerProxy ,
160
180
typeConfiguration : TypeConfigurationModel ,
161
181
) : Promise < ProgressEvent < ResourceModel , CallbackContext > > {
162
- const model = new ResourceModel ( request . desiredResourceState ) ;
163
- // TODO: put code here
182
+ const nextToken = new ResourceModel ( request . nextToken ) ;
183
+ const models : ResourceModel [ ] = [ ]
184
+ /**
185
+ * TODO: put code for getting all models controlled by this handler
186
+ * Example:
187
+ *
188
+ * const { modelsProps, nextTokenFromMyService } = await myModelSource.getN(10, request.nextToken);
189
+ * const models = modelsProps.map((mProps) => {
190
+ * return new ResourceModel(mProps);
191
+ * });
192
+ *
193
+ * const progress = ProgressEvent.builder<ProgressEvent<ResourceModel, CallbackContext>>()
194
+ * .status(OperationStatus.Success)
195
+ * .resourceModels(models)
196
+ * .nextToken(nextTokenFromMyService)
197
+ * .build();
198
+ */
164
199
const progress = ProgressEvent . builder < ProgressEvent < ResourceModel , CallbackContext > > ( )
165
200
. status ( OperationStatus . Success )
166
- . resourceModels ( [ model ] )
201
+ . resourceModels ( models )
167
202
. build ( ) ;
168
203
return progress ;
169
204
}
0 commit comments