Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix redrive_allow_policy JSON diff in upstream provider #4749

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions patches/0077-Fix-spurious-JSON-diff-for-redrive_allow_policy.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: James Forcier <[email protected]>
Date: Mon, 11 Nov 2024 16:12:57 -0500
Subject: [PATCH] Fix spurious JSON diff for redrive_allow_policy

This applies the same fix found in #2529 to the RedriveAllowPolicy
resource, which needs the same treatment.

diff --git a/internal/service/sqs/queue_redrive_allow_policy.go b/internal/service/sqs/queue_redrive_allow_policy.go
index 7e3c390e50..789bb04619 100644
--- a/internal/service/sqs/queue_redrive_allow_policy.go
+++ b/internal/service/sqs/queue_redrive_allow_policy.go
@@ -32,9 +32,10 @@ func resourceQueueRedriveAllowPolicy() *schema.Resource {
ForceNew: true,
},
"redrive_allow_policy": {
- Type: schema.TypeString,
- Required: true,
- ValidateFunc: validation.StringIsJSON,
+ Type: schema.TypeString,
+ Required: true,
+ ValidateFunc: validation.StringIsJSON,
+ DiffSuppressFunc: verify.SuppressEquivalentJSONDiffs,
StateFunc: func(v interface{}) string {
json, _ := structure.NormalizeJsonString(v)
return json
8 changes: 8 additions & 0 deletions provider/provider_python_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ func TestRegress4457(t *testing.T) {
t.Logf("%s", previewResult.StdErr)
}

func TestRegress4760(t *testing.T) {
ptest := pulumiTest(t, filepath.Join("test-programs", "regress-4760"))
upResult := ptest.Up(t)
t.Logf("#%v", upResult.Summary)
result := ptest.Preview(t, optpreview.ExpectNoChanges())
t.Logf("#%v", result.ChangeSummary)
}

func getPythonBaseOptions(t *testing.T) integration.ProgramTestOptions {
t.Helper()
envRegion := getEnvRegion(t)
Expand Down
2 changes: 2 additions & 0 deletions provider/test-programs/regress-4760/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.pyc
venv/
10 changes: 10 additions & 0 deletions provider/test-programs/regress-4760/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: regress-4760
runtime:
name: python
options:
virtualenv: venv
description: Provision an SQS queue/DLQ to test RedriveAllowPolicy diffs
config:
pulumi:tags:
value:
pulumi:template: aws-python
24 changes: 24 additions & 0 deletions provider/test-programs/regress-4760/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import pulumi
from pulumi_aws import sqs

dlq = sqs.Queue("demo-dlq")
queue = sqs.Queue(
"demo-queue",
redrive_policy=pulumi.Output.json_dumps(
{
"deadLetterTargetArn": dlq.arn,
"maxReceiveCount": 2,
}
)
)

redrive_allow_policy = sqs.RedriveAllowPolicy(
"demo",
queue_url=dlq.id,
redrive_allow_policy=pulumi.Output.json_dumps(
{
"redrivePermission": "byQueue",
"sourceQueueArns": [queue.arn],
}
)
)
2 changes: 2 additions & 0 deletions provider/test-programs/regress-4760/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pulumi>=3.0.0,<4.0.0
pulumi-aws>=6.0.2,<7.0.0