-
Notifications
You must be signed in to change notification settings - Fork 42
feat: Add StreamWorkspace CloudFormation resource #1517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
82de04d
feat: Add StreamWorkspace ClooudFormation resource
9eba65d
CLOUDP-368426-Stream-Workspace Testig Region Update
ParthasarathyV 4cd9802
Merge remote-tracking branch 'origin/master' into CLOUDP-368426-Strea…
ParthasarathyV 42ca5af
CLOUDP-368426-Stream-Workspace latest version update
ParthasarathyV e3a8c9e
CLOUDP-368426-Stream-Workspace Delete resource_test.go
ParthasarathyV 013d2ce
CLOUDP-368426-Stream-Workspace Removing Connections from stream works…
ParthasarathyV 04654b4
CLOUDP-368426-Stream-Workspace remove bin file
ParthasarathyV fa3433c
CLOUDP-368426-Stream-Workspace Lint fix
ParthasarathyV ea07f4b
CLOUDP-368426-Stream-Workspace error codes standard
ParthasarathyV 6e53b2e
CLOUDP-368426-Stream-Workspace Copyright addition
ParthasarathyV 8479e75
CLOUDP-368426-Stream-Workspace Review comments
ParthasarathyV 0972221
Add workflow for cfn test
rakhul-peerislands 08452de
Merge branch 'master' into CLOUDP-368426-Stream-Workspace
ParthasarathyV File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| { | ||
| "artifact_type": "RESOURCE", | ||
| "typeName": "MongoDB::Atlas::StreamWorkspace", | ||
| "language": "go", | ||
| "runtime": "provided.al2", | ||
| "entrypoint": "bootstrap", | ||
| "testEntrypoint": "bootstrap", | ||
| "settings": { | ||
| "version": false, | ||
| "subparser_name": null, | ||
| "verbose": 0, | ||
| "force": false, | ||
| "type_name": "MongoDB::Atlas::StreamWorkspace", | ||
| "artifact_type": null, | ||
| "endpoint_url": null, | ||
| "region": null, | ||
| "target_schemas": [], | ||
| "profile": null, | ||
| "import_path": "github.com/mongodb/mongodbatlas-cloudformation-resources/stream-workspace", | ||
| "protocolVersion": "2.0.0" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| .PHONY: build test clean | ||
| tags=logging callback metrics scheduler | ||
| cgo=0 | ||
| goos=linux | ||
| goarch=amd64 | ||
| CFNREP_GIT_SHA?=$(shell git rev-parse HEAD) | ||
| ldXflags=-s -w -X github.com/mongodb/mongodbatlas-cloudformation-resources/util.defaultLogLevel=info -X github.com/mongodb/mongodbatlas-cloudformation-resources/version.Version=${CFNREP_GIT_SHA} | ||
| ldXflagsD=-X github.com/mongodb/mongodbatlas-cloudformation-resources/util.defaultLogLevel=debug -X github.com/mongodb/mongodbatlas-cloudformation-resources/version.Version=${CFNREP_GIT_SHA} | ||
|
|
||
| build: | ||
| cfn generate | ||
| env GOOS=$(goos) CGO_ENABLED=$(cgo) GOARCH=$(goarch) go build -ldflags="$(ldXflags)" -tags="$(tags)" -o bin/bootstrap cmd/main.go | ||
|
|
||
| debug: | ||
| cfn generate | ||
| env GOOS=$(goos) CGO_ENABLED=$(cgo) GOARCH=$(goarch) go build -ldflags="$(ldXflagsD)" -tags="$(tags)" -o bin/bootstrap cmd/main.go | ||
|
|
||
| clean: | ||
| rm -rf bin | ||
|
|
||
| create-test-resources: | ||
| @echo "==> Creating test files for contract testing" | ||
| ./test/contract-testing/cfn-test-create-inputs.sh | ||
|
|
||
| delete-test-resources: | ||
| @echo "==> Delete test resources used for contract testing" | ||
| ./test/cfn-test-delete-inputs.sh | ||
|
|
||
| run-contract-testing: | ||
| @echo "==> Run contract testing" | ||
| make build | ||
| sam local start-lambda & | ||
| cfn test --function-name TestEntrypoint --verbose |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # MongoDB::Atlas::StreamWorkspace | ||
|
|
||
| ## Description | ||
|
|
||
| Resource for managing [Stream Workspaces](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/group/endpoint-streams). | ||
|
|
||
| ## Requirements | ||
|
|
||
| Set up an AWS profile to securely give CloudFormation access to your Atlas credentials. | ||
| For instructions on setting up a profile, [see here](/README.md#mongodb-atlas-api-keys-credential-management). | ||
|
|
||
| ## Attributes and Parameters | ||
|
|
||
| See the [resource docs](docs/README.md). Also refer [AWS security best practices for CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/security-best-practices.html#creds) to manage credentials. | ||
|
|
||
| ## CloudFormation Examples | ||
|
|
||
| See the examples [CFN Template](/examples/stream-workspace/stream-workspace.json) for example resource. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| // Copyright 2026 MongoDB Inc | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package resource | ||
|
|
||
| import "go.mongodb.org/atlas-sdk/v20250312012/admin" | ||
|
|
||
| func NewStreamWorkspaceCreateReq(model *Model) *admin.StreamsTenant { | ||
| if model == nil { | ||
| return nil | ||
| } | ||
| dataProcessRegion := *model.DataProcessRegion | ||
| streamTenant := &admin.StreamsTenant{ | ||
| Name: model.WorkspaceName, | ||
| GroupId: model.ProjectId, | ||
| DataProcessRegion: &admin.StreamsDataProcessRegion{ | ||
| CloudProvider: *dataProcessRegion.CloudProvider, | ||
| Region: *dataProcessRegion.Region, | ||
| }, | ||
| } | ||
| if streamConfig := model.StreamConfig; streamConfig != nil { | ||
| streamTenant.StreamConfig = &admin.StreamConfig{} | ||
| if tier := streamConfig.Tier; tier != nil { | ||
| streamTenant.StreamConfig.Tier = tier | ||
| } | ||
| if maxTierSize := streamConfig.MaxTierSize; maxTierSize != nil { | ||
| streamTenant.StreamConfig.MaxTierSize = maxTierSize | ||
| } | ||
| } | ||
| return streamTenant | ||
| } | ||
|
|
||
| func NewStreamWorkspaceUpdateReq(model *Model) *admin.StreamsTenantUpdateRequest { | ||
| if model == nil || model.DataProcessRegion == nil { | ||
| return nil | ||
| } | ||
| dataProcessRegion := *model.DataProcessRegion | ||
| if dataProcessRegion.Region == nil { | ||
| return nil | ||
| } | ||
| // CloudFormation is AWS-only, so CloudProvider is always AWS | ||
| cloudProvider := CloudProvider | ||
| return &admin.StreamsTenantUpdateRequest{ | ||
| CloudProvider: &cloudProvider, | ||
| Region: dataProcessRegion.Region, | ||
| } | ||
| } | ||
|
|
||
| func newModelDataRegion(dataProcessRegion *admin.StreamsDataProcessRegion) *StreamsDataProcessRegion { | ||
| return &StreamsDataProcessRegion{ | ||
| CloudProvider: &dataProcessRegion.CloudProvider, | ||
| Region: &dataProcessRegion.Region, | ||
| } | ||
| } | ||
|
|
||
| func newModelStreamConfig(streamConfig *admin.StreamConfig) *StreamConfig { | ||
| if streamConfig == nil { | ||
| return nil | ||
| } | ||
| modelConfig := &StreamConfig{} | ||
| if streamConfig.Tier != nil { | ||
| modelConfig.Tier = streamConfig.Tier | ||
| } | ||
| if streamConfig.MaxTierSize != nil { | ||
| modelConfig.MaxTierSize = streamConfig.MaxTierSize | ||
| } | ||
| return modelConfig | ||
| } | ||
|
|
||
| func GetStreamWorkspaceModel(streamTenant *admin.StreamsTenant, currentModel *Model) *Model { | ||
| model := new(Model) | ||
|
|
||
| if currentModel != nil { | ||
| model = currentModel | ||
| } | ||
|
|
||
| if streamTenant != nil { | ||
| model.WorkspaceName = streamTenant.Name | ||
| model.DataProcessRegion = newModelDataRegion(streamTenant.DataProcessRegion) | ||
| model.StreamConfig = newModelStreamConfig(streamTenant.StreamConfig) | ||
| model.ProjectId = streamTenant.GroupId | ||
| model.Id = streamTenant.Id | ||
| model.Hostnames = streamTenant.GetHostnames() | ||
| } | ||
|
|
||
| return model | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which "primary identifier fields" are being referred to here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the vague comment