Skip to content

Commit 5611aa5

Browse files
committed
Adds SkipDefaultAlertsSettings to the schema
1 parent d6eb42f commit 5611aa5

File tree

4 files changed

+42
-22
lines changed

4 files changed

+42
-22
lines changed

cfn-resources/organization/cmd/resource/model.go

Lines changed: 12 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cfn-resources/organization/cmd/resource/resource.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"net/http"
2222
"time"
2323

24-
"go.mongodb.org/atlas-sdk/v20231115014/admin"
24+
"go.mongodb.org/atlas-sdk/v20241113004/admin"
2525

2626
"github.com/aws-cloudformation/cloudformation-cli-go-plugin/cfn/handler"
2727
"github.com/aws/aws-sdk-go/service/cloudformation"
@@ -76,7 +76,7 @@ func Create(req handler.Request, prevModel *Model, currentModel *Model) (handler
7676
if peErr != nil {
7777
return *peErr, nil
7878
}
79-
conn := client.Atlas20231115014
79+
conn := client.AtlasSDK
8080
ctx := context.Background()
8181

8282
_, _, err := secrets.Get(&req, *currentModel.AwsSecretName)
@@ -91,9 +91,10 @@ func Create(req handler.Request, prevModel *Model, currentModel *Model) (handler
9191

9292
// Set the roles from model
9393
orgInput := &admin.CreateOrganizationRequest{
94-
ApiKey: apikeyInputs,
95-
OrgOwnerId: currentModel.OrgOwnerId,
96-
Name: *currentModel.Name,
94+
ApiKey: apikeyInputs,
95+
OrgOwnerId: currentModel.OrgOwnerId,
96+
Name: *currentModel.Name,
97+
SkipDefaultAlertsSettings: currentModel.SkipDefaultAlertsSettings,
9798
}
9899
if currentModel.FederatedSettingsId != nil {
99100
orgInput.FederationSettingsId = currentModel.FederatedSettingsId
@@ -121,7 +122,7 @@ func Create(req handler.Request, prevModel *Model, currentModel *Model) (handler
121122
if peErr != nil {
122123
return *peErr, nil
123124
}
124-
conn = newOrgClient.Atlas20231115014
125+
conn = newOrgClient.AtlasSDK
125126
if _, _, errUpdate := conn.OrganizationsApi.UpdateOrganizationSettings(ctx, orgID, newOrganizationSettings(currentModel)).Execute(); errUpdate != nil {
126127
return handleError(response, constants.CREATE, err)
127128
}
@@ -145,7 +146,7 @@ func Read(req handler.Request, prevModel *Model, currentModel *Model) (handler.P
145146
return *peErr, nil
146147
}
147148

148-
model, response, err := currentModel.getOrgDetails(context.Background(), newOrgClient.Atlas20231115014, currentModel)
149+
model, response, err := currentModel.getOrgDetails(context.Background(), newOrgClient.AtlasSDK, currentModel)
149150
if err != nil {
150151
return handleError(response, constants.READ, err)
151152
}
@@ -167,11 +168,11 @@ func Update(req handler.Request, prevModel *Model, currentModel *Model) (handler
167168
if peErr != nil {
168169
return *peErr, nil
169170
}
170-
conn := newOrgClient.Atlas20231115014
171+
conn := newOrgClient.AtlasSDK
171172
ctx := context.Background()
172173

173-
atlasOrg := admin.AtlasOrganization{Id: currentModel.OrgId, Name: *currentModel.Name}
174-
if _, response, err := conn.OrganizationsApi.RenameOrganization(ctx, *currentModel.OrgId, &atlasOrg).Execute(); err != nil {
174+
atlasOrg := admin.AtlasOrganization{Id: currentModel.OrgId, Name: *currentModel.Name, SkipDefaultAlertsSettings: currentModel.SkipDefaultAlertsSettings}
175+
if _, response, err := conn.OrganizationsApi.UpdateOrganization(ctx, *currentModel.OrgId, &atlasOrg).Execute(); err != nil {
175176
return handleError(response, constants.UPDATE, err)
176177
}
177178

@@ -197,7 +198,7 @@ func Delete(req handler.Request, prevModel *Model, currentModel *Model) (handler
197198
if peErr != nil {
198199
return *peErr, nil
199200
}
200-
conn := newOrgClient.Atlas20231115014
201+
conn := newOrgClient.AtlasSDK
201202
ctx := context.Background()
202203

203204
// Callback
@@ -301,6 +302,7 @@ func (model *Model) getOrgDetails(ctx context.Context, conn *admin.APIClient, cu
301302
model.Name = util.Pointer(org.Name)
302303
model.OrgId = org.Id
303304
model.IsDeleted = org.IsDeleted
305+
model.SkipDefaultAlertsSettings = org.SkipDefaultAlertsSettings
304306

305307
settings, _, err := conn.OrganizationsApi.GetOrganizationSettings(ctx, org.GetId()).Execute()
306308
if err != nil {

cfn-resources/organization/docs/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ To declare this entity in your AWS CloudFormation template, use the following sy
1818
"<a href="#orgownerid" title="OrgOwnerId">OrgOwnerId</a>" : <i>String</i>,
1919
"<a href="#profile" title="Profile">Profile</a>" : <i>String</i>,
2020
"<a href="#awssecretname" title="AwsSecretName">AwsSecretName</a>" : <i>String</i>,
21+
"<a href="#skipdefaultalertssettings" title="SkipDefaultAlertsSettings">SkipDefaultAlertsSettings</a>" : <i>Boolean</i>,
2122
"<a href="#isdeleted" title="IsDeleted">IsDeleted</a>" : <i>Boolean</i>,
2223
"<a href="#apiaccesslistrequired" title="ApiAccessListRequired">ApiAccessListRequired</a>" : <i>Boolean</i>,
2324
"<a href="#multifactorauthrequired" title="MultiFactorAuthRequired">MultiFactorAuthRequired</a>" : <i>Boolean</i>,
@@ -37,6 +38,7 @@ Properties:
3738
<a href="#orgownerid" title="OrgOwnerId">OrgOwnerId</a>: <i>String</i>
3839
<a href="#profile" title="Profile">Profile</a>: <i>String</i>
3940
<a href="#awssecretname" title="AwsSecretName">AwsSecretName</a>: <i>String</i>
41+
<a href="#skipdefaultalertssettings" title="SkipDefaultAlertsSettings">SkipDefaultAlertsSettings</a>: <i>Boolean</i>
4042
<a href="#isdeleted" title="IsDeleted">IsDeleted</a>: <i>Boolean</i>
4143
<a href="#apiaccesslistrequired" title="ApiAccessListRequired">ApiAccessListRequired</a>: <i>Boolean</i>
4244
<a href="#multifactorauthrequired" title="MultiFactorAuthRequired">MultiFactorAuthRequired</a>: <i>Boolean</i>
@@ -109,6 +111,16 @@ _Type_: String
109111

110112
_Update requires_: [Replacement](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-replacement)
111113

114+
#### SkipDefaultAlertsSettings
115+
116+
Disables automatic alert creation. When set to `true`, Atlas doesn't automatically create organization-level alerts. Defaults to `true` for new Atlas Organizations created with the provider to prevent infrastructure drift caused by creation of new alerts.
117+
118+
_Required_: No
119+
120+
_Type_: Boolean
121+
122+
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)
123+
112124
#### IsDeleted
113125

114126
Flag that indicates whether this organization has been deleted.

cfn-resources/organization/mongodb-atlas-organization.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@
5151
"description": "AwsSecretName used to set newly created Org credentials information.",
5252
"default": "default"
5353
},
54+
"SkipDefaultAlertsSettings": {
55+
"type": "boolean",
56+
"description": "Disables automatic alert creation. When set to `true`, Atlas doesn't automatically create organization-level alerts. Defaults to `true` for new Atlas Organizations created with the provider to prevent infrastructure drift caused by creation of new alerts.",
57+
"default": "true"
58+
},
5459
"OrgId": {
5560
"type": "string",
5661
"description": "Unique 24-hexadecimal digit string that identifies the organization that contains your projects. Use the /orgs endpoint to retrieve all organizations to which the authenticated user has access.",

0 commit comments

Comments
 (0)