diff --git a/cfn-resources/search-deployment/cmd/resource/mappings.go b/cfn-resources/search-deployment/cmd/resource/mappings.go index db6240d38..0a851ae00 100644 --- a/cfn-resources/search-deployment/cmd/resource/mappings.go +++ b/cfn-resources/search-deployment/cmd/resource/mappings.go @@ -14,9 +14,9 @@ package resource -import admin20231115014 "go.mongodb.org/atlas-sdk/v20231115014/admin" +import "go.mongodb.org/atlas-sdk/v20250312012/admin" -func NewCFNSearchDeployment(prevModel *Model, apiResp *admin20231115014.ApiSearchDeploymentResponse) Model { +func NewCFNSearchDeployment(prevModel *Model, apiResp *admin.ApiSearchDeploymentResponse) Model { respSpecs := apiResp.GetSpecs() resultSpecs := make([]ApiSearchDeploymentSpec, len(respSpecs)) for i := range respSpecs { @@ -25,25 +25,27 @@ func NewCFNSearchDeployment(prevModel *Model, apiResp *admin20231115014.ApiSearc NodeCount: &respSpecs[i].NodeCount, } } + return Model{ - Profile: prevModel.Profile, - ClusterName: prevModel.ClusterName, - ProjectId: prevModel.ProjectId, - Id: apiResp.Id, - Specs: resultSpecs, - StateName: apiResp.StateName, + Profile: prevModel.Profile, + ClusterName: prevModel.ClusterName, + ProjectId: prevModel.ProjectId, + Id: apiResp.Id, + Specs: resultSpecs, + StateName: apiResp.StateName, + EncryptionAtRestProvider: apiResp.EncryptionAtRestProvider, } } -func NewSearchDeploymentReq(model *Model) admin20231115014.ApiSearchDeploymentRequest { +func NewSearchDeploymentReq(model *Model) admin.ApiSearchDeploymentRequest { modelSpecs := model.Specs - requestSpecs := make([]admin20231115014.ApiSearchDeploymentSpec, len(modelSpecs)) + requestSpecs := make([]admin.ApiSearchDeploymentSpec, len(modelSpecs)) for i, spec := range modelSpecs { // Both spec fields are required in CFN model and will be defined - requestSpecs[i] = admin20231115014.ApiSearchDeploymentSpec{ + requestSpecs[i] = admin.ApiSearchDeploymentSpec{ InstanceSize: *spec.InstanceSize, NodeCount: *spec.NodeCount, } } - return admin20231115014.ApiSearchDeploymentRequest{Specs: requestSpecs} + return admin.ApiSearchDeploymentRequest{Specs: requestSpecs} } diff --git a/cfn-resources/search-deployment/cmd/resource/mappings_test.go b/cfn-resources/search-deployment/cmd/resource/mappings_test.go index 556194132..63b751c2e 100644 --- a/cfn-resources/search-deployment/cmd/resource/mappings_test.go +++ b/cfn-resources/search-deployment/cmd/resource/mappings_test.go @@ -19,13 +19,13 @@ import ( "github.com/mongodb/mongodbatlas-cloudformation-resources/search-deployment/cmd/resource" "github.com/stretchr/testify/assert" - admin20231115014 "go.mongodb.org/atlas-sdk/v20231115014/admin" + "go.mongodb.org/atlas-sdk/v20250312012/admin" ) type sdkToCFNModelTestCase struct { prevModel resource.Model expectedModel resource.Model - SDKResp admin20231115014.ApiSearchDeploymentResponse + SDKResp admin.ApiSearchDeploymentResponse name string } @@ -44,15 +44,15 @@ func TestSDKToCFNModel(t *testing.T) { { name: "Complete SDK response", prevModel: resource.Model{ - Profile: admin20231115014.PtrString(profile), - ClusterName: admin20231115014.PtrString(clusterName), - ProjectId: admin20231115014.PtrString(dummyProjectID), + Profile: admin.PtrString(profile), + ClusterName: admin.PtrString(clusterName), + ProjectId: admin.PtrString(dummyProjectID), }, - SDKResp: admin20231115014.ApiSearchDeploymentResponse{ - Id: admin20231115014.PtrString(dummyDeploymentID), - GroupId: admin20231115014.PtrString(dummyProjectID), - StateName: admin20231115014.PtrString(stateName), - Specs: &[]admin20231115014.ApiSearchDeploymentSpec{ + SDKResp: admin.ApiSearchDeploymentResponse{ + Id: admin.PtrString(dummyDeploymentID), + GroupId: admin.PtrString(dummyProjectID), + StateName: admin.PtrString(stateName), + Specs: &[]admin.ApiSearchDeploymentSpec{ { InstanceSize: instanceSize, NodeCount: nodeCount, @@ -60,15 +60,15 @@ func TestSDKToCFNModel(t *testing.T) { }, }, expectedModel: resource.Model{ - Profile: admin20231115014.PtrString(profile), - ClusterName: admin20231115014.PtrString(clusterName), - ProjectId: admin20231115014.PtrString(dummyProjectID), - Id: admin20231115014.PtrString(dummyDeploymentID), - StateName: admin20231115014.PtrString(stateName), + Profile: admin.PtrString(profile), + ClusterName: admin.PtrString(clusterName), + ProjectId: admin.PtrString(dummyProjectID), + Id: admin.PtrString(dummyDeploymentID), + StateName: admin.PtrString(stateName), Specs: []resource.ApiSearchDeploymentSpec{ { - InstanceSize: admin20231115014.PtrString(instanceSize), - NodeCount: admin20231115014.PtrInt(nodeCount), + InstanceSize: admin.PtrString(instanceSize), + NodeCount: admin.PtrInt(nodeCount), }, }, }, @@ -76,22 +76,22 @@ func TestSDKToCFNModel(t *testing.T) { { name: "Empty specs array", prevModel: resource.Model{ - Profile: admin20231115014.PtrString(profile), - ClusterName: admin20231115014.PtrString(clusterName), - ProjectId: admin20231115014.PtrString(dummyProjectID), + Profile: admin.PtrString(profile), + ClusterName: admin.PtrString(clusterName), + ProjectId: admin.PtrString(dummyProjectID), }, - SDKResp: admin20231115014.ApiSearchDeploymentResponse{ - Id: admin20231115014.PtrString(dummyDeploymentID), - GroupId: admin20231115014.PtrString(dummyProjectID), - StateName: admin20231115014.PtrString(stateName), - Specs: &[]admin20231115014.ApiSearchDeploymentSpec{}, + SDKResp: admin.ApiSearchDeploymentResponse{ + Id: admin.PtrString(dummyDeploymentID), + GroupId: admin.PtrString(dummyProjectID), + StateName: admin.PtrString(stateName), + Specs: &[]admin.ApiSearchDeploymentSpec{}, }, expectedModel: resource.Model{ - Profile: admin20231115014.PtrString(profile), - ClusterName: admin20231115014.PtrString(clusterName), - ProjectId: admin20231115014.PtrString(dummyProjectID), - Id: admin20231115014.PtrString(dummyDeploymentID), - StateName: admin20231115014.PtrString(stateName), + Profile: admin.PtrString(profile), + ClusterName: admin.PtrString(clusterName), + ProjectId: admin.PtrString(dummyProjectID), + Id: admin.PtrString(dummyDeploymentID), + StateName: admin.PtrString(stateName), Specs: []resource.ApiSearchDeploymentSpec{}, }, }, @@ -109,25 +109,25 @@ func TestCFNModelToSDK(t *testing.T) { testCases := []struct { model resource.Model name string - expectedSDKReq admin20231115014.ApiSearchDeploymentRequest + expectedSDKReq admin.ApiSearchDeploymentRequest }{ { name: "Complete CFN model", model: resource.Model{ - Profile: admin20231115014.PtrString(profile), - ClusterName: admin20231115014.PtrString(clusterName), - ProjectId: admin20231115014.PtrString(dummyProjectID), - Id: admin20231115014.PtrString(dummyDeploymentID), - StateName: admin20231115014.PtrString(stateName), + Profile: admin.PtrString(profile), + ClusterName: admin.PtrString(clusterName), + ProjectId: admin.PtrString(dummyProjectID), + Id: admin.PtrString(dummyDeploymentID), + StateName: admin.PtrString(stateName), Specs: []resource.ApiSearchDeploymentSpec{ { - InstanceSize: admin20231115014.PtrString(instanceSize), - NodeCount: admin20231115014.PtrInt(nodeCount), + InstanceSize: admin.PtrString(instanceSize), + NodeCount: admin.PtrInt(nodeCount), }, }, }, - expectedSDKReq: admin20231115014.ApiSearchDeploymentRequest{ - Specs: []admin20231115014.ApiSearchDeploymentSpec{ + expectedSDKReq: admin.ApiSearchDeploymentRequest{ + Specs: []admin.ApiSearchDeploymentSpec{ { InstanceSize: instanceSize, NodeCount: nodeCount, @@ -138,15 +138,15 @@ func TestCFNModelToSDK(t *testing.T) { { name: "Empty specs array", model: resource.Model{ - Profile: admin20231115014.PtrString(profile), - ClusterName: admin20231115014.PtrString(clusterName), - ProjectId: admin20231115014.PtrString(dummyProjectID), - Id: admin20231115014.PtrString(dummyDeploymentID), - StateName: admin20231115014.PtrString(stateName), + Profile: admin.PtrString(profile), + ClusterName: admin.PtrString(clusterName), + ProjectId: admin.PtrString(dummyProjectID), + Id: admin.PtrString(dummyDeploymentID), + StateName: admin.PtrString(stateName), Specs: []resource.ApiSearchDeploymentSpec{}, }, - expectedSDKReq: admin20231115014.ApiSearchDeploymentRequest{ - Specs: []admin20231115014.ApiSearchDeploymentSpec{}, + expectedSDKReq: admin.ApiSearchDeploymentRequest{ + Specs: []admin.ApiSearchDeploymentSpec{}, }, }, } diff --git a/cfn-resources/search-deployment/cmd/resource/model.go b/cfn-resources/search-deployment/cmd/resource/model.go index ad25b0af6..e4e00ada3 100644 --- a/cfn-resources/search-deployment/cmd/resource/model.go +++ b/cfn-resources/search-deployment/cmd/resource/model.go @@ -4,12 +4,13 @@ package resource // Model is autogenerated from the json schema type Model struct { - Profile *string `json:",omitempty"` - ClusterName *string `json:",omitempty"` - ProjectId *string `json:",omitempty"` - Id *string `json:",omitempty"` - Specs []ApiSearchDeploymentSpec `json:",omitempty"` - StateName *string `json:",omitempty"` + Profile *string `json:",omitempty"` + ClusterName *string `json:",omitempty"` + ProjectId *string `json:",omitempty"` + Id *string `json:",omitempty"` + Specs []ApiSearchDeploymentSpec `json:",omitempty"` + StateName *string `json:",omitempty"` + EncryptionAtRestProvider *string `json:",omitempty"` } // ApiSearchDeploymentSpec is autogenerated from the json schema diff --git a/cfn-resources/search-deployment/cmd/resource/resource.go b/cfn-resources/search-deployment/cmd/resource/resource.go index 651e0b128..4bcac3259 100644 --- a/cfn-resources/search-deployment/cmd/resource/resource.go +++ b/cfn-resources/search-deployment/cmd/resource/resource.go @@ -20,7 +20,7 @@ import ( "net/http" "strings" - admin20231115014 "go.mongodb.org/atlas-sdk/v20231115014/admin" + "go.mongodb.org/atlas-sdk/v20250312012/admin" "github.com/aws-cloudformation/cloudformation-cli-go-plugin/cfn/handler" "github.com/aws/aws-sdk-go-v2/service/cloudformation/types" @@ -58,7 +58,7 @@ func Create(req handler.Request, prevModel *Model, currentModel *Model) (handler if progressErr != nil { return *progressErr, nil } - connV2 := client.Atlas20231115014 + connV2 := client.AtlasSDK // handling of subsequent retry calls if _, ok := req.CallbackContext[constants.ID]; ok { @@ -68,7 +68,7 @@ func Create(req handler.Request, prevModel *Model, currentModel *Model) (handler projectID := util.SafeString(currentModel.ProjectId) clusterName := util.SafeString(currentModel.ClusterName) apiReq := NewSearchDeploymentReq(currentModel) - apiResp, resp, err := connV2.AtlasSearchApi.CreateAtlasSearchDeployment(context.Background(), projectID, clusterName, &apiReq).Execute() + apiResp, resp, err := connV2.AtlasSearchApi.CreateClusterSearchDeployment(context.Background(), projectID, clusterName, &apiReq).Execute() if err != nil { return handleError(resp, err) } @@ -89,18 +89,29 @@ func Read(req handler.Request, prevModel *Model, currentModel *Model) (handler.P if progressErr != nil { return *progressErr, nil } - connV2 := client.Atlas20231115014 + connV2 := client.AtlasSDK projectID := util.SafeString(currentModel.ProjectId) clusterName := util.SafeString(currentModel.ClusterName) - apiResp, resp, err := connV2.AtlasSearchApi.GetAtlasSearchDeployment(context.Background(), projectID, clusterName).Execute() + apiResp, resp, err := connV2.AtlasSearchApi.GetClusterSearchDeployment(context.Background(), projectID, clusterName).Execute() if err != nil { return handleError(resp, err) } + newModel := NewCFNSearchDeployment(currentModel, apiResp) + + // If Specs is empty, the search deployment has been deleted + // Return NotFound instead of Success + if len(newModel.Specs) == 0 { + return handler.ProgressEvent{ + OperationStatus: handler.Failed, + Message: "Resource not found", + HandlerErrorCode: string(types.HandlerErrorCodeNotFound)}, nil + } + return handler.ProgressEvent{ OperationStatus: handler.Success, - ResourceModel: NewCFNSearchDeployment(currentModel, apiResp), + ResourceModel: newModel, }, nil } @@ -116,7 +127,7 @@ func Update(req handler.Request, prevModel *Model, currentModel *Model) (handler if progressErr != nil { return *progressErr, nil } - connV2 := client.Atlas20231115014 + connV2 := client.AtlasSDK // handling of subsequent retry calls if _, ok := req.CallbackContext[constants.ID]; ok { @@ -126,12 +137,22 @@ func Update(req handler.Request, prevModel *Model, currentModel *Model) (handler projectID := util.SafeString(currentModel.ProjectId) clusterName := util.SafeString(currentModel.ClusterName) apiReq := NewSearchDeploymentReq(currentModel) - apiResp, res, err := connV2.AtlasSearchApi.UpdateAtlasSearchDeployment(context.Background(), projectID, clusterName, &apiReq).Execute() + apiResp, res, err := connV2.AtlasSearchApi.UpdateClusterSearchDeployment(context.Background(), projectID, clusterName, &apiReq).Execute() if err != nil { + // Update should return NotFound if resource doesn't exist - this is already handled by handleError return handleError(res, err) } newModel := NewCFNSearchDeployment(currentModel, apiResp) + + // If Specs is empty, the search deployment has been deleted - return NotFound + if len(newModel.Specs) == 0 { + return handler.ProgressEvent{ + OperationStatus: handler.Failed, + Message: "Resource not found", + HandlerErrorCode: string(types.HandlerErrorCodeNotFound)}, nil + } + return inProgressEvent("Updating Search Deployment", &newModel), nil } @@ -147,7 +168,7 @@ func Delete(req handler.Request, prevModel *Model, currentModel *Model) (handler if progressErr != nil { return *progressErr, nil } - connV2 := client.Atlas20231115014 + connV2 := client.AtlasSDK // handling of subsequent retry calls if _, ok := req.CallbackContext[constants.ID]; ok { @@ -156,7 +177,7 @@ func Delete(req handler.Request, prevModel *Model, currentModel *Model) (handler projectID := util.SafeString(currentModel.ProjectId) clusterName := util.SafeString(currentModel.ClusterName) - if resp, err := connV2.AtlasSearchApi.DeleteAtlasSearchDeployment(context.Background(), projectID, clusterName).Execute(); err != nil { + if resp, err := connV2.AtlasSearchApi.DeleteClusterSearchDeployment(context.Background(), projectID, clusterName).Execute(); err != nil { return handleError(resp, err) } @@ -169,13 +190,13 @@ func List(req handler.Request, prevModel *Model, currentModel *Model) (handler.P // specific handling for search deployment API where 400 status code can include AlreadyExists or DoesNotExist that need specific mapping to CFN error codes func handleError(res *http.Response, err error) (handler.ProgressEvent, error) { - if apiError, ok := admin20231115014.AsError(err); ok && *apiError.Error == http.StatusBadRequest && strings.Contains(*apiError.ErrorCode, SearchDeploymentAlreadyExistsError) { + if apiError, ok := admin.AsError(err); ok && apiError.Error == http.StatusBadRequest && strings.Contains(apiError.ErrorCode, SearchDeploymentAlreadyExistsError) { return handler.ProgressEvent{ OperationStatus: handler.Failed, Message: err.Error(), HandlerErrorCode: string(types.HandlerErrorCodeAlreadyExists)}, nil } - if apiError, ok := admin20231115014.AsError(err); ok && *apiError.Error == http.StatusBadRequest && strings.Contains(*apiError.ErrorCode, SearchDeploymentDoesNotExistsError) { + if apiError, ok := admin.AsError(err); ok && apiError.Error == http.StatusBadRequest && strings.Contains(apiError.ErrorCode, SearchDeploymentDoesNotExistsError) { return handler.ProgressEvent{ OperationStatus: handler.Failed, Message: err.Error(), diff --git a/cfn-resources/search-deployment/cmd/resource/state_transition.go b/cfn-resources/search-deployment/cmd/resource/state_transition.go index 9d4e90e0d..9b4483c27 100644 --- a/cfn-resources/search-deployment/cmd/resource/state_transition.go +++ b/cfn-resources/search-deployment/cmd/resource/state_transition.go @@ -23,15 +23,15 @@ import ( "github.com/mongodb/mongodbatlas-cloudformation-resources/util" "github.com/mongodb/mongodbatlas-cloudformation-resources/util/constants" "github.com/mongodb/mongodbatlas-cloudformation-resources/util/progressevent" - admin20231115014 "go.mongodb.org/atlas-sdk/v20231115014/admin" + "go.mongodb.org/atlas-sdk/v20250312012/admin" ) -func HandleStateTransition(connV2 admin20231115014.APIClient, currentModel *Model, targetState string) handler.ProgressEvent { +func HandleStateTransition(connV2 admin.APIClient, currentModel *Model, targetState string) handler.ProgressEvent { projectID := util.SafeString(currentModel.ProjectId) clusterName := util.SafeString(currentModel.ClusterName) - apiResp, resp, err := connV2.AtlasSearchApi.GetAtlasSearchDeployment(context.Background(), projectID, clusterName).Execute() + apiResp, resp, err := connV2.AtlasSearchApi.GetClusterSearchDeployment(context.Background(), projectID, clusterName).Execute() if err != nil { - if targetState == constants.DeletedState && resp.StatusCode == http.StatusBadRequest && strings.Contains(err.Error(), SearchDeploymentDoesNotExistsError) { + if targetState == constants.DeletedState && resp != nil && resp.StatusCode == http.StatusBadRequest && strings.Contains(err.Error(), SearchDeploymentDoesNotExistsError) { return handler.ProgressEvent{ OperationStatus: handler.Success, ResourceModel: nil, @@ -42,6 +42,17 @@ func HandleStateTransition(connV2 admin20231115014.APIClient, currentModel *Mode } newModel := NewCFNSearchDeployment(currentModel, apiResp) + + // For delete operations, check if Specs is empty - this indicates deletion is complete + // The Atlas API returns 200 with only basic fields (no Specs) when deployment is deleted + if targetState == constants.DeletedState && len(newModel.Specs) == 0 { + return handler.ProgressEvent{ + OperationStatus: handler.Success, + ResourceModel: nil, + Message: constants.Complete, + } + } + if util.SafeString(newModel.StateName) == targetState { return handler.ProgressEvent{ OperationStatus: handler.Success, diff --git a/cfn-resources/search-deployment/cmd/resource/state_transition_test.go b/cfn-resources/search-deployment/cmd/resource/state_transition_test.go index db99f1800..ac883d6eb 100644 --- a/cfn-resources/search-deployment/cmd/resource/state_transition_test.go +++ b/cfn-resources/search-deployment/cmd/resource/state_transition_test.go @@ -21,85 +21,78 @@ import ( "github.com/aws-cloudformation/cloudformation-cli-go-plugin/cfn/handler" "github.com/mongodb/mongodbatlas-cloudformation-resources/search-deployment/cmd/resource" - "github.com/mongodb/mongodbatlas-cloudformation-resources/testutil/mocksvc" "github.com/mongodb/mongodbatlas-cloudformation-resources/util/constants" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - admin20231115014 "go.mongodb.org/atlas-sdk/v20231115014/admin" + "go.mongodb.org/atlas-sdk/v20250312012/admin" + "go.mongodb.org/atlas-sdk/v20250312012/mockadmin" ) type stateTransitionTestCase struct { name string - respModel *admin20231115014.ApiSearchDeploymentResponse + respModel *admin.ApiSearchDeploymentResponse respHTTP *http.Response respError error targetState string expectedEventStatus handler.Status } -var prevModel = resource.Model{ - Profile: admin20231115014.PtrString(profile), - ClusterName: admin20231115014.PtrString(clusterName), - ProjectId: admin20231115014.PtrString(dummyProjectID), +var prevModelStateTransition = resource.Model{ + Profile: admin.PtrString(profile), + ClusterName: admin.PtrString(clusterName), + ProjectId: admin.PtrString(dummyProjectID), } func TestStateTransitionProgressEvents(t *testing.T) { testCases := []stateTransitionTestCase{ { name: "State in WORKING with target IDLE should return in progress event", - respModel: &admin20231115014.ApiSearchDeploymentResponse{ - StateName: admin20231115014.PtrString("UPDATING"), + respModel: &admin.ApiSearchDeploymentResponse{ + Id: admin.PtrString(dummyDeploymentID), + StateName: admin.PtrString("UPDATING"), + Specs: &[]admin.ApiSearchDeploymentSpec{{InstanceSize: instanceSize, NodeCount: nodeCount}}, }, - respHTTP: &http.Response{ - StatusCode: 200, - }, - respError: nil, + respHTTP: &http.Response{StatusCode: 200}, targetState: constants.IdleState, expectedEventStatus: handler.InProgress, }, { name: "State in IDLE with target IDLE should return success event", - respModel: &admin20231115014.ApiSearchDeploymentResponse{ - StateName: admin20231115014.PtrString("IDLE"), - }, - respHTTP: &http.Response{ - StatusCode: 200, + respModel: &admin.ApiSearchDeploymentResponse{ + Id: admin.PtrString(dummyDeploymentID), + StateName: admin.PtrString("IDLE"), + Specs: &[]admin.ApiSearchDeploymentSpec{{InstanceSize: instanceSize, NodeCount: nodeCount}}, }, - respError: nil, + respHTTP: &http.Response{StatusCode: 200}, targetState: constants.IdleState, expectedEventStatus: handler.Success, }, { - name: "400 response with target DELETED should return success event", - respModel: nil, - respHTTP: &http.Response{ - StatusCode: 400, - }, + name: "400 response with target DELETED should return success event", + respHTTP: &http.Response{StatusCode: 400}, respError: errors.New(resource.SearchDeploymentDoesNotExistsError), targetState: constants.DeletedState, expectedEventStatus: handler.Success, }, { name: "State in WORKING with target DELETED should return in progress event", - respModel: &admin20231115014.ApiSearchDeploymentResponse{ - StateName: admin20231115014.PtrString("UPDATING"), + respModel: &admin.ApiSearchDeploymentResponse{ + Id: admin.PtrString(dummyDeploymentID), + StateName: admin.PtrString("UPDATING"), + Specs: &[]admin.ApiSearchDeploymentSpec{{InstanceSize: instanceSize, NodeCount: nodeCount}}, }, - respHTTP: &http.Response{ - StatusCode: 200, - }, - respError: nil, + respHTTP: &http.Response{StatusCode: 200}, targetState: constants.DeletedState, expectedEventStatus: handler.InProgress, }, { name: "State in IDLE with target DELETED should return in progress event", - respModel: &admin20231115014.ApiSearchDeploymentResponse{ - StateName: admin20231115014.PtrString("IDLE"), - }, - respHTTP: &http.Response{ - StatusCode: 200, + respModel: &admin.ApiSearchDeploymentResponse{ + Id: admin.PtrString(dummyDeploymentID), + StateName: admin.PtrString("IDLE"), + Specs: &[]admin.ApiSearchDeploymentSpec{{InstanceSize: instanceSize, NodeCount: nodeCount}}, }, - respError: nil, + respHTTP: &http.Response{StatusCode: 200}, targetState: constants.DeletedState, expectedEventStatus: handler.InProgress, }, @@ -107,12 +100,14 @@ func TestStateTransitionProgressEvents(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - m := mocksvc.NewAtlasSearchApi(t) - m.EXPECT().GetAtlasSearchDeployment(mock.Anything, mock.Anything, mock.Anything).Return(admin20231115014.GetAtlasSearchDeploymentApiRequest{ApiService: m}).Once() - m.EXPECT().GetAtlasSearchDeploymentExecute(mock.Anything).Return(tc.respModel, tc.respHTTP, tc.respError).Once() + mockSearchAPI := mockadmin.NewAtlasSearchApi(t) + req := admin.GetClusterSearchDeploymentApiRequest{ApiService: mockSearchAPI} + mockSearchAPI.EXPECT().GetClusterSearchDeployment(mock.Anything, dummyProjectID, clusterName).Return(req).Once() + mockSearchAPI.EXPECT().GetClusterSearchDeploymentExecute(mock.Anything).Return(tc.respModel, tc.respHTTP, tc.respError).Once() + + client := admin.APIClient{AtlasSearchApi: mockSearchAPI} + eventResult := resource.HandleStateTransition(client, &prevModelStateTransition, tc.targetState) - client := admin20231115014.APIClient{AtlasSearchApi: m} - eventResult := resource.HandleStateTransition(client, &prevModel, tc.targetState) assert.Equal(t, tc.expectedEventStatus, eventResult.OperationStatus) }) } diff --git a/cfn-resources/search-deployment/docs/README.md b/cfn-resources/search-deployment/docs/README.md index ecacad0af..0053a2da8 100644 --- a/cfn-resources/search-deployment/docs/README.md +++ b/cfn-resources/search-deployment/docs/README.md @@ -96,3 +96,7 @@ Unique 24-hexadecimal digit string that identifies the search deployment. Human-readable label that indicates the current operating condition of this search deployment. +#### EncryptionAtRestProvider + +Cloud service provider that manages your customer keys to provide an additional layer of Encryption At Rest for the cluster. + diff --git a/cfn-resources/search-deployment/docs/apisearchdeploymentspec.md b/cfn-resources/search-deployment/docs/apisearchdeploymentspec.md index 80b413e8d..f8c76c71e 100644 --- a/cfn-resources/search-deployment/docs/apisearchdeploymentspec.md +++ b/cfn-resources/search-deployment/docs/apisearchdeploymentspec.md @@ -24,7 +24,7 @@ To declare this entity in your AWS CloudFormation template, use the following sy #### InstanceSize -Hardware specification for the search node instance sizes. The [MongoDB Atlas API](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-createatlassearchdeployment) describes the valid values. More details can also be found in the [Search Node Documentation](https://www.mongodb.com/docs/atlas/cluster-config/multi-cloud-distribution/#search-tier). +Hardware specification for the search node instance sizes. The [MongoDB Atlas API](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/#tag/Atlas-Search/operation/createAtlasSearchDeployment) describes the valid values. More details can also be found in the [Search Node Documentation](https://www.mongodb.com/docs/atlas/cluster-config/multi-cloud-distribution/#search-tier). _Required_: Yes diff --git a/cfn-resources/search-deployment/mongodb-atlas-searchdeployment.json b/cfn-resources/search-deployment/mongodb-atlas-searchdeployment.json index 948bb6717..bd59318e3 100644 --- a/cfn-resources/search-deployment/mongodb-atlas-searchdeployment.json +++ b/cfn-resources/search-deployment/mongodb-atlas-searchdeployment.json @@ -67,6 +67,8 @@ "Specs": { "insertionOrder": false, "type": "array", + "minItems": 1, + "maxItems": 1, "items": { "$ref": "#/definitions/ApiSearchDeploymentSpec", "type": "object" @@ -76,6 +78,10 @@ "StateName": { "type": "string", "description": "Human-readable label that indicates the current operating condition of this search deployment." + }, + "EncryptionAtRestProvider": { + "type": "string", + "description": "Cloud service provider that manages your customer keys to provide an additional layer of Encryption At Rest for the cluster." } }, "primaryIdentifier": [ @@ -96,7 +102,8 @@ ], "readOnlyProperties": [ "/properties/Id", - "/properties/StateName" + "/properties/StateName", + "/properties/EncryptionAtRestProvider" ], "typeName": "MongoDB::Atlas::SearchDeployment", "documentationUrl": "https://github.com/mongodb/mongodbatlas-cloudformation-resources/blob/master/cfn-resources/search-deployment/README.md", diff --git a/examples/search-deployment/search-deployment.json b/examples/search-deployment/search-deployment.json index 9e4f372f1..48fe3bb7a 100644 --- a/examples/search-deployment/search-deployment.json +++ b/examples/search-deployment/search-deployment.json @@ -71,6 +71,15 @@ "StateName" ] } + }, + "SearchDeploymentEncryptionAtRestProvider": { + "Description": "Search Deployment Encryption At Rest Provider", + "Value": { + "Fn::GetAtt": [ + "SearchDeployment", + "EncryptionAtRestProvider" + ] + } } } }