Skip to content

Commit bedbda0

Browse files
authored
chore: Updates cluster resource to use cluster APIs to support certain advanced configuration attributes (#1344)
1 parent 271dfe9 commit bedbda0

File tree

411 files changed

+149979
-21
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

411 files changed

+149979
-21
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ rpdk.log
88
#compiled file
99
bin/
1010

11-
#vendor
12-
vendor/
13-
1411
create.json
1512
delete.json
1613
update.json

cfn-resources/cluster/cmd/resource/mappings.go

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ import (
1919
"fmt"
2020
"reflect"
2121

22+
"go.mongodb.org/atlas-sdk/v20231115014/admin"
23+
2224
"github.com/aws-cloudformation/cloudformation-cli-go-plugin/cfn/handler"
2325
"github.com/aws/aws-sdk-go/service/cloudformation"
26+
"github.com/spf13/cast"
27+
2428
"github.com/mongodb/mongodbatlas-cloudformation-resources/util"
2529
"github.com/mongodb/mongodbatlas-cloudformation-resources/util/constants"
26-
"github.com/spf13/cast"
27-
"go.mongodb.org/atlas-sdk/v20231115014/admin"
2830
)
2931

3032
func mapClusterToModel(model *Model, cluster *admin.AdvancedClusterDescription) {
@@ -374,20 +376,27 @@ func flattenPrivateEndpoint(pes *[]admin.ClusterDescriptionConnectionStringsPriv
374376
return privateEndpoints
375377
}
376378

377-
func flattenProcessArgs(p *admin.ClusterDescriptionProcessArgs) *ProcessArgs {
378-
return &ProcessArgs{
379+
func flattenProcessArgs(p *admin.ClusterDescriptionProcessArgs, cluster *admin.AdvancedClusterDescription) *ProcessArgs {
380+
res := &ProcessArgs{
379381
DefaultReadConcern: p.DefaultReadConcern,
380382
DefaultWriteConcern: p.DefaultWriteConcern,
381383
FailIndexKeyTooLong: p.FailIndexKeyTooLong,
382384
JavascriptEnabled: p.JavascriptEnabled,
383-
MinimumEnabledTLSProtocol: p.MinimumEnabledTlsProtocol,
384385
NoTableScan: p.NoTableScan,
385386
OplogSizeMB: p.OplogSizeMB,
386387
SampleSizeBIConnector: p.SampleSizeBIConnector,
387388
SampleRefreshIntervalBIConnector: p.SampleRefreshIntervalBIConnector,
388389
OplogMinRetentionHours: p.OplogMinRetentionHours,
389390
TransactionLifetimeLimitSeconds: util.Int64PtrToIntPtr(p.TransactionLifetimeLimitSeconds),
390391
}
392+
393+
if advConfig := cluster.AdvancedConfiguration; advConfig != nil {
394+
res.MinimumEnabledTLSProtocol = advConfig.MinimumEnabledTlsProtocol
395+
res.TlsCipherConfigMode = advConfig.TlsCipherConfigMode
396+
res.CustomOpensslCipherConfigTls12 = advConfig.GetCustomOpensslCipherConfigTls12()
397+
}
398+
399+
return res
391400
}
392401

393402
func flattenLabels(clusterLabels []admin.ComponentLabel) []Labels {
@@ -412,9 +421,7 @@ func expandAdvancedSettings(processArgs ProcessArgs) *admin.ClusterDescriptionPr
412421
args.DefaultWriteConcern = processArgs.DefaultWriteConcern
413422
}
414423
args.JavascriptEnabled = processArgs.JavascriptEnabled
415-
if processArgs.MinimumEnabledTLSProtocol != nil {
416-
args.MinimumEnabledTlsProtocol = processArgs.MinimumEnabledTLSProtocol
417-
}
424+
418425
args.NoTableScan = processArgs.NoTableScan
419426

420427
if processArgs.OplogSizeMB != nil {
@@ -593,9 +600,25 @@ func setClusterRequest(currentModel *Model) (*admin.AdvancedClusterDescription,
593600
clusterRequest.Tags = tags
594601

595602
clusterRequest.TerminationProtectionEnabled = currentModel.TerminationProtectionEnabled
603+
604+
clusterRequest.AdvancedConfiguration = expandClusterAdvancedConfiguration(*currentModel.AdvancedSettings)
596605
return clusterRequest, nil
597606
}
598607

608+
func expandClusterAdvancedConfiguration(processArgs ProcessArgs) *admin.ApiAtlasClusterAdvancedConfiguration {
609+
var args admin.ApiAtlasClusterAdvancedConfiguration
610+
611+
if processArgs.MinimumEnabledTLSProtocol != nil {
612+
args.MinimumEnabledTlsProtocol = processArgs.MinimumEnabledTLSProtocol
613+
}
614+
if processArgs.TlsCipherConfigMode != nil {
615+
args.TlsCipherConfigMode = processArgs.TlsCipherConfigMode
616+
}
617+
args.CustomOpensslCipherConfigTls12 = &processArgs.CustomOpensslCipherConfigTls12
618+
619+
return &args
620+
}
621+
599622
func AddReplicationSpecIDs(src, dest []admin.ReplicationSpec) *[]admin.ReplicationSpec {
600623
zoneToID := map[string]string{}
601624
providerRegionToID := map[string]string{}

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

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

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,18 @@ import (
2121
"net/http"
2222
"strings"
2323

24+
"go.mongodb.org/atlas-sdk/v20231115014/admin"
25+
2426
"github.com/aws-cloudformation/cloudformation-cli-go-plugin/cfn/handler"
2527
"github.com/aws/aws-sdk-go/aws"
2628
"github.com/aws/aws-sdk-go/service/cloudformation"
29+
"github.com/spf13/cast"
30+
2731
"github.com/mongodb/mongodbatlas-cloudformation-resources/util"
2832
"github.com/mongodb/mongodbatlas-cloudformation-resources/util/constants"
2933
log "github.com/mongodb/mongodbatlas-cloudformation-resources/util/logger"
3034
"github.com/mongodb/mongodbatlas-cloudformation-resources/util/progressevent"
3135
"github.com/mongodb/mongodbatlas-cloudformation-resources/util/validator"
32-
"github.com/spf13/cast"
33-
"go.mongodb.org/atlas-sdk/v20231115014/admin"
3436
)
3537

3638
const (
@@ -309,7 +311,7 @@ func List(req handler.Request, prevModel *Model, currentModel *Model) (handler.P
309311
return progressevent.GetFailedEventByResponse(fmt.Sprintf("Error creating resource : %s", err.Error()),
310312
res), nil
311313
}
312-
model.AdvancedSettings = flattenProcessArgs(processArgs)
314+
model.AdvancedSettings = flattenProcessArgs(processArgs, &clusterResults[i])
313315
models[i] = model
314316
}
315317

@@ -395,7 +397,7 @@ func readCluster(ctx context.Context, client *util.MongoDBClient, currentModel *
395397
if errr != nil || resp.StatusCode != http.StatusOK {
396398
return currentModel, resp, errr
397399
}
398-
currentModel.AdvancedSettings = flattenProcessArgs(processArgs)
400+
currentModel.AdvancedSettings = flattenProcessArgs(processArgs, cluster)
399401
}
400402
return currentModel, res, err
401403
}

cfn-resources/cluster/docs/processargs.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ To declare this entity in your AWS CloudFormation template, use the following sy
1515
"<a href="#failindexkeytoolong" title="FailIndexKeyTooLong">FailIndexKeyTooLong</a>" : <i>Boolean</i>,
1616
"<a href="#javascriptenabled" title="JavascriptEnabled">JavascriptEnabled</a>" : <i>Boolean</i>,
1717
"<a href="#minimumenabledtlsprotocol" title="MinimumEnabledTLSProtocol">MinimumEnabledTLSProtocol</a>" : <i>String</i>,
18+
"<a href="#tlscipherconfigmode" title="TlsCipherConfigMode">TlsCipherConfigMode</a>" : <i>String</i>,
19+
"<a href="#customopensslcipherconfigtls12" title="CustomOpensslCipherConfigTls12">CustomOpensslCipherConfigTls12</a>" : <i>[ String, ... ]</i>,
1820
"<a href="#notablescan" title="NoTableScan">NoTableScan</a>" : <i>Boolean</i>,
1921
"<a href="#oplogsizemb" title="OplogSizeMB">OplogSizeMB</a>" : <i>Integer</i>,
2022
"<a href="#samplesizebiconnector" title="SampleSizeBIConnector">SampleSizeBIConnector</a>" : <i>Integer</i>,
@@ -32,6 +34,9 @@ To declare this entity in your AWS CloudFormation template, use the following sy
3234
<a href="#failindexkeytoolong" title="FailIndexKeyTooLong">FailIndexKeyTooLong</a>: <i>Boolean</i>
3335
<a href="#javascriptenabled" title="JavascriptEnabled">JavascriptEnabled</a>: <i>Boolean</i>
3436
<a href="#minimumenabledtlsprotocol" title="MinimumEnabledTLSProtocol">MinimumEnabledTLSProtocol</a>: <i>String</i>
37+
<a href="#tlscipherconfigmode" title="TlsCipherConfigMode">TlsCipherConfigMode</a>: <i>String</i>
38+
<a href="#customopensslcipherconfigtls12" title="CustomOpensslCipherConfigTls12">CustomOpensslCipherConfigTls12</a>: <i>
39+
- String</i>
3540
<a href="#notablescan" title="NoTableScan">NoTableScan</a>: <i>Boolean</i>
3641
<a href="#oplogsizemb" title="OplogSizeMB">OplogSizeMB</a>: <i>Integer</i>
3742
<a href="#samplesizebiconnector" title="SampleSizeBIConnector">SampleSizeBIConnector</a>: <i>Integer</i>
@@ -92,6 +97,26 @@ _Type_: String
9297

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

100+
#### TlsCipherConfigMode
101+
102+
The TLS cipher suite configuration mode. Valid values include `CUSTOM` or `DEFAULT`. The `DEFAULT` mode uses the default cipher suites. The `CUSTOM` mode allows you to specify custom cipher suites for both TLS 1.2 and TLS 1.3. To unset, this should be set back to `DEFAULT`.
103+
104+
_Required_: No
105+
106+
_Type_: String
107+
108+
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)
109+
110+
#### CustomOpensslCipherConfigTls12
111+
112+
The custom OpenSSL cipher suite list for TLS 1.2. This field is only valid when `tls_cipher_config_mode` is set to `CUSTOM`.
113+
114+
_Required_: No
115+
116+
_Type_: List of String
117+
118+
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)
119+
95120
#### NoTableScan
96121

97122
Flag that indicates whether the cluster disables executing any query that requires a collection scan to return results.

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,18 @@
249249
"type": "string",
250250
"description": "Minimum Transport Layer Security (TLS) version that the cluster accepts for incoming connections. Clusters using TLS 1.0 or 1.1 should consider setting TLS 1.2 as the minimum TLS protocol version."
251251
},
252+
"TlsCipherConfigMode": {
253+
"type": "string",
254+
"description": "The TLS cipher suite configuration mode. Valid values include `CUSTOM` or `DEFAULT`. The `DEFAULT` mode uses the default cipher suites. The `CUSTOM` mode allows you to specify custom cipher suites for both TLS 1.2 and TLS 1.3. To unset, this should be set back to `DEFAULT`."
255+
},
256+
"CustomOpensslCipherConfigTls12": {
257+
"type": "array",
258+
"insertionOrder": false,
259+
"items": {
260+
"type": "string"
261+
},
262+
"description": "The custom OpenSSL cipher suite list for TLS 1.2. This field is only valid when `tls_cipher_config_mode` is set to `CUSTOM`."
263+
},
252264
"NoTableScan": {
253265
"type": "boolean",
254266
"description": "Flag that indicates whether the cluster disables executing any query that requires a collection scan to return results."

cfn-resources/cluster/test/inputs_1_update.template.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
"DefaultWriteConcern": "1",
88
"JavascriptEnabled": "false",
99
"MinimumEnabledTLSProtocol": "TLS1_2",
10+
"TlsCipherConfigMode": "CUSTOM",
11+
"CustomOpensslCipherConfigTls12": [
12+
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
13+
"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384"
14+
],
1015
"NoTableScan": "false",
1116
"OplogSizeMB": "4000",
1217
"SampleSizeBIConnector": "110",

cfn-resources/go.mod

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ module github.com/mongodb/mongodbatlas-cloudformation-resources
22

33
go 1.23.1
44

5+
// Replacing with local copy of Atlas SDK v20231115014 to support new AdvancedConfiguration in *admin.AdvancedClusterDescription
6+
replace go.mongodb.org/atlas-sdk/v20231115014 => ../vendor/go.mongodb.org/atlas-sdk/v20231115014
7+
58
require (
69
github.com/aws-cloudformation/cloudformation-cli-go-plugin v1.2.0
710
github.com/aws/aws-sdk-go v1.55.7
@@ -19,7 +22,7 @@ require (
1922
github.com/stretchr/testify v1.10.0
2023
github.com/tidwall/pretty v1.2.1
2124
go.mongodb.org/atlas-sdk/v20231115002 v20231115002.1.0
22-
go.mongodb.org/atlas-sdk/v20231115014 v20231115014.0.1
25+
go.mongodb.org/atlas-sdk/v20231115014 v20231115014.0.0
2326
go.mongodb.org/atlas-sdk/v20250312002 v20250312002.0.0
2427
)
2528

cfn-resources/go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,6 @@ go.mongodb.org/atlas v0.37.0 h1:zQnO1o5+bVP9IotpAYpres4UjMD2F4nwNEFTZhNL4ck=
103103
go.mongodb.org/atlas v0.37.0/go.mod h1:DJYtM+vsEpPEMSkQzJnFHrT0sP7ev6cseZc/GGjJYG8=
104104
go.mongodb.org/atlas-sdk/v20231115002 v20231115002.1.0 h1:x6nnq2pUIP9mN4WLD4/EseBzV88OmSgexxYchPilgno=
105105
go.mongodb.org/atlas-sdk/v20231115002 v20231115002.1.0/go.mod h1:el7cm23kEiiw72HAYimhNweKqp/ubHsNJk+Mk30yJhM=
106-
go.mongodb.org/atlas-sdk/v20231115014 v20231115014.0.1 h1:l+SxbeIK+3RmpSBq6MPfUEsQeQZHQ0pjTxeZQdNRFlA=
107-
go.mongodb.org/atlas-sdk/v20231115014 v20231115014.0.1/go.mod h1:pCl46YnWOIde8lq27whXDwUseNeUvtAy3vy5ZDeTcBA=
108106
go.mongodb.org/atlas-sdk/v20250312002 v20250312002.0.0 h1:KX8PrYp3/PCSxG4NbGLcc3+EsNcfyhcvylGbe/oRlx8=
109107
go.mongodb.org/atlas-sdk/v20250312002 v20250312002.0.0/go.mod h1:HHCmHxHPdJRr1bUXlvRIZbm7M4gRujjur1GnjE44YgA=
110108
golang.org/x/oauth2 v0.28.0 h1:CrgCKl8PPAVtLnU3c+EDw6x11699EWlsDeWNWKdIOkc=

cfn-resources/test/e2e/cluster/cluster.json.template

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@
1717
"NoTableScan": "false",
1818
"OplogSizeMB": "2000",
1919
"SampleSizeBIConnector": "110",
20-
"SampleRefreshIntervalBIConnector": "310"
20+
"SampleRefreshIntervalBIConnector": "310",
21+
"TlsCipherConfigMode": "CUSTOM",
22+
"CustomOpensslCipherConfigTls12": [
23+
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
24+
"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384"
25+
]
2126
},
2227
"BackupEnabled": "false",
2328
"ClusterType": "GEOSHARDED",

examples/cluster/cluster.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@
4141
"NoTableScan": "false",
4242
"OplogSizeMB": "2000",
4343
"SampleSizeBIConnector": "110",
44-
"SampleRefreshIntervalBIConnector": "310"
44+
"SampleRefreshIntervalBIConnector": "310",
45+
"TlsCipherConfigMode": "CUSTOM",
46+
"CustomOpensslCipherConfigTls12": [
47+
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
48+
"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384"
49+
]
4550
},
4651
"BackupEnabled": "true",
4752
"ClusterType": "REPLICASET",
@@ -122,4 +127,4 @@
122127
}
123128
}
124129
}
125-
}
130+
}

0 commit comments

Comments
 (0)