Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
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 (
"github.com/mongodb/mongodbatlas-cloudformation-resources/util"
"go.mongodb.org/atlas-sdk/v20250312002/admin"

"github.com/mongodb/mongodbatlas-cloudformation-resources/util"
)

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
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.

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
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