-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce accidentally dropped Plugin Framework resources (#3099)
Fixes #3081 An unfortunate interaction of schema manipulation over tags_all and how the upstream provider is written caused silent dropout of new PF based resources. WIth these changes `make tfgen` will fail loudly when this happens in the future, and the resources are now reintroduced to the provider. 5 resources in total: ``` `tags_all` attribute must not be Computed: aws_docdbelastic_cluster `tags_all` attribute must not be Computed: aws_eks_pod_identity_association `tags_all` attribute must not be Computed: aws_s3control_access_grant `tags_all` attribute must not be Computed: aws_s3control_access_grants_instance `tags_all` attribute must not be Computed: aws_s3control_access_grants_location ```
- Loading branch information
Showing
81 changed files
with
15,044 additions
and
4 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 |
---|---|---|
@@ -1,5 +1,11 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Anton Tayanovskyy <[email protected]> | ||
Date: Wed, 6 Dec 2023 23:41:21 -0500 | ||
Subject: [PATCH 32/32] Fix job queue sdkv2 migration | ||
|
||
|
||
diff --git a/internal/service/batch/job_queue_schema.go b/internal/service/batch/job_queue_schema.go | ||
index bd19814922..11cf093ece 100644 | ||
index 45c6b8cadc..11cf093ece 100644 | ||
--- a/internal/service/batch/job_queue_schema.go | ||
+++ b/internal/service/batch/job_queue_schema.go | ||
@@ -92,6 +92,7 @@ func upgradeJobQueueResourceStateV0toV1(ctx context.Context, req resource.Upgrad | ||
|
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,81 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Anton Tayanovskyy <[email protected]> | ||
Date: Wed, 6 Dec 2023 23:44:25 -0500 | ||
Subject: [PATCH 33/33] DisableTagSchemaCheck for PF provider | ||
|
||
|
||
diff --git a/internal/provider/fwprovider/provider.go b/internal/provider/fwprovider/provider.go | ||
index acde512855..f277744dbf 100644 | ||
--- a/internal/provider/fwprovider/provider.go | ||
+++ b/internal/provider/fwprovider/provider.go | ||
@@ -408,8 +408,7 @@ func (p *fwprovider) Resources(ctx context.Context) []func() resource.Resource { | ||
if v.Tags != nil { | ||
// The resource has opted in to transparent tagging. | ||
// Ensure that the schema look OK. | ||
- schemaResponse := resource.SchemaResponse{} | ||
- inner.Schema(ctx, resource.SchemaRequest{}, &schemaResponse) | ||
+ schemaResponse := schemaResponseForTagsChecking(ctx, inner) | ||
|
||
if v, ok := schemaResponse.Schema.Attributes[names.AttrTags]; ok { | ||
if v.IsComputed() { | ||
diff --git a/internal/provider/fwprovider/provider_tagscheck.go b/internal/provider/fwprovider/provider_tagscheck.go | ||
new file mode 100644 | ||
index 0000000000..f790acb4e2 | ||
--- /dev/null | ||
+++ b/internal/provider/fwprovider/provider_tagscheck.go | ||
@@ -0,0 +1,43 @@ | ||
+package fwprovider | ||
+ | ||
+import ( | ||
+ "context" | ||
+ | ||
+ "github.com/hashicorp/terraform-plugin-framework/resource" | ||
+ "github.com/hashicorp/terraform-plugin-framework/resource/schema" | ||
+ | ||
+ "github.com/hashicorp/terraform-provider-aws/names" | ||
+) | ||
+ | ||
+type disableTagsSchemaCheckKey struct{} | ||
+ | ||
+func DisableTagSchemaCheck(ctx context.Context) context.Context { | ||
+ return context.WithValue(ctx, disableTagsSchemaCheckKey{}, true) | ||
+} | ||
+ | ||
+func schemaResponseForTagsChecking( | ||
+ ctx context.Context, | ||
+ r resource.ResourceWithConfigure, | ||
+) *resource.SchemaResponse { | ||
+ flag := ctx.Value(disableTagsSchemaCheckKey{}) | ||
+ switch flag := flag.(type) { | ||
+ case bool: | ||
+ if flag { | ||
+ return &resource.SchemaResponse{ | ||
+ Schema: schema.Schema{ | ||
+ Attributes: map[string]schema.Attribute{ | ||
+ names.AttrTags: schema.MapAttribute{ | ||
+ Computed: true, | ||
+ }, | ||
+ names.AttrTagsAll: schema.MapAttribute{ | ||
+ Computed: false, | ||
+ }, | ||
+ }, | ||
+ }, | ||
+ } | ||
+ } | ||
+ } | ||
+ var resp resource.SchemaResponse | ||
+ r.Schema(ctx, resource.SchemaRequest{}, &resp) | ||
+ return &resp | ||
+} | ||
diff --git a/shim/shim.go b/shim/shim.go | ||
index 00297dbe77..9ef51a5245 100644 | ||
--- a/shim/shim.go | ||
+++ b/shim/shim.go | ||
@@ -18,6 +18,7 @@ type UpstreamProvider struct { | ||
} | ||
|
||
func NewUpstreamProvider(ctx context.Context) (UpstreamProvider, error) { | ||
+ ctx = fwprovider.DisableTagSchemaCheck(ctx) | ||
primary, err := provider.New(provider.DisableTagSchemaCheck(ctx)) | ||
if err != nil { | ||
return UpstreamProvider{}, err |
72 changes: 72 additions & 0 deletions
72
patches/0034-Run-scripts-patch_computed_only.sh-to-patch-eks-pod_.patch
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,72 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Anton Tayanovskyy <[email protected]> | ||
Date: Thu, 7 Dec 2023 00:05:40 -0500 | ||
Subject: [PATCH 34/34] Run scripts/patch_computed_only.sh to patch | ||
eks/pod_identity_association and more | ||
|
||
|
||
diff --git a/internal/service/docdbelastic/cluster.go b/internal/service/docdbelastic/cluster.go | ||
index 31b2fbe18f..aa6820adf4 100644 | ||
--- a/internal/service/docdbelastic/cluster.go | ||
+++ b/internal/service/docdbelastic/cluster.go | ||
@@ -127,7 +127,7 @@ func (r *resourceCluster) Schema(ctx context.Context, _ resource.SchemaRequest, | ||
}, | ||
}, | ||
names.AttrTags: tftags.TagsAttribute(), | ||
- names.AttrTagsAll: tftags.TagsAttributeComputedOnly(), | ||
+ names.AttrTagsAll: tftags.TagsAttribute(), | ||
"vpc_security_group_ids": schema.SetAttribute{ | ||
ElementType: types.StringType, | ||
Optional: true, | ||
diff --git a/internal/service/eks/pod_identity_association.go b/internal/service/eks/pod_identity_association.go | ||
index b5f6e46d2b..98c3f91956 100644 | ||
--- a/internal/service/eks/pod_identity_association.go | ||
+++ b/internal/service/eks/pod_identity_association.go | ||
@@ -105,7 +105,7 @@ func (r *podIdentityAssociationResource) Schema(ctx context.Context, req resourc | ||
}, | ||
}, | ||
names.AttrTags: tftags.TagsAttribute(), | ||
- names.AttrTagsAll: tftags.TagsAttributeComputedOnly(), | ||
+ names.AttrTagsAll: tftags.TagsAttribute(), | ||
}, | ||
} | ||
} | ||
diff --git a/internal/service/s3control/access_grant.go b/internal/service/s3control/access_grant.go | ||
index f2963c92a6..d93b539ff2 100644 | ||
--- a/internal/service/s3control/access_grant.go | ||
+++ b/internal/service/s3control/access_grant.go | ||
@@ -103,7 +103,7 @@ func (r *accessGrantResource) Schema(ctx context.Context, request resource.Schem | ||
}, | ||
}, | ||
names.AttrTags: tftags.TagsAttribute(), | ||
- names.AttrTagsAll: tftags.TagsAttributeComputedOnly(), | ||
+ names.AttrTagsAll: tftags.TagsAttribute(), | ||
}, | ||
Blocks: map[string]schema.Block{ | ||
"access_grants_location_configuration": schema.ListNestedBlock{ | ||
diff --git a/internal/service/s3control/access_grants_instance.go b/internal/service/s3control/access_grants_instance.go | ||
index 8adcc8ce67..ceb5336ce9 100644 | ||
--- a/internal/service/s3control/access_grants_instance.go | ||
+++ b/internal/service/s3control/access_grants_instance.go | ||
@@ -82,7 +82,7 @@ func (r *accessGrantsInstanceResource) Schema(ctx context.Context, request resou | ||
Optional: true, | ||
}, | ||
names.AttrTags: tftags.TagsAttribute(), | ||
- names.AttrTagsAll: tftags.TagsAttributeComputedOnly(), | ||
+ names.AttrTagsAll: tftags.TagsAttribute(), | ||
}, | ||
} | ||
} | ||
diff --git a/internal/service/s3control/access_grants_location.go b/internal/service/s3control/access_grants_location.go | ||
index f45d59078b..bead9b4bb9 100644 | ||
--- a/internal/service/s3control/access_grants_location.go | ||
+++ b/internal/service/s3control/access_grants_location.go | ||
@@ -84,7 +84,7 @@ func (r *accessGrantsLocationResource) Schema(ctx context.Context, request resou | ||
}, | ||
names.AttrID: framework.IDAttribute(), | ||
names.AttrTags: tftags.TagsAttribute(), | ||
- names.AttrTagsAll: tftags.TagsAttributeComputedOnly(), | ||
+ names.AttrTagsAll: tftags.TagsAttribute(), | ||
}, | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
patches/0035-Fail-fast-when-PF-resources-are-dropped.patch
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,21 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Anton Tayanovskyy <[email protected]> | ||
Date: Thu, 7 Dec 2023 00:18:14 -0500 | ||
Subject: [PATCH 35/35] Fail fast when PF resources are dropped | ||
|
||
|
||
diff --git a/internal/provider/fwprovider/provider.go b/internal/provider/fwprovider/provider.go | ||
index f277744dbf..00c69b64b5 100644 | ||
--- a/internal/provider/fwprovider/provider.go | ||
+++ b/internal/provider/fwprovider/provider.go | ||
@@ -439,9 +439,7 @@ func (p *fwprovider) Resources(ctx context.Context) []func() resource.Resource { | ||
} | ||
|
||
if err := errors.Join(errs...); err != nil { | ||
- tflog.Warn(ctx, "registering resources", map[string]interface{}{ | ||
- "error": err.Error(), | ||
- }) | ||
+ panic(err) | ||
} | ||
|
||
return resources |
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
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.