Skip to content

Commit 67e3d4f

Browse files
maasthaCopilot
andauthored
chore: Updates package aws-sdk-go to aws-sdk-go-v2 - follow up (#1491)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent a9f2666 commit 67e3d4f

54 files changed

Lines changed: 308 additions & 339 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/contract-testing.yaml

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ jobs:
2828
project: ${{ steps.filter.outputs.project }}
2929
resource-policy: ${{ steps.filter.outputs.resource-policy }}
3030
search-deployment: ${{ steps.filter.outputs.search-deployment }}
31-
serverless-private-endpoint: ${{ steps.filter.outputs.serverless-private-endpoint }}
3231
stream-connection: ${{ steps.filter.outputs.stream-connection }}
3332
stream-instance: ${{ steps.filter.outputs.stream-instance }}
3433
steps:
@@ -72,8 +71,6 @@ jobs:
7271
- 'cfn-resources/resource-policy/**'
7372
search-deployment:
7473
- 'cfn-resources/search-deployment/**'
75-
serverless-private-endpoint:
76-
- 'cfn-resources/serverless-private-endpoint/**'
7774
stream-connection:
7875
- 'cfn-resources/stream-connection/**'
7976
stream-instance:
@@ -774,48 +771,6 @@ jobs:
774771
775772
cat inputs/inputs_1_create.json
776773
777-
make run-contract-testing
778-
make delete-test-resources
779-
serverless-private-endpoint:
780-
needs: change-detection
781-
if: ${{ needs.change-detection.outputs. serverless-private-endpoint == 'true' }}
782-
runs-on: ubuntu-latest
783-
steps:
784-
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3
785-
- uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c
786-
with:
787-
go-version-file: 'cfn-resources/go.mod'
788-
- name: setup Atlas CLI
789-
uses: mongodb/atlas-github-action@e3c9e0204659bafbb3b65e1eb1ee745cca0e9f3b
790-
- uses: aws-actions/setup-sam@c71dd89d980e49367c70391e8ada4353f52f2800
791-
with:
792-
use-installer: true
793-
- uses: aws-actions/configure-aws-credentials@61815dcd50bd041e203e49132bacad1fd04d2708
794-
with:
795-
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_TEST_ENV }}
796-
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_TEST_ENV }}
797-
aws-region: eu-west-1
798-
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548
799-
with:
800-
python-version: '3.9'
801-
cache: 'pip' # caching pip dependencies
802-
- run: pip install cloudformation-cli cloudformation-cli-go-plugin
803-
- name: Run the Contract test
804-
shell: bash
805-
env:
806-
MONGODB_ATLAS_PUBLIC_API_KEY: ${{ secrets.CLOUD_DEV_PUBLIC_KEY }}
807-
MONGODB_ATLAS_PRIVATE_API_KEY: ${{ secrets.CLOUD_DEV_PRIVATE_KEY }}
808-
MONGODB_ATLAS_ORG_ID: ${{ secrets.CLOUD_DEV_ORG_ID }}
809-
MONGODB_ATLAS_TEAM_ID: 641490b0207f4d22f4d8f2fd
810-
MONGODB_ATLAS_OPS_MANAGER_URL: https://cloud-dev.mongodb.com/
811-
MONGODB_ATLAS_PROFILE: cfn-cloud-dev-github-action
812-
run: |
813-
pushd cfn-resources/serverless-private-endpoint
814-
make create-test-resources
815-
816-
cat inputs/inputs_1_create.json
817-
cat inputs/inputs_1_update.json
818-
819774
make run-contract-testing
820775
make delete-test-resources
821776
stream-connection:

cfn-resources/autogen/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const (
4343
deleteReqFields = "DeleteRequiredFields"
4444
listReqFields = "ListRequiredFields"
4545
handler = "github.com/aws-cloudformation/cloudformation-cli-go-plugin/cfn/handler"
46-
cloudformation = "github.com/aws/aws-sdk-go/service/cloudformation"
46+
cloudformation = "github.com/aws/aws-sdk-go-v2/service/cloudformation/types"
4747
util = "github.com/mongodb/mongodbatlas-cloudformation-resources/util"
4848
validator = "github.com/mongodb/mongodbatlas-cloudformation-resources/util/validator"
4949
progressEvent = "github.com/mongodb/mongodbatlas-cloudformation-resources/util/progressevent"

cfn-resources/cloud-backup-schedule/test/cfn-test-create-inputs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export MCLI_PROJECT_ID=$projectId
3333
clusterId=$(atlas clusters list --projectId "${projectId}" --output json | jq --arg NAME "${clusterName}" -r '.results[]? | select(.name==$NAME) | .id')
3434
if [ -z "$clusterId" ]; then
3535
echo "creating cluster.."
36-
atlas clusters create "${clusterName}" --projectId "${projectId}" --backup --provider AWS --region US_EAST_1 --members 3 --tier M10 --mdbVersion 5.0 --diskSizeGB 10 --output=json
36+
atlas clusters create "${clusterName}" --projectId "${projectId}" --backup --provider AWS --region US_EAST_1 --members 3 --tier M10 --diskSizeGB 10 --output=json
3737
atlas clusters watch "${clusterName}" --projectId "${projectId}"
3838
echo -e "Created Cluster \"${clusterName}\""
3939
fi

cfn-resources/cloud-backup-snapshot/test/cfn-test-create-inputs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ if [ -z "$projectId" ]; then
4343
echo -e "Cant find project \"${projectName}\"\n"
4444
fi
4545

46-
atlas clusters create "${clusterName}" --projectId "${projectId}" --backup --provider AWS --region US_EAST_1 --members 3 --tier M10 --mdbVersion 5.0 --diskSizeGB 10 --output=json
46+
atlas clusters create "${clusterName}" --projectId "${projectId}" --backup --provider AWS --region US_EAST_1 --members 3 --tier M10 --diskSizeGB 10 --output=json
4747
atlas clusters watch "${clusterName}" --projectId "${projectId}"
4848
echo -e "Created Cluster \"${clusterName}\""
4949

cfn-resources/database-user/cmd/resource/resource.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import (
1919
"fmt"
2020

2121
"github.com/aws-cloudformation/cloudformation-cli-go-plugin/cfn/handler"
22-
"github.com/aws/aws-sdk-go/aws"
23-
"github.com/aws/aws-sdk-go/service/cloudformation"
22+
"github.com/aws/aws-sdk-go-v2/aws"
23+
"github.com/aws/aws-sdk-go-v2/service/cloudformation/types"
2424
"github.com/mongodb/mongodbatlas-cloudformation-resources/util"
2525
"github.com/mongodb/mongodbatlas-cloudformation-resources/util/constants"
2626
"github.com/mongodb/mongodbatlas-cloudformation-resources/util/logger"
@@ -63,7 +63,7 @@ func Create(req handler.Request, prevModel *Model, currentModel *Model) (handler
6363
return handler.ProgressEvent{
6464
OperationStatus: handler.Failed,
6565
Message: fmt.Sprintf("Error Creating resource: %s", err.Error()),
66-
HandlerErrorCode: cloudformation.HandlerErrorCodeInvalidRequest}, nil
66+
HandlerErrorCode: string(types.HandlerErrorCodeInvalidRequest)}, nil
6767
}
6868

6969
groupID := *currentModel.ProjectId
@@ -172,7 +172,7 @@ func Update(req handler.Request, prevModel *Model, currentModel *Model) (handler
172172
return handler.ProgressEvent{
173173
OperationStatus: handler.Failed,
174174
Message: fmt.Sprintf("Error Creating resource: %s", err.Error()),
175-
HandlerErrorCode: cloudformation.HandlerErrorCodeInvalidRequest}, nil
175+
HandlerErrorCode: string(types.HandlerErrorCodeInvalidRequest)}, nil
176176
}
177177

178178
groupID := *currentModel.ProjectId

cfn-resources/encryption-at-rest/cmd/resource/resource.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@ import (
2222
"math/big"
2323
"strconv"
2424

25+
admin20231115002 "go.mongodb.org/atlas-sdk/v20231115002/admin"
26+
2527
"github.com/aws-cloudformation/cloudformation-cli-go-plugin/cfn/handler"
26-
"github.com/aws/aws-sdk-go/aws"
27-
"github.com/aws/aws-sdk-go/service/cloudformation"
28+
"github.com/aws/aws-sdk-go-v2/aws"
29+
"github.com/aws/aws-sdk-go-v2/service/cloudformation/types"
30+
2831
"github.com/mongodb/mongodbatlas-cloudformation-resources/util"
2932
"github.com/mongodb/mongodbatlas-cloudformation-resources/util/constants"
3033
"github.com/mongodb/mongodbatlas-cloudformation-resources/util/progressevent"
3134
"github.com/mongodb/mongodbatlas-cloudformation-resources/util/validator"
32-
admin20231115002 "go.mongodb.org/atlas-sdk/v20231115002/admin"
3335
)
3436

3537
var (
@@ -174,13 +176,13 @@ func List(req handler.Request, prevModel *Model, currentModel *Model) (handler.P
174176
}
175177

176178
func validateExist(info *admin20231115002.EncryptionAtRest) *handler.ProgressEvent {
177-
if info != nil && info.AwsKms != nil && aws.BoolValue(info.AwsKms.Enabled) {
179+
if info != nil && info.AwsKms != nil && aws.ToBool(info.AwsKms.Enabled) {
178180
return nil
179181
}
180182
return &handler.ProgressEvent{
181183
OperationStatus: handler.Failed,
182184
Message: "Resource Not Found",
183-
HandlerErrorCode: cloudformation.HandlerErrorCodeNotFound}
185+
HandlerErrorCode: string(types.HandlerErrorCodeNotFound)}
184186
}
185187

186188
func randInt64() int64 {

cfn-resources/federated-database-instance/cmd/resource/resource.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import (
2020
"net/http"
2121

2222
"github.com/aws-cloudformation/cloudformation-cli-go-plugin/cfn/handler"
23-
"github.com/aws/aws-sdk-go/aws"
24-
"github.com/aws/aws-sdk-go/service/cloudformation"
23+
"github.com/aws/aws-sdk-go-v2/aws"
24+
"github.com/aws/aws-sdk-go-v2/service/cloudformation/types"
2525
"github.com/mongodb/mongodbatlas-cloudformation-resources/profile"
2626
"github.com/mongodb/mongodbatlas-cloudformation-resources/util"
2727
"github.com/mongodb/mongodbatlas-cloudformation-resources/util/constants"
@@ -231,13 +231,13 @@ func handleError(response *http.Response, method string, err error) (handler.Pro
231231
return handler.ProgressEvent{
232232
OperationStatus: handler.Failed,
233233
Message: fmt.Sprintf("%s:%s", method, err.Error()),
234-
HandlerErrorCode: cloudformation.HandlerErrorCodeAlreadyExists}, nil
234+
HandlerErrorCode: string(types.HandlerErrorCodeAlreadyExists)}, nil
235235
}
236236
if response.StatusCode == http.StatusNotFound {
237237
return handler.ProgressEvent{
238238
OperationStatus: handler.Failed,
239239
Message: fmt.Sprintf("%s:%s", method, err.Error()),
240-
HandlerErrorCode: cloudformation.HandlerErrorCodeNotFound}, nil
240+
HandlerErrorCode: string(types.HandlerErrorCodeNotFound)}, nil
241241
}
242242

243243
return progress_events.GetFailedEventByResponse(fmt.Sprintf("Error during execution : %s", err.Error()),

cfn-resources/federated-database-instance/test/cfn-test-create-inputs-with-clusters.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ if atlas clusters describe "${cluster1}" --projectId "${projectId}"; then
5454
echo "Cluster found"
5555
else
5656
echo "Cluster1 not found, creating..."
57-
atlas clusters create "${cluster1}" --projectId "${projectId}" --backup --provider AWS --region US_EAST_1 --members 3 --tier M10 --mdbVersion 5.0 --diskSizeGB 10 --output=json
57+
atlas clusters create "${cluster1}" --projectId "${projectId}" --backup --provider AWS --region US_EAST_1 --members 3 --tier M10 --diskSizeGB 10 --output=json
5858
atlas clusters watch "${cluster1}" --projectId "${projectId}"
5959
echo -e "Created Cluster \"${cluster1}\""
6060
fi
@@ -63,7 +63,7 @@ if atlas clusters describe "${cluster2}" --projectId "${projectId}"; then
6363
echo "Cluster found"
6464
else
6565
echo "Cluster2 not found, creating..."
66-
atlas clusters create "${cluster2}" --projectId "${projectId}" --backup --provider AWS --region US_EAST_1 --members 3 --tier M10 --mdbVersion 5.0 --diskSizeGB 10 --output=json
66+
atlas clusters create "${cluster2}" --projectId "${projectId}" --backup --provider AWS --region US_EAST_1 --members 3 --tier M10 --diskSizeGB 10 --output=json
6767
atlas clusters watch "${cluster2}" --projectId "${projectId}"
6868
echo -e "Created Cluster \"${cluster2}\""
6969
fi

cfn-resources/federated-query-limit/cmd/resource/resource.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import (
2020
"net/http"
2121

2222
"github.com/aws-cloudformation/cloudformation-cli-go-plugin/cfn/handler"
23-
"github.com/aws/aws-sdk-go/aws"
24-
"github.com/aws/aws-sdk-go/service/cloudformation"
23+
"github.com/aws/aws-sdk-go-v2/aws"
24+
"github.com/aws/aws-sdk-go-v2/service/cloudformation/types"
2525
"github.com/mongodb/mongodbatlas-cloudformation-resources/profile"
2626
"github.com/mongodb/mongodbatlas-cloudformation-resources/util"
2727
"github.com/mongodb/mongodbatlas-cloudformation-resources/util/constants"
@@ -74,7 +74,7 @@ func Create(req handler.Request, prevModel *Model, currentModel *Model) (handler
7474
return handler.ProgressEvent{
7575
OperationStatus: handler.Failed,
7676
Message: AlreadyExists,
77-
HandlerErrorCode: cloudformation.HandlerErrorCodeAlreadyExists}, nil
77+
HandlerErrorCode: string(types.HandlerErrorCodeAlreadyExists)}, nil
7878
}
7979
// create and update uses same PATCH API
8080
return createOrUpdateQueryLimit(currentModel, atlas, CREATE)
@@ -136,7 +136,7 @@ func Update(req handler.Request, prevModel *Model, currentModel *Model) (handler
136136
return handler.ProgressEvent{
137137
OperationStatus: handler.Failed,
138138
Message: DoesntExists,
139-
HandlerErrorCode: cloudformation.HandlerErrorCodeNotFound}, nil
139+
HandlerErrorCode: string(types.HandlerErrorCodeNotFound)}, nil
140140
}
141141
return createOrUpdateQueryLimit(currentModel, atlas, UPDATE)
142142
}
@@ -224,7 +224,7 @@ func handleError(response *http.Response, method string, err error) (handler.Pro
224224
return handler.ProgressEvent{
225225
OperationStatus: handler.Failed,
226226
Message: errMsg,
227-
HandlerErrorCode: cloudformation.HandlerErrorCodeAlreadyExists}, nil
227+
HandlerErrorCode: string(types.HandlerErrorCodeAlreadyExists)}, nil
228228
}
229229
return progress_events.GetFailedEventByResponse(errMsg, response), nil
230230
}

cfn-resources/federated-settings-org-role-mapping/cmd/resource/resource.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ import (
2121
"net/http"
2222
"strings"
2323

24+
admin20231115002 "go.mongodb.org/atlas-sdk/v20231115002/admin"
25+
2426
"github.com/aws-cloudformation/cloudformation-cli-go-plugin/cfn/handler"
25-
"github.com/aws/aws-sdk-go/service/cloudformation"
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-
admin20231115002 "go.mongodb.org/atlas-sdk/v20231115002/admin"
3133
)
3234

3335
var CreateRequiredFields = []string{constants.FederationSettingsID, constants.OrgID, constants.ExternalGroupName, constants.RoleAssignments}
@@ -70,7 +72,7 @@ func Create(req handler.Request, prevModel *Model, currentModel *Model) (handler
7072
if err != nil {
7173
if resp.StatusCode == http.StatusBadRequest && strings.Contains(err.Error(), "DUPLICATE_ROLE_MAPPING") {
7274
return progressevent.GetFailedEventByCode("Resource already exists",
73-
cloudformation.HandlerErrorCodeAlreadyExists), nil
75+
string(types.HandlerErrorCodeAlreadyExists)), nil
7476
}
7577
return progressevent.GetFailedEventByResponse(fmt.Sprintf("Error getting resource : %s", err.Error()),
7678
resp), nil
@@ -132,15 +134,15 @@ func Update(req handler.Request, prevModel *Model, currentModel *Model) (handler
132134
roleMappingID := currentModel.Id
133135

134136
if !isRoleMappingExists(currentModel, client) {
135-
return progressevent.GetFailedEventByCode("Not Found", cloudformation.HandlerErrorCodeNotFound), nil
137+
return progressevent.GetFailedEventByCode("Not Found", string(types.HandlerErrorCodeNotFound)), nil
136138
}
137139

138140
if (currentModel.RoleAssignments) == nil || len(currentModel.RoleAssignments) == 0 {
139141
err := errors.New(RoleAssignementShouldBeSet)
140142
return handler.ProgressEvent{
141143
OperationStatus: handler.Failed,
142144
Message: err.Error(),
143-
HandlerErrorCode: cloudformation.HandlerErrorCodeInvalidRequest}, nil
145+
HandlerErrorCode: string(types.HandlerErrorCodeInvalidRequest)}, nil
144146
}
145147
// preparing model request
146148
requestBody, _, _ := modelToRoleMappingRequest(currentModel)
@@ -175,7 +177,7 @@ func Delete(req handler.Request, prevModel *Model, currentModel *Model) (handler
175177

176178
// Check if already exist
177179
if !isRoleMappingExists(currentModel, client) {
178-
return progressevent.GetFailedEventByCode("Not Found", cloudformation.HandlerErrorCodeNotFound), nil
180+
return progressevent.GetFailedEventByCode("Not Found", string(types.HandlerErrorCodeNotFound)), nil
179181
}
180182

181183
federationSettingsID := currentModel.FederationSettingsId

0 commit comments

Comments
 (0)