Skip to content

Commit

Permalink
Merge pull request #34595 from bschaatsbergen/f/controltower-landingzone
Browse files Browse the repository at this point in the history
[New Resource]: `aws_controltower_landing_zone`
  • Loading branch information
ewbankkit committed Feb 5, 2024
2 parents acdb94f + 139597a commit bdb787a
Show file tree
Hide file tree
Showing 11 changed files with 865 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .changelog/34595.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```release-note:new-resource
aws_controltower_landing_zone
```

```release-note:note
resource/aws_controltower_landing_zone: Because we cannot easily test this functionality, it is best effort and we ask for community help in testing
```
39 changes: 39 additions & 0 deletions internal/json/smithy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package json

import (
"encoding/json"

smithydocument "github.com/aws/smithy-go/document"
)

func SmithyDocumentFromString[T smithydocument.Marshaler](s string, f func(any) T) (T, error) {
var v map[string]interface{}

err := json.Unmarshal([]byte(s), &v)
if err != nil {
var zero T
return zero, err
}

return f(v), nil
}

// SmithyDocumentToString converts a [Smithy document](https://smithy.io/2.0/spec/simple-types.html#document) to a JSON string.
func SmithyDocumentToString(document smithydocument.Unmarshaler) (string, error) {
var v map[string]interface{}

err := document.UnmarshalSmithyDocument(&v)
if err != nil {
return "", err
}

bytes, err := json.Marshal(v)
if err != nil {
return "", err
}

return string(bytes), nil
}
24 changes: 24 additions & 0 deletions internal/service/controltower/controltower_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package controltower_test

import (
"testing"

"github.com/hashicorp/terraform-provider-aws/internal/acctest"
)

func TestAccControlTower_serial(t *testing.T) {
t.Parallel()

testCases := map[string]map[string]func(t *testing.T){
"LandingZone": {
"basic": testAccLandingZone_basic,
"disappears": testAccLandingZone_disappears,
"tags": testAccLandingZone_tags,
},
}

acctest.RunSerialTests2Levels(t, testCases, 0)
}
4 changes: 3 additions & 1 deletion internal/service/controltower/exports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ package controltower

// Exports for use in tests only.
var (
ResourceControl = resourceControl
ResourceControl = resourceControl
ResourceLandingZone = resourceLandingZone

FindEnabledControlByTwoPartKey = findEnabledControlByTwoPartKey
FindLandingZoneByID = findLandingZoneByID
)
1 change: 1 addition & 0 deletions internal/service/controltower/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: MPL-2.0

//go:generate go run ../../generate/servicepackage/main.go
//go:generate go run ../../generate/tags/main.go -AWSSDKVersion=2 -ServiceTagsMap -KVTValues -SkipTypesImp -ListTags -UpdateTags
// ONLY generate directives and package declaration! Do not add anything else to this file.

package controltower
Loading

0 comments on commit bdb787a

Please sign in to comment.