Skip to content

Commit

Permalink
Fix defaultTags to trigger downstream updates
Browse files Browse the repository at this point in the history
The `defaultTags` input property on providers now triggers an update on
downstream resources. Because of the nature of the fix in the Pulumi TF Bridge,
and to limit the scope of the change, we mark only the `tags_all` field from TF
schema as a `ComputedInput`, triggering new diff behavior within the bridge.

As the `tags_all` field is otherwise hidden as a "computed" value, we omit
detailed diff information. This is a tradeoff to avoid a more invasive change
with more risk.

Fixes #1655.

Example output:

```
pulumi up --skip-preview
Updating (test-aws-1655)

View in Browser (Ctrl+O): https://app.pulumi.com/pulumi/simple-yaml/test-aws-1655/updates/9

     Type                     Name                       Status              Info
     pulumi:pulumi:Stack      simple-yaml-test-aws-1655
 ~   ├─ pulumi:providers:aws  aws-provider               updated (0.13s)     [diff: ~defaultTags]
 ~   ├─ aws:s3:Bucket         my-bucket                  updated (0.87s)
 ~   └─ aws:s3:BucketObject   index.html                 updated (0.24s)
```

Verified when adding, updating, deleting, and removing entirely the
`defaultTags` property.
  • Loading branch information
AaronFriel committed Jun 30, 2023
1 parent 93ecd56 commit 8a97a53
Show file tree
Hide file tree
Showing 10 changed files with 2,067 additions and 358 deletions.
13 changes: 13 additions & 0 deletions examples/default-tags-yaml/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: test-aws-1655
runtime: yaml
description: A minimal Pulumi YAML program
resources:
aws-provider:
type: pulumi:providers:aws
# properties:
# defaultTags: {}
defaultProvider: true
my-bucket:
type: aws:s3:Bucket
outputs:
bucketTags: ${my-bucket.tagsAll}
15 changes: 15 additions & 0 deletions examples/default-tags-yaml/step1/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: test-aws-1655
runtime: yaml
description: A minimal Pulumi YAML program
resources:
aws-provider:
type: pulumi:providers:aws
properties:
defaultTags:
tags:
foo: bar
defaultProvider: true
my-bucket:
type: aws:s3:Bucket
outputs:
bucketTags: ${my-bucket.tagsAll}
15 changes: 15 additions & 0 deletions examples/default-tags-yaml/step2/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: test-aws-1655
runtime: yaml
description: A minimal Pulumi YAML program
resources:
aws-provider:
type: pulumi:providers:aws
properties:
defaultTags:
tags:
foo: quux
defaultProvider: true
my-bucket:
type: aws:s3:Bucket
outputs:
bucketTags: ${my-bucket.tagsAll}
16 changes: 16 additions & 0 deletions examples/default-tags-yaml/step3/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: test-aws-1655
runtime: yaml
description: A minimal Pulumi YAML program
resources:
aws-provider:
type: pulumi:providers:aws
properties:
defaultTags:
tags:
foo: quux
thwomp: pow
defaultProvider: true
my-bucket:
type: aws:s3:Bucket
outputs:
bucketTags: ${my-bucket.tagsAll}
14 changes: 14 additions & 0 deletions examples/default-tags-yaml/step4/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: test-aws-1655
runtime: yaml
description: A minimal Pulumi YAML program
resources:
aws-provider:
type: pulumi:providers:aws
properties:
defaultTags:
tags: {}
defaultProvider: true
my-bucket:
type: aws:s3:Bucket
outputs:
bucketTags: ${my-bucket.tagsAll}
11 changes: 11 additions & 0 deletions examples/default-tags-yaml/step5/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: test-aws-1655
runtime: yaml
description: A minimal Pulumi YAML program
resources:
aws-provider:
type: pulumi:providers:aws
defaultProvider: true
my-bucket:
type: aws:s3:Bucket
outputs:
bucketTags: ${my-bucket.tagsAll}
45 changes: 45 additions & 0 deletions examples/examples_go_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ package examples

import (
"path/filepath"
"strconv"
"testing"

"github.com/pulumi/pulumi/pkg/v3/testing/integration"
"github.com/stretchr/testify/assert"
)

func TestAccWebserverGo(t *testing.T) {
Expand All @@ -22,3 +24,46 @@ func TestAccWebserverGo(t *testing.T) {

integration.ProgramTest(t, &test)
}

func TestAccDefaultTagsGo(t *testing.T) {
stepOutputs := []map[string]interface{}{
{},
{
"foo": "bar",
},
{
"foo": "quux",
},
{
"foo": "quux",
"thwomp": "pow",
},
{},
}

editDirs := []integration.EditDir{}
for i, stepOutput := range stepOutputs {
i := i
stepOutput := stepOutput
editDirs = append(editDirs, integration.EditDir{
Dir: filepath.Join(getCwd(t), "default-tags-yaml", "step"+strconv.Itoa(i)),
Additive: true,
ExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) {
stackOutputBucketTags := stackInfo.Outputs["bucketTags"].(map[string]interface{})
assert.Equal(t, stepOutput, stackOutputBucketTags, "Unexpected stack output for step %d", i)
},
})
}

integration.ProgramTest(t, &integration.ProgramTestOptions{
Dir: filepath.Join(getCwd(t), "default-tags-yaml"),

ExtraRuntimeValidation: editDirs[0].ExtraRuntimeValidation,
EditDirs: editDirs[1:],

Config: map[string]string{"aws:region": getEnvRegion(t)},
Quick: true,
DestroyOnCleanup: true,
})

}
Loading

0 comments on commit 8a97a53

Please sign in to comment.