-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36773 from mattburgess/ce-awssdkv2-migration
costexplorer: Migrate to AWS SDK v2
- Loading branch information
Showing
35 changed files
with
1,081 additions
and
1,231 deletions.
There are no files selected for viewing
This file contains 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,7 @@ | ||
```release-note:bug | ||
resource/aws_ce_anomaly_monitor: Change `monitor_dimension` to [ForceNew](https://developer.hashicorp.com/terraform/plugin/sdkv2/schemas/schema-behaviors#forcenew) | ||
``` | ||
|
||
```release-note:bug | ||
resource/aws_ce_anomaly_subscription: Change `account_id` to [ForceNew](https://developer.hashicorp.com/terraform/plugin/sdkv2/schemas/schema-behaviors#forcenew) | ||
``` |
This file contains 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
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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,63 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package sdkv2 | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
// Adapted from https://github.com/hashicorp/terraform-provider-google/google/datasource_helpers.go. Thanks! | ||
|
||
// DataSourcePropertyFromResourceProperty is a recursive func that | ||
// converts an existing Resource property schema to a Datasource property schema. | ||
// All schema elements are copied, but certain attributes are ignored or changed: | ||
// - all attributes have Computed = true | ||
// - all attributes have ForceNew, Required = false | ||
// - Validation funcs and attributes (e.g. MaxItems) are not copied | ||
func DataSourcePropertyFromResourceProperty(rs *schema.Schema) *schema.Schema { | ||
ds := &schema.Schema{ | ||
Computed: true, | ||
Description: rs.Description, | ||
Type: rs.Type, | ||
} | ||
|
||
switch rs.Type { | ||
case schema.TypeSet: | ||
ds.Set = rs.Set | ||
fallthrough | ||
case schema.TypeList, schema.TypeMap: | ||
// List & Set types are generally used for 2 cases: | ||
// - a list/set of simple primitive values (e.g. list of strings) | ||
// - a sub resource | ||
// Maps are usually used for maps of simple primitives | ||
switch elem := rs.Elem.(type) { | ||
case *schema.Resource: | ||
// handle the case where the Element is a sub-resource | ||
ds.Elem = DataSourceElemFromResourceElem(elem) | ||
case *schema.Schema: | ||
// handle simple primitive case | ||
ds.Elem = &schema.Schema{Type: elem.Type} | ||
} | ||
} | ||
|
||
return ds | ||
} | ||
|
||
func DataSourceElemFromResourceElem(rs *schema.Resource) *schema.Resource { | ||
ds := &schema.Resource{ | ||
Schema: DataSourceSchemaFromResourceSchema(rs.Schema), | ||
} | ||
|
||
return ds | ||
} | ||
|
||
func DataSourceSchemaFromResourceSchema(rs map[string]*schema.Schema) map[string]*schema.Schema { | ||
ds := make(map[string]*schema.Schema, len(rs)) | ||
|
||
for k, v := range rs { | ||
ds[k] = DataSourcePropertyFromResourceProperty(v) | ||
} | ||
|
||
return ds | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.