@@ -21,6 +21,8 @@ class Resource extends BaseResource<ResourceModel> {
2121 * CloudFormation invokes this handler when the resource is initially created
2222 * during stack create operations.
2323 *
24+ * See rules: https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/resource-type-test-contract.html#resource-type-test-contract-create
25+ *
2426 * @param session Current AWS session passed through from caller
2527 * @param request The request object for the provisioning request passed to the implementor
2628 * @param callbackContext Custom context object to allow the passing through of additional
@@ -62,6 +64,8 @@ class Resource extends BaseResource<ResourceModel> {
6264 * CloudFormation invokes this handler when the resource is updated
6365 * as part of a stack update operation.
6466 *
67+ * See rules: https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/resource-type-test-contract.html#resource-type-test-contract-update
68+ *
6569 * @param session Current AWS session passed through from caller
6670 * @param request The request object for the provisioning request passed to the implementor
6771 * @param callbackContext Custom context object to allow the passing through of additional
@@ -90,6 +94,8 @@ class Resource extends BaseResource<ResourceModel> {
9094 * the resource is deleted from the stack as part of a stack update operation,
9195 * or the stack itself is deleted.
9296 *
97+ * See rules: https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/resource-type-test-contract.html#resource-type-test-contract-delete
98+ *
9399 * @param session Current AWS session passed through from caller
94100 * @param request The request object for the provisioning request passed to the implementor
95101 * @param callbackContext Custom context object to allow the passing through of additional
@@ -117,6 +123,8 @@ class Resource extends BaseResource<ResourceModel> {
117123 * CloudFormation invokes this handler as part of a stack update operation when
118124 * detailed information about the resource's current state is required.
119125 *
126+ * See rules: https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/resource-type-test-contract.html#resource-type-test-contract-read
127+ *
120128 * @param session Current AWS session passed through from caller
121129 * @param request The request object for the provisioning request passed to the implementor
122130 * @param callbackContext Custom context object to allow the passing through of additional
@@ -134,15 +142,27 @@ class Resource extends BaseResource<ResourceModel> {
134142 typeConfiguration : TypeConfigurationModel ,
135143 ) : Promise < ProgressEvent < ResourceModel , CallbackContext > > {
136144 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 ) ;
139157 return progress ;
140158 }
141159
142160 /**
143161 * CloudFormation invokes this handler when summary information about multiple
144162 * resources of this resource provider is required.
145163 *
164+ * See rules: https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/resource-type-test-contract.html#resource-type-test-contract-list
165+ *
146166 * @param session Current AWS session passed through from caller
147167 * @param request The request object for the provisioning request passed to the implementor
148168 * @param callbackContext Custom context object to allow the passing through of additional
@@ -159,11 +179,26 @@ class Resource extends BaseResource<ResourceModel> {
159179 logger : LoggerProxy ,
160180 typeConfiguration : TypeConfigurationModel ,
161181 ) : 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+ */
164199 const progress = ProgressEvent . builder < ProgressEvent < ResourceModel , CallbackContext > > ( )
165200 . status ( OperationStatus . Success )
166- . resourceModels ( [ model ] )
201+ . resourceModels ( models )
167202 . build ( ) ;
168203 return progress ;
169204 }
0 commit comments