Skip to content

Commit 2941cea

Browse files
ParthasarathyVsivaram-mongodb
andauthored
feat: update organization resource (#1533)
Co-authored-by: sivaram-mongodb <sivaram@mongodb.com>
1 parent 276eb28 commit 2941cea

8 files changed

Lines changed: 41 additions & 8 deletions

File tree

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

Lines changed: 1 addition & 0 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: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ func Delete(req handler.Request, prevModel *Model, currentModel *Model) (handler
217217

218218
// If exists
219219
_, response, err = currentModel.getOrgDetails(ctx, conn, currentModel)
220-
if err != nil && response.StatusCode == http.StatusUnauthorized {
220+
if err != nil && util.StatusUnauthorized(response) {
221221
return handleError(response, constants.DELETE, err)
222222
}
223223

@@ -283,7 +283,7 @@ func deleteCallback(ctx context.Context, conn *admin.APIClient, currentModel *Mo
283283
// Read before delete
284284
org, response, err := currentModel.getOrgDetails(ctx, conn, currentModel)
285285
if err != nil {
286-
if response.StatusCode == http.StatusUnauthorized {
286+
if util.StatusUnauthorized(response) {
287287
return handler.ProgressEvent{
288288
OperationStatus: handler.Success,
289289
Message: DeleteCompleted,
@@ -333,28 +333,29 @@ func (model *Model) getOrgDetails(ctx context.Context, conn *admin.APIClient, cu
333333
model.MultiFactorAuthRequired = settings.MultiFactorAuthRequired
334334
model.RestrictEmployeeAccess = settings.RestrictEmployeeAccess
335335
model.GenAIFeaturesEnabled = settings.GenAIFeaturesEnabled
336+
model.SecurityContact = settings.SecurityContact
336337

337338
return model, response, nil
338339
}
339340

340341
func handleError(response *http.Response, method constants.CfnFunctions, err error) (handler.ProgressEvent, error) {
341342
errMsg := fmt.Sprintf("%s error:%s", method, err.Error())
342343
_, _ = logger.Warn(errMsg)
343-
if response.StatusCode == http.StatusConflict {
344+
if util.StatusConflict(response) {
344345
return handler.ProgressEvent{
345346
OperationStatus: handler.Failed,
346347
Message: errMsg,
347348
HandlerErrorCode: string(types.HandlerErrorCodeAlreadyExists)}, nil
348349
}
349350

350-
if response.StatusCode == http.StatusUnauthorized {
351+
if util.StatusUnauthorized(response) {
351352
return handler.ProgressEvent{
352353
OperationStatus: handler.Failed,
353354
Message: "Not found",
354355
HandlerErrorCode: string(types.HandlerErrorCodeNotFound)}, nil
355356
}
356357

357-
if response.StatusCode == http.StatusBadRequest {
358+
if util.StatusBadRequest(response) {
358359
return handler.ProgressEvent{
359360
OperationStatus: handler.Failed,
360361
Message: errMsg,
@@ -377,6 +378,7 @@ func newOrganizationSettings(model *Model) *admin.OrganizationSettings {
377378
MultiFactorAuthRequired: model.MultiFactorAuthRequired,
378379
RestrictEmployeeAccess: model.RestrictEmployeeAccess,
379380
GenAIFeaturesEnabled: model.GenAIFeaturesEnabled,
381+
SecurityContact: model.SecurityContact,
380382
}
381383
}
382384

cfn-resources/organization/docs/README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ To declare this entity in your AWS CloudFormation template, use the following sy
2323
"<a href="#isdeleted" title="IsDeleted">IsDeleted</a>" : <i>Boolean</i>,
2424
"<a href="#apiaccesslistrequired" title="ApiAccessListRequired">ApiAccessListRequired</a>" : <i>Boolean</i>,
2525
"<a href="#multifactorauthrequired" title="MultiFactorAuthRequired">MultiFactorAuthRequired</a>" : <i>Boolean</i>,
26-
"<a href="#restrictemployeeaccess" title="RestrictEmployeeAccess">RestrictEmployeeAccess</a>" : <i>Boolean</i>
26+
"<a href="#restrictemployeeaccess" title="RestrictEmployeeAccess">RestrictEmployeeAccess</a>" : <i>Boolean</i>,
27+
"<a href="#securitycontact" title="SecurityContact">SecurityContact</a>" : <i>String</i>
2728
}
2829
}
2930
</pre>
@@ -45,6 +46,7 @@ Properties:
4546
<a href="#apiaccesslistrequired" title="ApiAccessListRequired">ApiAccessListRequired</a>: <i>Boolean</i>
4647
<a href="#multifactorauthrequired" title="MultiFactorAuthRequired">MultiFactorAuthRequired</a>: <i>Boolean</i>
4748
<a href="#restrictemployeeaccess" title="RestrictEmployeeAccess">RestrictEmployeeAccess</a>: <i>Boolean</i>
49+
<a href="#securitycontact" title="SecurityContact">SecurityContact</a>: <i>String</i>
4850
</pre>
4951

5052
## Properties
@@ -173,6 +175,16 @@ _Type_: Boolean
173175

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

178+
#### SecurityContact
179+
180+
Email address of the security contact for the organization.
181+
182+
_Required_: No
183+
184+
_Type_: String
185+
186+
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)
187+
176188
## Return Values
177189

178190
### Fn::GetAtt

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@
8383
"RestrictEmployeeAccess": {
8484
"type": "boolean",
8585
"description": "Flag that indicates whether to block MongoDB Support from accessing Atlas infrastructure for any deployment in the specified organization without explicit permission. Once this setting is turned on, you can grant MongoDB Support a 24-hour bypass access to the Atlas deployment to resolve support issues. To learn more, see: https://www.mongodb.com/docs/atlas/security-restrict-support-access/."
86+
},
87+
"SecurityContact": {
88+
"type": "string",
89+
"description": "Email address of the security contact for the organization."
8690
}
8791
},
8892
"additionalProperties": false,

cfn-resources/organization/test/inputs_1_create.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
"RestrictEmployeeAccess": "false",
1515
"ApiAccessListRequired": "false",
1616
"SkipDefaultAlertsSettings": "true",
17-
"GenAIFeaturesEnabled": "true"
17+
"GenAIFeaturesEnabled": "true",
18+
"SecurityContact": "security-test@example.com"
1819
}

cfn-resources/organization/test/inputs_1_update.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
"RestrictEmployeeAccess": "true",
1515
"ApiAccessListRequired": "false",
1616
"SkipDefaultAlertsSettings": "false",
17-
"GenAIFeaturesEnabled": "false"
17+
"GenAIFeaturesEnabled": "false",
18+
"SecurityContact": "security-updated@example.com"
1819
}

cfn-resources/util/http_status.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,7 @@ func StatusBadRequest(resp *http.Response) bool {
3131
func StatusServiceUnavailable(resp *http.Response) bool {
3232
return resp != nil && resp.StatusCode == http.StatusServiceUnavailable
3333
}
34+
35+
func StatusUnauthorized(resp *http.Response) bool {
36+
return resp != nil && resp.StatusCode == http.StatusUnauthorized
37+
}

examples/organization/organization.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@
8181
],
8282
"Default": "true",
8383
"Description": "Flag that indicates whether this organization has access to generative AI features. This setting only applies to Atlas Commercial and defaults to `true`. With this setting on, Project Owners may be able to enable or disable individual AI features at the project level. To learn more, see https://www.mongodb.com/docs/generative-ai-faq/"
84+
},
85+
"SecurityContact": {
86+
"Type": "String",
87+
"Description": "Email address of the security contact for the organization.",
88+
"Default": ""
8489
}
8590
},
8691
"Mappings": {},
@@ -139,6 +144,9 @@
139144
},
140145
"GenAIFeaturesEnabled": {
141146
"Ref": "GenAIFeaturesEnabled"
147+
},
148+
"SecurityContact": {
149+
"Ref": "SecurityContact"
142150
}
143151
}
144152
}

0 commit comments

Comments
 (0)