@@ -20,14 +20,16 @@ import (
2020 "fmt"
2121 "time"
2222
23+ admin20231115014 "go.mongodb.org/atlas-sdk/v20231115014/admin"
24+
2325 "github.com/aws-cloudformation/cloudformation-cli-go-plugin/cfn/handler"
24- "github.com/aws/aws-sdk-go/aws"
25- "github.com/aws/aws-sdk-go/service/cloudformation"
26+ "github.com/aws/aws-sdk-go-v2/aws"
27+ "github.com/aws/aws-sdk-go-v2/service/cloudformation/types"
28+
2629 "github.com/mongodb/mongodbatlas-cloudformation-resources/util"
2730 "github.com/mongodb/mongodbatlas-cloudformation-resources/util/constants"
2831 "github.com/mongodb/mongodbatlas-cloudformation-resources/util/progressevent"
2932 "github.com/mongodb/mongodbatlas-cloudformation-resources/util/validator"
30- admin20231115014 "go.mongodb.org/atlas-sdk/v20231115014/admin"
3133)
3234
3335var CreateRequiredFields = []string {constants .SnapshotID , constants .DeliveryType , constants .InstanceType , constants .InstanceName }
@@ -53,7 +55,7 @@ func validateModel(fields []string, model *Model) *handler.ProgressEvent {
5355
5456 if * model .InstanceType != clusterInstanceType && * model .InstanceType != serverlessInstanceType {
5557 pe := progressevent .GetFailedEventByCode (fmt .Sprintf ("InstanceType must be %s or %s" , clusterInstanceType , serverlessInstanceType ),
56- cloudformation .HandlerErrorCodeInvalidRequest )
58+ string ( types .HandlerErrorCodeInvalidRequest ) )
5759 return & pe
5860 }
5961
@@ -74,7 +76,7 @@ func Create(req handler.Request, prevModel *Model, currentModel *Model) (handler
7476
7577 err := currentModel .validateAsynchronousProperties ()
7678 if err != nil {
77- return progressevent .GetFailedEventByCode (err .Error (), cloudformation .HandlerErrorCodeInvalidRequest ), err
79+ return progressevent .GetFailedEventByCode (err .Error (), string ( types .HandlerErrorCodeInvalidRequest ) ), err
7880 }
7981
8082 if _ , idExists := req .CallbackContext [constants .StateName ]; idExists {
@@ -110,7 +112,7 @@ func Create(req handler.Request, prevModel *Model, currentModel *Model) (handler
110112 currentModel .Id = server .Id
111113 }
112114
113- if aws .BoolValue (currentModel .EnableSynchronousCreation ) {
115+ if aws .ToBool (currentModel .EnableSynchronousCreation ) {
114116 return progressevent .GetInProgressProgressEvent (
115117 "Create in progress" ,
116118 map [string ]interface {}{
@@ -146,11 +148,11 @@ func Read(req handler.Request, prevModel *Model, currentModel *Model) (handler.P
146148 return * err , nil
147149 }
148150
149- if aws .BoolValue (currentModel .Cancelled ) {
151+ if aws .ToBool (currentModel .Cancelled ) {
150152 return handler.ProgressEvent {
151153 OperationStatus : handler .Failed ,
152154 Message : "The job is in status cancelled, Cannot read a cancelled job" ,
153- HandlerErrorCode : cloudformation .HandlerErrorCodeNotFound }, nil
155+ HandlerErrorCode : string ( types .HandlerErrorCodeNotFound ) }, nil
154156 }
155157
156158 return handler.ProgressEvent {
@@ -180,14 +182,14 @@ func Delete(req handler.Request, prevModel *Model, currentModel *Model) (handler
180182 return * err , nil
181183 }
182184
183- if aws .BoolValue (currentModel .Cancelled ) {
185+ if aws .ToBool (currentModel .Cancelled ) {
184186 return handler.ProgressEvent {
185187 OperationStatus : handler .Failed ,
186188 Message : "The job is in status cancelled, Cannot delete a cancelled job" ,
187- HandlerErrorCode : cloudformation .HandlerErrorCodeNotFound }, nil
189+ HandlerErrorCode : string ( types .HandlerErrorCodeNotFound ) }, nil
188190 }
189191
190- if util .IsStringPresent (currentModel .FinishedAt ) || aws .BoolValue (currentModel .Failed ) || aws .BoolValue (currentModel .Expired ) {
192+ if util .IsStringPresent (currentModel .FinishedAt ) || aws .ToBool (currentModel .Failed ) || aws .ToBool (currentModel .Expired ) {
191193 return handler.ProgressEvent {
192194 OperationStatus : handler .Success ,
193195 Message : "The resource is finished, failed, or expired" ,
@@ -242,7 +244,7 @@ func List(req handler.Request, prevModel *Model, currentModel *Model) (handler.P
242244 InstanceName : currentModel .InstanceName ,
243245 Profile : currentModel .Profile ,
244246 }
245- if ! aws .BoolValue (job .Cancelled ) && ! aws .BoolValue (job .Expired ) {
247+ if ! aws .ToBool (job .Cancelled ) && ! aws .ToBool (job .Expired ) {
246248 updateModelServerless (model , job )
247249 models = append (models , model )
248250 }
@@ -262,7 +264,7 @@ func List(req handler.Request, prevModel *Model, currentModel *Model) (handler.P
262264 InstanceName : currentModel .InstanceName ,
263265 Profile : currentModel .Profile ,
264266 }
265- if ! aws .BoolValue (job .Cancelled ) && ! aws .BoolValue (job .Expired ) {
267+ if ! aws .ToBool (job .Cancelled ) && ! aws .ToBool (job .Expired ) {
266268 updateModelServer (model , job )
267269 models = append (models , model )
268270 }
@@ -283,11 +285,11 @@ func (model *Model) validateAsynchronousProperties() error {
283285 }
284286
285287 if model .SynchronousCreationOptions .CallbackDelaySeconds == nil {
286- model .SynchronousCreationOptions .CallbackDelaySeconds = aws . Int (defaultBackSeconds )
288+ model .SynchronousCreationOptions .CallbackDelaySeconds = util . IntPtr (defaultBackSeconds )
287289 }
288290
289291 if model .SynchronousCreationOptions .TimeOutInSeconds == nil {
290- model .SynchronousCreationOptions .TimeOutInSeconds = aws . Int (defaultTimeOutInSeconds )
292+ model .SynchronousCreationOptions .TimeOutInSeconds = util . IntPtr (defaultTimeOutInSeconds )
291293 }
292294
293295 if model .SynchronousCreationOptions .ReturnSuccessIfTimeOut == nil {
@@ -321,7 +323,7 @@ func createCallback(client *util.MongoDBClient, currentModel *Model, jobID, star
321323 }
322324 }
323325
324- return progressevent .GetFailedEventByCode ("Create failed with Timout" , cloudformation .HandlerErrorCodeInternalFailure )
326+ return progressevent .GetFailedEventByCode ("Create failed with Timout" , string ( types .HandlerErrorCodeInternalFailure ) )
325327 }
326328
327329 return progressevent .GetInProgressProgressEvent (
0 commit comments