Skip to content

Commit

Permalink
Merge pull request #38194 from acwwat/b-aws_db_event_subscription-upd…
Browse files Browse the repository at this point in the history
…ate_validation

fix: Align name and name_prefix validation with AWS API for aws_db_event_subscription
  • Loading branch information
ewbankkit authored Aug 15, 2024
2 parents fa57128 + 011b745 commit 819e037
Show file tree
Hide file tree
Showing 49 changed files with 968 additions and 1,519 deletions.
3 changes: 3 additions & 0 deletions .changelog/38194.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_db_event_subscription: Fix plan-time validation of `name` and `name_prefix`
```
11 changes: 0 additions & 11 deletions internal/conns/awsclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
aws_sdkv1 "github.com/aws/aws-sdk-go/aws"
session_sdkv1 "github.com/aws/aws-sdk-go/aws/session"
opsworks_sdkv1 "github.com/aws/aws-sdk-go/service/opsworks"
rds_sdkv1 "github.com/aws/aws-sdk-go/service/rds"
baselogging "github.com/hashicorp/aws-sdk-go-base/v2/logging"
"github.com/hashicorp/terraform-plugin-log/tflog"
"github.com/hashicorp/terraform-provider-aws/internal/errs"
Expand Down Expand Up @@ -86,16 +85,6 @@ func (c *AWSClient) RegionalHostname(ctx context.Context, prefix string) string
return fmt.Sprintf("%s.%s.%s", prefix, c.Region, c.DNSSuffix(ctx))
}

// RDSConnForRegion returns an AWS SDK For Go v1 RDS API client for the specified AWS Region.
// If the specified region is not the default a new "simple" client is created.
// This new client does not use any configured endpoint override.
func (c *AWSClient) RDSConnForRegion(ctx context.Context, region string) *rds_sdkv1.RDS {
if region == c.Region {
return c.RDSConn(ctx)
}
return rds_sdkv1.New(c.session, aws_sdkv1.NewConfig().WithRegion(region))
}

// S3ExpressClient returns an AWS SDK for Go v2 S3 API client suitable for use with S3 Express (directory buckets).
// This client differs from the standard S3 API client only in us-east-1 if the global S3 endpoint is used.
// In that case the returned client uses the regional S3 endpoint.
Expand Down
5 changes: 0 additions & 5 deletions internal/conns/awsclient_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion internal/generate/namevaluesfilters/v1/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ func main() {
// Representing types such as []*fsx.Filter, []*rds.Filter, ...
sliceServiceNames := []string{
"imagebuilder",
"rds",
}
// Always sort to reduce any potential generation churn
sort.Strings(sliceServiceNames)
Expand Down
23 changes: 0 additions & 23 deletions internal/namevaluesfilters/v1/service_filters_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 6 additions & 8 deletions internal/service/meta/service_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
"fmt"
"testing"

"github.com/aws/aws-sdk-go/service/rds"
"github.com/aws/aws-sdk-go/service/s3"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-provider-aws/internal/acctest"
tfmeta "github.com/hashicorp/terraform-provider-aws/internal/service/meta"
Expand Down Expand Up @@ -53,9 +51,9 @@ func TestAccMetaService_byReverseDNSName(t *testing.T) {
Config: testAccServiceDataSourceConfig_byReverseDNSName(),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(dataSourceName, names.AttrRegion, names.CNNorth1RegionID),
resource.TestCheckResourceAttr(dataSourceName, "reverse_dns_name", fmt.Sprintf("%s.%s.%s", "cn.com.amazonaws", names.CNNorth1RegionID, s3.EndpointsID)),
resource.TestCheckResourceAttr(dataSourceName, "reverse_dns_name", fmt.Sprintf("%s.%s.%s", "cn.com.amazonaws", names.CNNorth1RegionID, names.S3)),
resource.TestCheckResourceAttr(dataSourceName, "reverse_dns_prefix", "cn.com.amazonaws"),
resource.TestCheckResourceAttr(dataSourceName, "service_id", s3.EndpointsID),
resource.TestCheckResourceAttr(dataSourceName, "service_id", names.S3),
resource.TestCheckResourceAttr(dataSourceName, "supported", acctest.CtTrue),
),
},
Expand All @@ -76,9 +74,9 @@ func TestAccMetaService_byDNSName(t *testing.T) {
Config: testAccServiceDataSourceConfig_byDNSName(),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(dataSourceName, names.AttrRegion, names.USEast1RegionID),
resource.TestCheckResourceAttr(dataSourceName, "reverse_dns_name", fmt.Sprintf("%s.%s.%s", "com.amazonaws", names.USEast1RegionID, rds.EndpointsID)),
resource.TestCheckResourceAttr(dataSourceName, "reverse_dns_name", fmt.Sprintf("%s.%s.%s", "com.amazonaws", names.USEast1RegionID, names.RDS)),
resource.TestCheckResourceAttr(dataSourceName, "reverse_dns_prefix", "com.amazonaws"),
resource.TestCheckResourceAttr(dataSourceName, "service_id", rds.EndpointsID),
resource.TestCheckResourceAttr(dataSourceName, "service_id", names.RDS),
resource.TestCheckResourceAttr(dataSourceName, "supported", acctest.CtTrue),
),
},
Expand All @@ -98,8 +96,8 @@ func TestAccMetaService_byParts(t *testing.T) {
{
Config: testAccServiceDataSourceConfig_byPart(),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(dataSourceName, names.AttrDNSName, fmt.Sprintf("%s.%s.%s", s3.EndpointsID, acctest.Region(), "amazonaws.com")),
resource.TestCheckResourceAttr(dataSourceName, "reverse_dns_name", fmt.Sprintf("%s.%s.%s", "com.amazonaws", acctest.Region(), s3.EndpointsID)),
resource.TestCheckResourceAttr(dataSourceName, names.AttrDNSName, fmt.Sprintf("%s.%s.%s", names.S3, acctest.Region(), "amazonaws.com")),
resource.TestCheckResourceAttr(dataSourceName, "reverse_dns_name", fmt.Sprintf("%s.%s.%s", "com.amazonaws", acctest.Region(), names.S3)),
resource.TestCheckResourceAttr(dataSourceName, "supported", acctest.CtTrue),
),
},
Expand Down
12 changes: 6 additions & 6 deletions internal/service/rds/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func resourceCluster() *schema.Resource {
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: validation.StringInSlice(ClusterExportableLogType_Values(), false),
ValidateFunc: validation.StringInSlice(clusterExportableLogType_Values(), false),
},
},
names.AttrEndpoint: {
Expand Down Expand Up @@ -657,7 +657,7 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta int
Engine: aws.String(d.Get(names.AttrEngine).(string)),
EngineMode: aws.String(d.Get("engine_mode").(string)),
SnapshotIdentifier: aws.String(v.(string)),
Tags: getTagsInV2(ctx),
Tags: getTagsIn(ctx),
}

if v, ok := d.GetOk(names.AttrAvailabilityZones); ok && v.(*schema.Set).Len() > 0 {
Expand Down Expand Up @@ -788,7 +788,7 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta int
S3Prefix: aws.String(tfMap[names.AttrBucketPrefix].(string)),
SourceEngine: aws.String(tfMap["source_engine"].(string)),
SourceEngineVersion: aws.String(tfMap["source_engine_version"].(string)),
Tags: getTagsInV2(ctx),
Tags: getTagsIn(ctx),
}

if v, ok := d.GetOk(names.AttrAvailabilityZones); ok && v.(*schema.Set).Len() > 0 {
Expand Down Expand Up @@ -911,7 +911,7 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta int
CopyTagsToSnapshot: aws.Bool(d.Get("copy_tags_to_snapshot").(bool)),
DBClusterIdentifier: aws.String(identifier),
DeletionProtection: aws.Bool(d.Get(names.AttrDeletionProtection).(bool)),
Tags: getTagsInV2(ctx),
Tags: getTagsIn(ctx),
}

if v, ok := d.GetOk("backtrack_window"); ok {
Expand Down Expand Up @@ -1035,7 +1035,7 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta int
DeletionProtection: aws.Bool(d.Get(names.AttrDeletionProtection).(bool)),
Engine: aws.String(d.Get(names.AttrEngine).(string)),
EngineMode: aws.String(d.Get("engine_mode").(string)),
Tags: getTagsInV2(ctx),
Tags: getTagsIn(ctx),
}

if v, ok := d.GetOkExists(names.AttrAllocatedStorage); ok {
Expand Down Expand Up @@ -1375,7 +1375,7 @@ func resourceClusterRead(ctx context.Context, d *schema.ResourceData, meta inter
}
}

setTagsOutV2(ctx, dbc.TagList)
setTagsOut(ctx, dbc.TagList)

return diags
}
Expand Down
2 changes: 1 addition & 1 deletion internal/service/rds/cluster_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func dataSourceClusterRead(ctx context.Context, d *schema.ResourceData, meta int
return aws.ToString(v.VpcSecurityGroupId)
}))

setTagsOutV2(ctx, dbc.TagList)
setTagsOut(ctx, dbc.TagList)

return diags
}
2 changes: 1 addition & 1 deletion internal/service/rds/cluster_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func resourceClusterEndpointCreate(ctx context.Context, d *schema.ResourceData,
DBClusterEndpointIdentifier: aws.String(endpointID),
DBClusterIdentifier: aws.String(d.Get(names.AttrClusterIdentifier).(string)),
EndpointType: aws.String(d.Get("custom_endpoint_type").(string)),
Tags: getTagsInV2(ctx),
Tags: getTagsIn(ctx),
}

if v, ok := d.GetOk("excluded_members"); ok && v.(*schema.Set).Len() > 0 {
Expand Down
Loading

0 comments on commit 819e037

Please sign in to comment.