-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pluralized lifecycle_policies to EFS file system data source (#4590)
The `lifecycle_policy` output of the `efs.getFileSystem` data source has `MaxItemsOne` hardcoded on the Pulumi side and this triggers panics when there is more than one lifecycle policy on the resource. By adding a pluralized lifecycle_policies output and fixing the singular version to only return at most one element we're able to fix this panic without introducing breaking changes. To incentivize users to move to the pluralized version I've marked the singular version as deprecated. During the next major release we can drop the patch (I'll create a tracking ticket once this PR goes in) and the auto-aliasing should correctly drop `MaxItemsOne` as well. At that point we're tracking upstream behavior again. Fixes #4568
- Loading branch information
1 parent
d80f7d1
commit 9a752fd
Showing
16 changed files
with
274 additions
and
14 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
patches/0067-Add-pluralized-lifecycle_policies-to-EFS-file-system.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,68 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Florian Stadler <[email protected]> | ||
Date: Tue, 1 Oct 2024 20:39:29 +0200 | ||
Subject: [PATCH] Add pluralized lifecycle_policies to EFS file system data | ||
source | ||
|
||
The lifecycle_policy attribute has MaxItemsOne hardcoded on the | ||
Pulumi side and this triggers panics when there is more than | ||
one lifecycle policy on the resource. | ||
By adding pluralized lifecycle_policies and fixing the singular | ||
version to only return at most one element we're able to fix this | ||
panic without introducing breaking changes. | ||
|
||
diff --git a/internal/service/efs/file_system_data_source.go b/internal/service/efs/file_system_data_source.go | ||
index f045aa36a4..a7b710fe9b 100644 | ||
--- a/internal/service/efs/file_system_data_source.go | ||
+++ b/internal/service/efs/file_system_data_source.go | ||
@@ -63,6 +63,28 @@ func dataSourceFileSystem() *schema.Resource { | ||
Computed: true, | ||
}, | ||
"lifecycle_policy": { | ||
+ Type: schema.TypeList, | ||
+ Computed: true, | ||
+ Deprecated: "Use `lifecycle_policies` instead. This field will be removed in the next major version.", | ||
+ Elem: &schema.Resource{ | ||
+ Schema: map[string]*schema.Schema{ | ||
+ "transition_to_archive": { | ||
+ Type: schema.TypeString, | ||
+ Computed: true, | ||
+ }, | ||
+ "transition_to_ia": { | ||
+ Type: schema.TypeString, | ||
+ Computed: true, | ||
+ }, | ||
+ "transition_to_primary_storage_class": { | ||
+ Type: schema.TypeString, | ||
+ Computed: true, | ||
+ }, | ||
+ }, | ||
+ }, | ||
+ }, | ||
+ // duplicating lifecycle_policy to drop the hard coded MaxItemsOne on the Pulumi side without a breaking change | ||
+ "lifecycle_policies": { | ||
Type: schema.TypeList, | ||
Computed: true, | ||
Elem: &schema.Resource{ | ||
@@ -179,9 +201,20 @@ func dataSourceFileSystemRead(ctx context.Context, d *schema.ResourceData, meta | ||
return sdkdiag.AppendErrorf(diags, "reading EFS File System (%s) lifecycle configuration: %s", d.Id(), err) | ||
} | ||
|
||
- if err := d.Set("lifecycle_policy", flattenLifecyclePolicies(output.LifecyclePolicies)); err != nil { | ||
+ flattenedLifecyclePolicies := flattenLifecyclePolicies(output.LifecyclePolicies) | ||
+ | ||
+ // if there are any lifecycle policies then set the first one as the singular version | ||
+ var singularLifeCyclePolicy []interface{} | ||
+ if len(flattenedLifecyclePolicies) > 0 { | ||
+ singularLifeCyclePolicy = append(singularLifeCyclePolicy, flattenedLifecyclePolicies[0]) | ||
+ } | ||
+ | ||
+ if err := d.Set("lifecycle_policy", singularLifeCyclePolicy); err != nil { | ||
return sdkdiag.AppendErrorf(diags, "setting lifecycle_policy: %s", err) | ||
} | ||
+ if err := d.Set("lifecycle_policies", flattenedLifecyclePolicies); err != nil { | ||
+ return sdkdiag.AppendErrorf(diags, "setting lifecycle_policies: %s", err) | ||
+ } | ||
|
||
return diags | ||
} |
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.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
name: regress-4568 | ||
runtime: nodejs | ||
description: A minimal AWS TypeScript Pulumi program | ||
config: | ||
pulumi:tags: | ||
value: | ||
pulumi:template: aws-typescript |
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,12 @@ | ||
import * as aws from "@pulumi/aws"; | ||
|
||
const efsFilesystem = new aws.efs.FileSystem("my-efs", { | ||
lifecyclePolicies: [{ | ||
transitionToIa: "AFTER_30_DAYS", | ||
}, { | ||
transitionToPrimaryStorageClass: "AFTER_1_ACCESS", | ||
}], | ||
}); | ||
|
||
export const lifecyclePolicy = aws.efs.getFileSystemOutput({ fileSystemId: efsFilesystem.id }).lifecyclePolicy; | ||
export const lifecyclePolicies = aws.efs.getFileSystemOutput({ fileSystemId: efsFilesystem.id }).lifecyclePolicies; |
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,11 @@ | ||
{ | ||
"name": "regress-4568", | ||
"main": "index.ts", | ||
"devDependencies": { | ||
"@types/node": "^18" | ||
}, | ||
"dependencies": { | ||
"@pulumi/pulumi": "^3.0.0", | ||
"@pulumi/aws": "^6.0.0" | ||
} | ||
} |
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,18 @@ | ||
{ | ||
"compilerOptions": { | ||
"strict": true, | ||
"outDir": "bin", | ||
"target": "es2016", | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"sourceMap": true, | ||
"experimentalDecorators": true, | ||
"pretty": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"noImplicitReturns": true, | ||
"forceConsistentCasingInFileNames": true | ||
}, | ||
"files": [ | ||
"index.ts" | ||
] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.