feat: Search Deployment CloudFormation Resource#1520
feat: Search Deployment CloudFormation Resource#1520sivaram-mongodb wants to merge 1 commit intomasterfrom
Conversation
f74ae97 to
487b36b
Compare
487b36b to
a37eee4
Compare
| make build | ||
| sam local start-lambda & | ||
| cfn test --function-name TestEntrypoint --verbose | ||
| cfn test --verbose --enforce-timeout 3600 |
There was a problem hiding this comment.
[q] why the enforce-timeout?
| for i := range respSpecs { | ||
| instanceSize := respSpecs[i].InstanceSize | ||
| // Follow cluster pattern: directly assign NodeCount from API response | ||
| // Reference: mongodbatlas-cloudformation-resources/cfn-resources/cluster/cmd/resource/mappings.go:305,317 |
There was a problem hiding this comment.
not sure, I understand how this is different than the previous implementation as that is using respSpecs as well?
also, I think you can remove this comment as the code is quite self-explanatory
| } | ||
|
|
||
| func Create(req handler.Request, prevModel *Model, currentModel *Model) (handler.ProgressEvent, error) { | ||
| var InitEnvWithClient = func(req handler.Request, currentModel *Model, requiredFields []string) (*admin20250312010.APIClient, *handler.ProgressEvent) { |
There was a problem hiding this comment.
i think we can rename this to InitEnv as this is doing a few things other than initializing the client as well.
| createResp, resp, err := connV2.AtlasSearchApi.CreateClusterSearchDeployment(context.Background(), projectID, clusterName, &apiReq).Execute() | ||
| if err != nil { | ||
| return handleError(resp, err) | ||
| notFound := resp != nil && resp.StatusCode == http.StatusNotFound |
There was a problem hiding this comment.
is StatusNotFound a valid case for the create API?
| alreadyExists := resp != nil && resp.StatusCode == http.StatusConflict && | ||
| strings.Contains(err.Error(), SearchDeploymentAlreadyExistsErrorAPI) | ||
|
|
||
| if alreadyExists || notFound { |
There was a problem hiding this comment.
If the intention here is to handle the transition where creation can take some time, can you extract the logic to a callback function similar to cluster here - https://github.com/mongodb/mongodbatlas-cloudformation-resources/blob/master/cfn-resources/cluster/cmd/resource/resource.go#L255
Otherwise it's not very clear what the logic is trying to accomplish
| projectID := util.SafeString(currentModel.ProjectId) | ||
| clusterName := util.SafeString(currentModel.ClusterName) | ||
|
|
||
| // Check if resource exists before updating (required by contract tests) |
There was a problem hiding this comment.
[q] why is this needed now? How do the existing contract tests running today?
| ) | ||
|
|
||
| func HandleStateTransition(connV2 admin20231115014.APIClient, currentModel *Model, targetState string) handler.ProgressEvent { | ||
| func ValidateProgress(connV2 admin20250312010.APIClient, currentModel *Model, isDelete bool) handler.ProgressEvent { |
There was a problem hiding this comment.
can you please explain the changes in this method?
There was a problem hiding this comment.
The ValidateProgress function follows the flex-cluster pattern :
Uses isDelete bool instead of targetState string — determines target state internally (IdleState for create/update, DeletedState for delete)
Returns handler.ProgressEvent directly (no error return)
Handles nil states safely with a default of DeletedState
For delete operations, returns success without ResourceModel
This aligns with the flex-cluster implementation and is the current pattern for state validation in callback functions.
| Id *string `json:",omitempty"` | ||
| Specs []ApiSearchDeploymentSpec `json:",omitempty"` | ||
| StateName *string `json:",omitempty"` | ||
| Profile *string `json:",omitempty"` |
There was a problem hiding this comment.
can you please update the PR description to include only what has been updated? This is an existing resource & I believe only new attributes have been added. The PR description, however, implies that a new resource is being added.
|
|
||
| Human-readable label that indicates the current operating condition of this search deployment. | ||
|
|
||
| #### EncryptionAtRestProvider |
There was a problem hiding this comment.
can you also update the example for this resource (under /examples/search-deployment) & ensure that works for the testing screenshots in the PR description?
|
|
||
| function usage { | ||
| echo "usage:$0 <project_name>" | ||
| echo "Creates a new project and an Cluster for testing" |
There was a problem hiding this comment.
can you also please update the test input files to use the new attribute?
| clusterName=$(jq -r '.ClusterName' ./inputs/inputs_1_create.json) | ||
| projectId=$(jq -r '.ProjectId' ./inputs/inputs_1_create.json) | ||
|
|
||
| # TEMPORARY: Skip deletion of test cluster/project (only for today's testing - 2025-12-29) |
There was a problem hiding this comment.
nit: would revert this & keep only required changes in the PR to merge
Proposed changes
Added new resource Search Deployment:
Resource Configuration:
The Search Deployment resource enables you to create and manage dedicated search nodes that provide workload isolation for Atlas Search queries. By deploying search nodes, you can separate search workloads from your database workloads, improving overall cluster performance.
Required Properties:
ProjectId: Atlas project identifier (24-hexadecimal characters)ClusterName: Name of the cluster to attach search nodesSpecs: Array of search node specifications (currently limited to 1 element)InstanceSize: Hardware specification for search nodes (e.g., S20_HIGHCPU_NVME, S30_HIGHCPU_NVME)NodeCount: Number of search nodes in the deploymentOptional Properties:
Profile: AWS Secrets Manager profile for Atlas credentials (default: "default")Read-Only Properties:
Id: Unique 24-hexadecimal identifier for the search deploymentStateName: Current operating state (IDLE when ready, DELETED when removed)EncryptionAtRestProvider: Encryption provider for the deployment (AWS, GCP, AZURE, or NONE)Create-Only Properties:
ProjectId,ClusterName,Profile: These cannot be changed after creationConfiguration Examples:
Basic Search Deployment:
cfn testing:
stack testing:
Atlas UI - Before Creation
Atlas UI - After Creation
Jira ticket: CLOUDP-369807
Please include a summary of the fix/feature/change, including any relevant motivation and context.
Link to any related issue(s):
Type of change:
expected)
Manual QA performed:
Required Checklist:
make fmtand formatted my codeworks in Atlas
Further comments