Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cfn-resources/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ require (
github.com/tidwall/pretty v1.2.1
go.mongodb.org/atlas-sdk/v20231115002 v20231115002.1.0
go.mongodb.org/atlas-sdk/v20231115014 v20231115014.0.0
go.mongodb.org/atlas-sdk/v20241113004 v20241113004.1.0
go.mongodb.org/atlas-sdk/v20250312002 v20250312002.0.0
)

require (
Expand Down Expand Up @@ -50,7 +50,7 @@ require (
github.com/segmentio/ksuid v1.0.4 // indirect
github.com/stretchr/objx v0.5.2 // indirect
go.mongodb.org/atlas v0.37.0 // indirect
golang.org/x/oauth2 v0.24.0 // indirect
golang.org/x/oauth2 v0.28.0 // indirect
gopkg.in/validator.v2 v2.0.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
8 changes: 4 additions & 4 deletions cfn-resources/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ go.mongodb.org/atlas-sdk/v20231115002 v20231115002.1.0 h1:x6nnq2pUIP9mN4WLD4/Ese
go.mongodb.org/atlas-sdk/v20231115002 v20231115002.1.0/go.mod h1:el7cm23kEiiw72HAYimhNweKqp/ubHsNJk+Mk30yJhM=
go.mongodb.org/atlas-sdk/v20231115014 v20231115014.0.0 h1:hN7x3m6THf03q/tE48up1j0U/26lJmx+s1LXB/qvHHc=
go.mongodb.org/atlas-sdk/v20231115014 v20231115014.0.0/go.mod h1:pCl46YnWOIde8lq27whXDwUseNeUvtAy3vy5ZDeTcBA=
go.mongodb.org/atlas-sdk/v20241113004 v20241113004.1.0 h1:AvrgNUpVMFnqZZJo4m/Bynr0wlDWM4xjhugCSdX/7mM=
go.mongodb.org/atlas-sdk/v20241113004 v20241113004.1.0/go.mod h1:CABkQ0sbsqRBXR55UwS+0rX91Dx7et0xxq4QBB6qRog=
golang.org/x/oauth2 v0.24.0 h1:KTBBxWqUa0ykRPLtV69rRto9TLXcqYkeswu48x/gvNE=
golang.org/x/oauth2 v0.24.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
go.mongodb.org/atlas-sdk/v20250312002 v20250312002.0.0 h1:KX8PrYp3/PCSxG4NbGLcc3+EsNcfyhcvylGbe/oRlx8=
go.mongodb.org/atlas-sdk/v20250312002 v20250312002.0.0/go.mod h1:HHCmHxHPdJRr1bUXlvRIZbm7M4gRujjur1GnjE44YgA=
golang.org/x/oauth2 v0.28.0 h1:CrgCKl8PPAVtLnU3c+EDw6x11699EWlsDeWNWKdIOkc=
golang.org/x/oauth2 v0.28.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
Expand Down
4 changes: 2 additions & 2 deletions cfn-resources/organization/cmd/resource/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"net/http"
"time"

"go.mongodb.org/atlas-sdk/v20241113004/admin"
"go.mongodb.org/atlas-sdk/v20250312002/admin"

"github.com/aws-cloudformation/cloudformation-cli-go-plugin/cfn/handler"
"github.com/aws/aws-sdk-go/service/cloudformation"
Expand Down Expand Up @@ -230,7 +230,7 @@ func Delete(req handler.Request, prevModel *Model, currentModel *Model) (handler

responseChan := make(chan DeleteResponse, 1)
go func() {
_, response, err := deleteRequest.Execute()
response, err := deleteRequest.Execute()
responseChan <- DeleteResponse{Error: err, Response: response}
}()

Expand Down
13 changes: 8 additions & 5 deletions cfn-resources/resource-policy/cmd/resource/mappings.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@
package resource

import (
"go.mongodb.org/atlas-sdk/v20250312002/admin"

"github.com/mongodb/mongodbatlas-cloudformation-resources/util"
"go.mongodb.org/atlas-sdk/v20241113004/admin"
)

func NewResourcePolicyCreateReq(model *Model) *admin.ApiAtlasResourcePolicyCreate {
if model == nil {
return nil
}
return &admin.ApiAtlasResourcePolicyCreate{
Name: *model.Name,
Policies: *modelPoliciesToSDKPolicies(model.Policies),
Name: *model.Name,
Description: model.Description,
Policies: *modelPoliciesToSDKPolicies(model.Policies),
}
}

Expand All @@ -42,8 +44,9 @@ func NewResourcePolicyUpdateReq(model *Model) *admin.ApiAtlasResourcePolicyEdit
return nil
}
return &admin.ApiAtlasResourcePolicyEdit{
Name: model.Name,
Policies: modelPoliciesToSDKPolicies(model.Policies),
Name: model.Name,
Description: model.Description,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will happen in the update if the description is removed from the template? I guess it will be nil and therefore, not update/delete the description?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, since we don't validate against previous model in CFN at this point, users can still unset the description by setting it to an empty string. It's not ideal but atleast we have a workaround until we have alignment on this.

Policies: modelPoliciesToSDKPolicies(model.Policies),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package resource_test
import (
"testing"

"go.mongodb.org/atlas-sdk/v20241113004/admin"
"go.mongodb.org/atlas-sdk/v20250312002/admin"

"github.com/aws/smithy-go/ptr"
"github.com/mongodb/mongodbatlas-cloudformation-resources/resource-policy/cmd/resource"
Expand Down
1 change: 1 addition & 0 deletions cfn-resources/resource-policy/cmd/resource/model.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions cfn-resources/resource-policy/cmd/resource/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ import (
"fmt"
"net/http"

"go.mongodb.org/atlas-sdk/v20250312002/admin"

"github.com/aws-cloudformation/cloudformation-cli-go-plugin/cfn/handler"
"github.com/aws/aws-sdk-go/service/cloudformation"

"github.com/mongodb/mongodbatlas-cloudformation-resources/util"
"github.com/mongodb/mongodbatlas-cloudformation-resources/util/constants"
progress_events "github.com/mongodb/mongodbatlas-cloudformation-resources/util/progressevent"
"github.com/mongodb/mongodbatlas-cloudformation-resources/util/validator"
"go.mongodb.org/atlas-sdk/v20241113004/admin"
)

var CreateRequiredFields = []string{"OrgId", "Name", "Policies"}
Expand Down Expand Up @@ -139,7 +141,7 @@ func Delete(req handler.Request, prevModel *Model, currentModel *Model) (handler

orgID := currentModel.OrgId
resourcePolicyID := currentModel.Id
_, apiResp, err := conn.ResourcePoliciesApi.DeleteAtlasResourcePolicy(ctx, *orgID, *resourcePolicyID).Execute()
apiResp, err := conn.ResourcePoliciesApi.DeleteAtlasResourcePolicy(ctx, *orgID, *resourcePolicyID).Execute()
if err != nil {
return handleError(apiResp, constants.DELETE, err)
}
Expand Down
12 changes: 12 additions & 0 deletions cfn-resources/resource-policy/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ To declare this entity in your AWS CloudFormation template, use the following sy
"<a href="#createdbyuser" title="CreatedByUser">CreatedByUser</a>" : <i><a href="apiatlasusermetadata.md">ApiAtlasUserMetadata</a></i>,
"<a href="#lastupdatedbyuser" title="LastUpdatedByUser">LastUpdatedByUser</a>" : <i><a href="apiatlasusermetadata.md">ApiAtlasUserMetadata</a></i>,
"<a href="#name" title="Name">Name</a>" : <i>String</i>,
"<a href="#description" title="Description">Description</a>" : <i>String</i>,
"<a href="#orgid" title="OrgId">OrgId</a>" : <i>String</i>,
"<a href="#policies" title="Policies">Policies</a>" : <i>[ <a href="apiatlaspolicy.md">ApiAtlasPolicy</a>, ... ]</i>,
"<a href="#profile" title="Profile">Profile</a>" : <i>String</i>
Expand All @@ -30,6 +31,7 @@ Properties:
<a href="#createdbyuser" title="CreatedByUser">CreatedByUser</a>: <i><a href="apiatlasusermetadata.md">ApiAtlasUserMetadata</a></i>
<a href="#lastupdatedbyuser" title="LastUpdatedByUser">LastUpdatedByUser</a>: <i><a href="apiatlasusermetadata.md">ApiAtlasUserMetadata</a></i>
<a href="#name" title="Name">Name</a>: <i>String</i>
<a href="#description" title="Description">Description</a>: <i>String</i>
<a href="#orgid" title="OrgId">OrgId</a>: <i>String</i>
<a href="#policies" title="Policies">Policies</a>: <i>
- <a href="apiatlaspolicy.md">ApiAtlasPolicy</a></i>
Expand Down Expand Up @@ -64,6 +66,16 @@ _Type_: String

_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

#### Description

Description of the Atlas resource policy.

_Required_: No

_Type_: String

_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

#### OrgId

Unique 24-hexadecimal digit string that identifies the organization that contains your projects. Use the [/orgs](#tag/Organizations/operation/listOrganizations) endpoint to retrieve all organizations to which the authenticated user has access.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@
"type": "string",
"description": "Human-readable label that describes the atlas resource policy."
},
"Description": {
"type": "string",
"description": "Description of the Atlas resource policy."
},
"OrgId": {
"type": "string",
"maxLength": 24,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"Name": "Name",
"OrgId": "OrgId",
"Description": "test description",
"Id": "",
"Profile": "default",
"Policies": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"Name": "Name",
"OrgId": "OrgId",
"Description": "test description updated",
"Id": "",
"Profile": "default",
"Policies": [
Expand Down
2 changes: 1 addition & 1 deletion cfn-resources/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (

admin20231115002 "go.mongodb.org/atlas-sdk/v20231115002/admin"
admin20231115014 "go.mongodb.org/atlas-sdk/v20231115014/admin"
"go.mongodb.org/atlas-sdk/v20241113004/admin"
"go.mongodb.org/atlas-sdk/v20250312002/admin"

"github.com/aws-cloudformation/cloudformation-cli-go-plugin/cfn/handler"
"github.com/aws-cloudformation/cloudformation-cli-go-plugin/cfn/logging"
Expand Down
7 changes: 7 additions & 0 deletions examples/resource-policy/resource-policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
"Type": "String",
"Description": "Resource policy name."
},
"Description": {
"Type": "String",
"Description": "Description of the Atlas resource policy."
},
"Policies": {
"Type": "String",
"Description": "Policies description"
Expand All @@ -34,6 +38,9 @@
"Name": {
"Ref": "Name"
},
"Description": {
"Ref": "Description"
},
"Policies": [
{
"Body": {
Expand Down
Loading