Skip to content

Commit

Permalink
Merge branch 'master' into CLOUDP-229747
Browse files Browse the repository at this point in the history
* master:
  chore: Bump dorny/paths-filter from 3.0.0 to 3.0.1 (#1964)
  chore: Bump github.com/aws/aws-sdk-go from 1.50.17 to 1.50.22 (#1965)
  chore: Upgrades `advanced_cluster` resource to auto-generated SDK (#1947)
  fix: mongodbatlas_encryption_at_rest resource with google_cloud_kms_config (#1962)
  chore: Restores atlas streams guide in examples section (#1958)
  chore: Signs created tag during release process (#1960)
  • Loading branch information
lantoli committed Feb 21, 2024
2 parents 839d5ba + d7b15fc commit 2748c3a
Show file tree
Hide file tree
Showing 95 changed files with 2,931 additions and 3,118 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/acceptance-tests-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ jobs:
encryption: ${{ steps.filter.outputs.encryption == 'true' || env.mustTrigger == 'true' }}
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- uses: dorny/paths-filter@0bc4621a3135347011ad047f9ecf449bf72ce2bd
- uses: dorny/paths-filter@ebc4d7e9ebcb0b1eb21480bb8f43113e996ac77a
id: filter
if: ${{ inputs.test_group == '' && env.mustTrigger == 'false' }}
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/migration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
cluster: ${{ steps.filter.outputs.cluster == 'true' || env.mustTrigger == 'true' }}
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- uses: dorny/paths-filter@0bc4621a3135347011ad047f9ecf449bf72ce2bd
- uses: dorny/paths-filter@ebc4d7e9ebcb0b1eb21480bb8f43113e996ac77a
id: filter
if: ${{ inputs.test_group == '' && env.mustTrigger == 'false' }}
with:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ jobs:
uses: rickstaa/action-create-tag@a1c7777fcb2fee4f19b0f283ba888afa11678b72 # will fail if existing tag is present
with:
tag: ${{ inputs.version_number }}
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg_passphrase: ${{ secrets.PASSPHRASE }}
- name: Set up Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491
with:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# MongoDB Atlas Provider - Atlas Streams with Terraform

Atlas Stream Processing is composed of multiple components, and users can leverage Terraform to define a subset of these. To obtain more details on each of the components please refer to the [Atlas Stream Processing Documentation](https://www.mongodb.com/docs/atlas/atlas-sp/overview/#atlas-stream-processing-overview).

### Resources supported by Terraform

- `mongodbatlas_stream_instance`: Enables creating, modifying, and deleting Stream Instances. as part of this resource, a computed `hostnames` attribute is available for connecting to the created instance.
- `mongodbatlas_stream_connection`: Enables creating, modifying, and deleting Stream Instance Connections, which serve as data sources and sinks for your instance.

**NOTE**: To leverage these resources you'll need to set the environment variable `MONGODB_ATLAS_ENABLE_BETA=true` as this functionality is currently in preview. Also see [Limitations](https://www.mongodb.com/docs/atlas/atlas-sp/limitations/#std-label-atlas-sp-limitations) of Atlas Streams Processing during this preview period.

### Managing Stream Processors

Once a stream instance and its connections have been defined, `Stream Processors` can be created to define how your data will be processed in your instance. There are currently no resources defined in Terraform to provide this configuration. To obtain information on how this can be configured refer to [Manage Stream Processors](https://www.mongodb.com/docs/atlas/atlas-sp/manage-stream-processor/#manage-stream-processors).

Connect to your stream instance defined in terraform using the following code block:
```
output "stream_instance_hostname" {
value = mongodbatlas_stream_instance.test.hostnames
}
```

This value can then be used to connect to the stream instance using `mongosh`, as described in the [Get Started Tutorial](https://www.mongodb.com/docs/atlas/atlas-sp/tutorial/).
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.21
toolchain go1.21.6

require (
github.com/aws/aws-sdk-go v1.50.17
github.com/aws/aws-sdk-go v1.50.22
github.com/go-test/deep v1.1.0
github.com/gruntwork-io/terratest v0.46.11
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
Expand All @@ -28,7 +28,6 @@ require (
go.mongodb.org/atlas-sdk/v20231001002 v20231001002.0.0
go.mongodb.org/atlas-sdk/v20231115006 v20231115006.0.0
go.mongodb.org/realm v0.1.0
golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819
)

require (
Expand Down Expand Up @@ -128,6 +127,7 @@ require (
github.com/zclconf/go-cty-yaml v1.0.2 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/crypto v0.18.0 // indirect
golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.18.0 // indirect
golang.org/x/oauth2 v0.14.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkY
github.com/aws/aws-sdk-go v1.15.78/go.mod h1:E3/ieXAlvM0XWO57iftYVDLLvQ824smPP3ATZkfNZeM=
github.com/aws/aws-sdk-go v1.37.0/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo=
github.com/aws/aws-sdk-go v1.50.17 h1:KsbzUKDgGNlkDHGvoQDhiJ63a9jtZd+O+/s3pTOr/ns=
github.com/aws/aws-sdk-go v1.50.17/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
github.com/aws/aws-sdk-go v1.50.22 h1:BUhSaO2qLk2jkcyLebcvDmbdOunVe/Wq8RsCyI8szL0=
github.com/aws/aws-sdk-go v1.50.22/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas=
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4=
github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY=
Expand Down
16 changes: 8 additions & 8 deletions internal/common/conversion/flatten_expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@ import (
"go.mongodb.org/atlas-sdk/v20231115006/admin"
)

func FlattenLinks(links []admin.Link) []map[string]any {
ret := make([]map[string]any, len(links))
func FlattenLinks(links []admin.Link) []map[string]string {
ret := make([]map[string]string, len(links))
for i, link := range links {
ret[i] = map[string]any{
ret[i] = map[string]string{
"href": link.GetHref(),
"rel": link.GetRel(),
}
}
return ret
}

func FlattenTags(tags []admin.ResourceTag) []map[string]any {
ret := make([]map[string]any, len(tags))
func FlattenTags(tags []admin.ResourceTag) []map[string]string {
ret := make([]map[string]string, len(tags))
for i, tag := range tags {
ret[i] = map[string]any{
ret[i] = map[string]string{
"key": tag.GetKey(),
"value": tag.GetValue(),
}
}
return ret
}

func ExpandTagsFromSetSchema(d *schema.ResourceData) []admin.ResourceTag {
func ExpandTagsFromSetSchema(d *schema.ResourceData) *[]admin.ResourceTag {
list := d.Get("tags").(*schema.Set)
ret := make([]admin.ResourceTag, list.Len())
for i, item := range list.List() {
Expand All @@ -38,7 +38,7 @@ func ExpandTagsFromSetSchema(d *schema.ResourceData) []admin.ResourceTag {
Value: StringPtr(tag["value"].(string)),
}
}
return ret
return &ret
}

func ExpandStringList(list []any) (res []string) {
Expand Down
6 changes: 6 additions & 0 deletions internal/common/conversion/type_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ func TimeToString(t time.Time) string {
return t.UTC().Format(time.RFC3339Nano)
}

// StringToTime is the opposite to TimeToString, returns ok if conversion is possible.
func StringToTime(str string) (time.Time, bool) {
ret, err := time.Parse(time.RFC3339Nano, str)
return ret, err == nil
}

func Int64PtrToIntPtr(i64 *int64) *int {
if i64 == nil {
return nil
Expand Down
27 changes: 19 additions & 8 deletions internal/common/conversion/type_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,39 @@ import (
"time"

"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
"github.com/stretchr/testify/assert"
)

func TestTimeToStringWithoutNanos(t *testing.T) {
func TestTimeWithoutNanos(t *testing.T) {
inputTime := time.Date(2023, time.July, 18, 16, 12, 23, 0, time.UTC)
expectedOutput := "2023-07-18T16:12:23Z"

result := conversion.TimeToString(inputTime)
assert.Equal(t, expectedOutput, result)

if result != expectedOutput {
t.Errorf("TimeToString(%v) = %v; want %v", inputTime, result, expectedOutput)
}
expectedTime, ok := conversion.StringToTime(result)
assert.True(t, ok)
assert.Equal(t, expectedTime, inputTime)
}

func TestTimeToStringWithNanos(t *testing.T) {
func TestTimeWithNanos(t *testing.T) {
inputTime := time.Date(2023, time.July, 18, 16, 12, 23, 456_000_000, time.UTC)
expectedOutput := "2023-07-18T16:12:23.456Z"

result := conversion.TimeToString(inputTime)
assert.Equal(t, expectedOutput, result)

if result != expectedOutput {
t.Errorf("TimeToString(%v) = %v; want %v", inputTime, result, expectedOutput)
}
expectedTime, ok := conversion.StringToTime(result)
assert.True(t, ok)
assert.Equal(t, expectedTime, inputTime)
}

func TestStringToTimeInvalid(t *testing.T) {
_, ok := conversion.StringToTime("")
assert.False(t, ok)

_, ok = conversion.StringToTime("123")
assert.False(t, ok)
}

func TestIsStringPresent(t *testing.T) {
Expand Down
Loading

0 comments on commit 2748c3a

Please sign in to comment.