Skip to content

Commit

Permalink
Upgrade terraform provider aws to v5.32.0 (#3292)
Browse files Browse the repository at this point in the history
Fixes #3253

This PR upgrades the provider to match upstream provider version
v5.32.0.

List of unusual things that defeated upgrade-provider and required
manual intervention:

- The patch for elbv2 target workaround in #2517 does not apply cleanly
to new upstream, had to be redone; I've tested manually that 2517 does
not reproduce on top of the new provider, but need to backlog adding a
test for it; the relevant ticket is in
#2749

- Upstream is gradually removing AWS Go SDK v1. This affected legacy
bucket resource that Pulumi retains in spite of upstream having it
removed. This is now working again but required another invasive patch
to undo upstream changes.

- New "verified permissions" module needed to be registered in
resources.go to support automatic module inference.

- Several new Plugin Framework based resources required patching to
support tags; this is slowing us down until we can implement
#2962

- Run test of provider shim was breaking as it didn't get all the
dependencies, now fixed

- Patch from #3290 wouldn't
apply because of wrong format (`make upstream.rebase` broken) - had to
reformat it

- doc_edits.go would keep appending edits to replacements.json; this is fixed
  • Loading branch information
t0yv0 committed Jan 23, 2024
1 parent abfc6ac commit 9335f62
Show file tree
Hide file tree
Showing 896 changed files with 54,331 additions and 2,963 deletions.
6 changes: 6 additions & 0 deletions .ci-mgmt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ extraTests:
with:
ref: ${{ env.PR_COMMIT_SHA }}
submodules: true
- name: Unshallow clone for tags
run: git fetch --prune --unshallow --tags
- name: Install pulumictl
uses: jaxxstorm/[email protected]
with:
repo: pulumi/pulumictl
- name: Make upstream
run: make upstream
- uses: actions/setup-go@v4
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,12 @@ jobs:
with:
ref: ${{ env.PR_COMMIT_SHA }}
submodules: true
- name: Unshallow clone for tags
run: git fetch --prune --unshallow --tags
- name: Install pulumictl
uses: jaxxstorm/[email protected]
with:
repo: pulumi/pulumictl
- name: Make upstream
run: make upstream
- uses: actions/setup-go@v4
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,12 @@ jobs:
with:
ref: ${{ env.PR_COMMIT_SHA }}
submodules: true
- name: Unshallow clone for tags
run: git fetch --prune --unshallow --tags
- name: Install pulumictl
uses: jaxxstorm/[email protected]
with:
repo: pulumi/pulumictl
- name: Make upstream
run: make upstream
- uses: actions/setup-go@v4
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,12 @@ jobs:
with:
ref: ${{ env.PR_COMMIT_SHA }}
submodules: true
- name: Unshallow clone for tags
run: git fetch --prune --unshallow --tags
- name: Install pulumictl
uses: jaxxstorm/[email protected]
with:
repo: pulumi/pulumictl
- name: Make upstream
run: make upstream
- uses: actions/setup-go@v4
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/run-acceptance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,12 @@ jobs:
with:
ref: ${{ env.PR_COMMIT_SHA }}
submodules: true
- name: Unshallow clone for tags
run: git fetch --prune --unshallow --tags
- name: Install pulumictl
uses: jaxxstorm/[email protected]
with:
repo: pulumi/pulumictl
- name: Make upstream
run: make upstream
- uses: actions/setup-go@v4
Expand Down
241 changes: 127 additions & 114 deletions examples/go.mod

Large diffs are not rendered by default.

478 changes: 252 additions & 226 deletions examples/go.sum

Large diffs are not rendered by default.

43 changes: 43 additions & 0 deletions patches/0022-Fix-elbv2-target-group-read-to-workaround-2517.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Anton Tayanovskyy <[email protected]>
Date: Fri, 19 Jan 2024 17:36:47 -0500
Subject: [PATCH 22/39] Fix elbv2 target group read to workaround #2517


diff --git a/internal/service/elbv2/target_group.go b/internal/service/elbv2/target_group.go
index 388edc5ec7..e61259bfa2 100644
--- a/internal/service/elbv2/target_group.go
+++ b/internal/service/elbv2/target_group.go
@@ -562,15 +562,15 @@ func resourceTargetGroupRead(ctx context.Context, d *schema.ResourceData, meta i
return sdkdiag.AppendErrorf(diags, "reading ELBv2 Target Group (%s) attributes: %s", d.Id(), err)
}

- if err := d.Set("stickiness", []interface{}{flattenTargetGroupStickinessAttributes(attributes, protocol)}); err != nil {
+ if err := d.Set("stickiness", fix2517(flattenTargetGroupStickinessAttributes(attributes, protocol))); err != nil {
return sdkdiag.AppendErrorf(diags, "setting stickiness: %s", err)
}

- if err := d.Set("target_failover", []interface{}{flattenTargetGroupTargetFailoverAttributes(attributes, protocol)}); err != nil {
+ if err := d.Set("target_failover", fix2517(flattenTargetGroupTargetFailoverAttributes(attributes, protocol))); err != nil {
return sdkdiag.AppendErrorf(diags, "setting target_failover: %s", err)
}

- if err := d.Set("target_health_state", []interface{}{flattenTargetGroupTargetHealthStateAttributes(attributes, protocol)}); err != nil {
+ if err := d.Set("target_health_state", fix2517(flattenTargetGroupTargetHealthStateAttributes(attributes, protocol))); err != nil {
return sdkdiag.AppendErrorf(diags, "setting target_health_state: %s", err)
}

@@ -1385,3 +1385,13 @@ func runtimeValidations(d *schema.ResourceData, diags *diag.Diagnostics) {
}
}
}
+
+// Workaround for https://github.com/pulumi/pulumi-aws/issues/2517
+//
+// Don't return single empty map. Return empty list instead.
+func fix2517(m map[string]interface{}) []interface{} {
+ if len(m) == 0 {
+ return []interface{}{}
+ }
+ return []interface{}{m}
+}
25 changes: 0 additions & 25 deletions patches/0022-Fix-elbv2-target-group-read.patch

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Anton Tayanovskyy <[email protected]>
Date: Fri, 19 Jan 2024 18:08:51 -0500
Subject: [PATCH 38/39] Patch ACM retry to not retry after
LimitExceededException (#3290)


diff --git a/internal/service/acm/service_package_gen.go b/internal/service/acm/service_package_gen.go
index dbd2989c62..949496c395 100644
--- a/internal/service/acm/service_package_gen.go
Expand Down
172 changes: 172 additions & 0 deletions patches/0039-Restore-legacy-bucket.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Anton Tayanovskyy <[email protected]>
Date: Fri, 19 Jan 2024 18:13:52 -0500
Subject: [PATCH 39/39] Restore legacy bucket


diff --git a/go.mod b/go.mod
index 1a6d14c02f..321330c7a4 100644
--- a/go.mod
+++ b/go.mod
@@ -187,6 +187,7 @@ require (
github.com/go-test/deep v1.1.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/uuid v1.3.1 // indirect
+ github.com/hashicorp/aws-sdk-go-base v1.1.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-plugin v1.6.0 // indirect
diff --git a/go.sum b/go.sum
index 581cbc37ef..86cdff810b 100644
--- a/go.sum
+++ b/go.sum
@@ -21,6 +21,7 @@ github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmms
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI=
github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
+github.com/aws/aws-sdk-go v1.31.9/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0=
github.com/aws/aws-sdk-go v1.49.18 h1:g/iMXkfXeJQ7MvnLwroxWsTTNkHtdVJGxIgrAIEG62M=
github.com/aws/aws-sdk-go v1.49.18/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
github.com/aws/aws-sdk-go-v2 v1.24.1 h1:xAojnj+ktS95YZlDf0zxWBkbFtymPeDP+rvUQIH3uAU=
@@ -304,6 +305,7 @@ github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY=
github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
+github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg=
github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
@@ -323,6 +325,8 @@ github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hashicorp/aws-cloudformation-resource-schema-sdk-go v0.21.0 h1:IUypt/TbXiJBkBbE3926CgnjD8IltAitdn7Yive61DY=
github.com/hashicorp/aws-cloudformation-resource-schema-sdk-go v0.21.0/go.mod h1:cdTE6F2pCKQobug+RqRaQp7Kz9hIEqiSvpPmb6E5G1w=
+github.com/hashicorp/aws-sdk-go-base v1.1.0 h1:27urM3JAp6v+Oj/Ea5ULZwuFPK9cO1RUdEpV+rNdSAc=
+github.com/hashicorp/aws-sdk-go-base v1.1.0/go.mod h1:2fRjWDv3jJBeN6mVWFHV6hFTNeFBx2gpDLQaZNxUVAY=
github.com/hashicorp/aws-sdk-go-base/v2 v2.0.0-beta.46 h1:4HEbsW1qG5LQubjhlEwyCq4bEyvG+XvwYGYQ/PAtIP8=
github.com/hashicorp/aws-sdk-go-base/v2 v2.0.0-beta.46/go.mod h1:NBUTIFnvxeFb+YdNpecFB6t6oeUmWKz8jn0NexS5iJA=
github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2 v2.0.0-beta.47 h1:FAgLmKVkzcGE7/HaBg6389jupgs2pXjn7ctoOAnxcTg=
@@ -394,6 +398,7 @@ github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+h
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c=
+github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik=
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
@@ -513,6 +518,7 @@ golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=
golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
diff --git a/internal/conns/awsclient.go b/internal/conns/awsclient.go
index f29ee2f68f..8d738f06fa 100644
--- a/internal/conns/awsclient.go
+++ b/internal/conns/awsclient.go
@@ -103,6 +103,10 @@ func (c *AWSClient) S3UsePathStyle() bool {
return c.s3UsePathStyle
}

+func (c *AWSClient) S3Conn(ctx context.Context) *s3_sdkv1.S3 {
+ return errs.Must(conn[*s3_sdkv1.S3](ctx, c, names.S3, make(map[string]any)))
+}
+
func (client *AWSClient) S3ConnURICleaningDisabled(ctx context.Context) *s3_sdkv1.S3 {
config := client.S3Conn(ctx).Config
config.DisableRestProtocolURICleaning = aws_sdkv2.Bool(true)
@@ -175,7 +179,7 @@ func (c *AWSClient) DefaultKMSKeyPolicy() string {
"Resource": "*"
}
]
-}
+}
`, c.Partition, c.AccountID)
}

diff --git a/internal/service/s3/service_package_bwcompat.go b/internal/service/s3/service_package_bwcompat.go
new file mode 100644
index 0000000000..4278d1e70a
--- /dev/null
+++ b/internal/service/s3/service_package_bwcompat.go
@@ -0,0 +1,57 @@
+// Copyright (c) HashiCorp, Inc.
+// SPDX-License-Identifier: MPL-2.0
+
+package s3
+
+import (
+ "context"
+ "fmt"
+
+ aws_sdkv1 "github.com/aws/aws-sdk-go/aws"
+ endpoints_sdkv1 "github.com/aws/aws-sdk-go/aws/endpoints"
+ request_sdkv1 "github.com/aws/aws-sdk-go/aws/request"
+ session_sdkv1 "github.com/aws/aws-sdk-go/aws/session"
+ s3_sdkv1 "github.com/aws/aws-sdk-go/service/s3"
+ tfawserr_sdkv1 "github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr"
+)
+
+// NewConn returns a new AWS SDK for Go v1 client for this service package's AWS API.
+func (p *servicePackage) NewConn(ctx context.Context, m map[string]any) (*s3_sdkv1.S3, error) {
+ sess := m["session"].(*session_sdkv1.Session)
+ config := &aws_sdkv1.Config{
+ Endpoint: aws_sdkv1.String(m["endpoint"].(string)),
+ S3ForcePathStyle: aws_sdkv1.Bool(m["s3_use_path_style"].(bool)),
+ }
+
+ if v, ok := m["s3_us_east_1_regional_endpoint"]; ok {
+ switch v := v.(type) {
+ case string:
+ if v == "" {
+ config.S3UsEast1RegionalEndpoint = endpoints_sdkv1.RegionalS3UsEast1Endpoint
+ } else {
+ e, err := endpoints_sdkv1.GetS3UsEast1RegionalEndpoint(v)
+ if err != nil {
+ return nil, err
+ }
+ config.S3UsEast1RegionalEndpoint = e
+ }
+ case endpoints_sdkv1.S3UsEast1RegionalEndpoint:
+ config.S3UsEast1RegionalEndpoint = v
+ default:
+ return nil, fmt.Errorf("Unexpected type of s3_us_east_1_regional_endpoint")
+ }
+ }
+
+ return s3_sdkv1.New(sess.Copy(config)), nil
+}
+
+// CustomizeConn customizes a new AWS SDK for Go v1 client for this service package's AWS API.
+func (p *servicePackage) CustomizeConn(ctx context.Context, conn *s3_sdkv1.S3) (*s3_sdkv1.S3, error) {
+ conn.Handlers.Retry.PushBack(func(r *request_sdkv1.Request) {
+ if tfawserr_sdkv1.ErrMessageContains(r.Error, errCodeOperationAborted, "A conflicting conditional operation is currently in progress against this resource. Please try again.") {
+ r.Retryable = aws_sdkv1.Bool(true)
+ }
+ })
+
+ return conn, nil
+}
diff --git a/internal/service/s3legacy/bucket_legacy.go b/internal/service/s3legacy/bucket_legacy.go
index 007c2f2dc1..5f64a814be 100644
--- a/internal/service/s3legacy/bucket_legacy.go
+++ b/internal/service/s3legacy/bucket_legacy.go
@@ -31,7 +31,7 @@ import (
"github.com/hashicorp/terraform-provider-aws/internal/flex"
tftags "github.com/hashicorp/terraform-provider-aws/internal/tags"
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
- "github.com/hashicorp/terraform-provider-aws/internal/types"
+ "github.com/hashicorp/terraform-provider-aws/internal/types/option"
"github.com/hashicorp/terraform-provider-aws/internal/verify"
)

@@ -1393,7 +1393,7 @@ func resourceBucketLegacyRead(ctx context.Context, d *schema.ResourceData, meta
}

if inContext, ok := tftags.FromContext(ctx); ok {
- inContext.TagsOut = types.Some(tags)
+ inContext.TagsOut = option.Some(tags)
}

arn := arn.ARN{
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Anton Tayanovskyy <[email protected]>
Date: Fri, 19 Jan 2024 18:21:56 -0500
Subject: [PATCH 40/40] Apply patch_computed_only for serverless_cache and
amp_scraper


diff --git a/internal/service/amp/scraper.go b/internal/service/amp/scraper.go
index 5224c93b6e..26a572c6da 100644
--- a/internal/service/amp/scraper.go
+++ b/internal/service/amp/scraper.go
@@ -77,7 +77,7 @@ func (r *scraperResource) Schema(ctx context.Context, req resource.SchemaRequest
},
},
names.AttrTags: tftags.TagsAttribute(),
- names.AttrTagsAll: tftags.TagsAttributeComputedOnly(),
+ names.AttrTagsAll: tftags.TagsAttribute(),
},
Blocks: map[string]schema.Block{
"destination": schema.ListNestedBlock{
diff --git a/internal/service/elasticache/serverless_cache.go b/internal/service/elasticache/serverless_cache.go
index 1ea07b398e..54d8d5b5d7 100644
--- a/internal/service/elasticache/serverless_cache.go
+++ b/internal/service/elasticache/serverless_cache.go
@@ -176,7 +176,7 @@ func (r *resourceServerlessCache) Schema(ctx context.Context, request resource.S
},
},
names.AttrTags: tftags.TagsAttribute(),
- names.AttrTagsAll: tftags.TagsAttributeComputedOnly(),
+ names.AttrTagsAll: tftags.TagsAttribute(),
"user_group_id": schema.StringAttribute{
Optional: true,
},
Loading

0 comments on commit 9335f62

Please sign in to comment.