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
1 change: 1 addition & 0 deletions cfn-resources/organization/cmd/resource/model.go

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

12 changes: 7 additions & 5 deletions cfn-resources/organization/cmd/resource/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func Delete(req handler.Request, prevModel *Model, currentModel *Model) (handler

// If exists
_, response, err = currentModel.getOrgDetails(ctx, conn, currentModel)
if err != nil && response.StatusCode == http.StatusUnauthorized {
if err != nil && util.StatusUnauthorized(response) {
return handleError(response, constants.DELETE, err)
}

Expand Down Expand Up @@ -283,7 +283,7 @@ func deleteCallback(ctx context.Context, conn *admin.APIClient, currentModel *Mo
// Read before delete
org, response, err := currentModel.getOrgDetails(ctx, conn, currentModel)
if err != nil {
if response.StatusCode == http.StatusUnauthorized {
if util.StatusUnauthorized(response) {
return handler.ProgressEvent{
OperationStatus: handler.Success,
Message: DeleteCompleted,
Expand Down Expand Up @@ -333,28 +333,29 @@ func (model *Model) getOrgDetails(ctx context.Context, conn *admin.APIClient, cu
model.MultiFactorAuthRequired = settings.MultiFactorAuthRequired
model.RestrictEmployeeAccess = settings.RestrictEmployeeAccess
model.GenAIFeaturesEnabled = settings.GenAIFeaturesEnabled
model.SecurityContact = settings.SecurityContact

return model, response, nil
}

func handleError(response *http.Response, method constants.CfnFunctions, err error) (handler.ProgressEvent, error) {
errMsg := fmt.Sprintf("%s error:%s", method, err.Error())
_, _ = logger.Warn(errMsg)
if response.StatusCode == http.StatusConflict {
if util.StatusConflict(response) {
return handler.ProgressEvent{
OperationStatus: handler.Failed,
Message: errMsg,
HandlerErrorCode: string(types.HandlerErrorCodeAlreadyExists)}, nil
}

if response.StatusCode == http.StatusUnauthorized {
if util.StatusUnauthorized(response) {
return handler.ProgressEvent{
OperationStatus: handler.Failed,
Message: "Not found",
HandlerErrorCode: string(types.HandlerErrorCodeNotFound)}, nil
}

if response.StatusCode == http.StatusBadRequest {
if util.StatusBadRequest(response) {
return handler.ProgressEvent{
OperationStatus: handler.Failed,
Message: errMsg,
Expand All @@ -377,6 +378,7 @@ func newOrganizationSettings(model *Model) *admin.OrganizationSettings {
MultiFactorAuthRequired: model.MultiFactorAuthRequired,
RestrictEmployeeAccess: model.RestrictEmployeeAccess,
GenAIFeaturesEnabled: model.GenAIFeaturesEnabled,
SecurityContact: model.SecurityContact,
}
}

Expand Down
14 changes: 13 additions & 1 deletion cfn-resources/organization/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ To declare this entity in your AWS CloudFormation template, use the following sy
"<a href="#isdeleted" title="IsDeleted">IsDeleted</a>" : <i>Boolean</i>,
"<a href="#apiaccesslistrequired" title="ApiAccessListRequired">ApiAccessListRequired</a>" : <i>Boolean</i>,
"<a href="#multifactorauthrequired" title="MultiFactorAuthRequired">MultiFactorAuthRequired</a>" : <i>Boolean</i>,
"<a href="#restrictemployeeaccess" title="RestrictEmployeeAccess">RestrictEmployeeAccess</a>" : <i>Boolean</i>
"<a href="#restrictemployeeaccess" title="RestrictEmployeeAccess">RestrictEmployeeAccess</a>" : <i>Boolean</i>,
"<a href="#securitycontact" title="SecurityContact">SecurityContact</a>" : <i>String</i>
}
}
</pre>
Expand All @@ -45,6 +46,7 @@ Properties:
<a href="#apiaccesslistrequired" title="ApiAccessListRequired">ApiAccessListRequired</a>: <i>Boolean</i>
<a href="#multifactorauthrequired" title="MultiFactorAuthRequired">MultiFactorAuthRequired</a>: <i>Boolean</i>
<a href="#restrictemployeeaccess" title="RestrictEmployeeAccess">RestrictEmployeeAccess</a>: <i>Boolean</i>
<a href="#securitycontact" title="SecurityContact">SecurityContact</a>: <i>String</i>
</pre>

## Properties
Expand Down Expand Up @@ -173,6 +175,16 @@ _Type_: Boolean

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

#### SecurityContact

Email address of the security contact for the organization.

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

## Return Values

### Fn::GetAtt
Expand Down
4 changes: 4 additions & 0 deletions cfn-resources/organization/mongodb-atlas-organization.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@
"RestrictEmployeeAccess": {
"type": "boolean",
"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/."
},
"SecurityContact": {
"type": "string",
"description": "Email address of the security contact for the organization."
}
},
"additionalProperties": false,
Expand Down
3 changes: 2 additions & 1 deletion cfn-resources/organization/test/inputs_1_create.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
"RestrictEmployeeAccess": "false",
"ApiAccessListRequired": "false",
"SkipDefaultAlertsSettings": "true",
"GenAIFeaturesEnabled": "true"
"GenAIFeaturesEnabled": "true",
"SecurityContact": "security-test@example.com"
}
3 changes: 2 additions & 1 deletion cfn-resources/organization/test/inputs_1_update.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
"RestrictEmployeeAccess": "true",
"ApiAccessListRequired": "false",
"SkipDefaultAlertsSettings": "false",
"GenAIFeaturesEnabled": "false"
"GenAIFeaturesEnabled": "false",
"SecurityContact": "security-updated@example.com"
}
4 changes: 4 additions & 0 deletions cfn-resources/util/http_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ func StatusBadRequest(resp *http.Response) bool {
func StatusServiceUnavailable(resp *http.Response) bool {
return resp != nil && resp.StatusCode == http.StatusServiceUnavailable
}

func StatusUnauthorized(resp *http.Response) bool {
return resp != nil && resp.StatusCode == http.StatusUnauthorized
}
8 changes: 8 additions & 0 deletions examples/organization/organization.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@
],
"Default": "true",
"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/"
},
"SecurityContact": {
"Type": "String",
"Description": "Email address of the security contact for the organization.",
"Default": ""
}
},
"Mappings": {},
Expand Down Expand Up @@ -139,6 +144,9 @@
},
"GenAIFeaturesEnabled": {
"Ref": "GenAIFeaturesEnabled"
},
"SecurityContact": {
"Ref": "SecurityContact"
}
}
}
Expand Down
Loading