Skip to content

Conversation

@rshade
Copy link
Contributor

@rshade rshade commented Oct 2, 2025

Add a new StackTags resource that allows managing multiple stack tags as a single resource, improving the user experience especially for YAML users who can now define tags as a map rather than creating individual StackTag resources for each tag.

Changes

  • Schema: Added pulumiservice:index:StackTags resource definition with support for map[string]string tags property
  • API Client: Added GetStackTags() helper method to retrieve all stack tags at once
  • Resource Implementation: Created PulumiServiceStackTagsResource with full CRUD support:
    • Create: Iterates through tags map and creates each tag
    • Read: Retrieves all stack tags and filters to managed set
    • Update: Calculates diff (add/remove/modify) and applies changes
    • Delete: Removes all managed tags
    • Diff: Detects changes with proper replace-on-change for org/project/stack
  • Provider Registration: Registered new resource in provider
  • Unit Tests: Added comprehensive unit tests for all CRUD operations
  • Integration Test: Added YAML example and test case demonstrating usage

Implementation Details

The StackTags resource manages multiple tags as a unit while respecting tag immutability in the Pulumi Cloud API. Tag value changes are handled by deleting the old tag and creating a new one. The resource tracks which tags it manages in state to avoid interfering with tags created by other resources or manual operations.

Example Usage

stackTags:
  type: pulumiservice:StackTags
  properties:
    organization: my-org
    project: my-project
    stack: my-stack
    tags:
      environment: production
      team: platform
      cost-center: engineering

A complete working example is available in examples/yaml-stack-tags-plural/ and tested in TestYamlStackTagsPluralExample.

Fixes #61

@rshade rshade force-pushed the rshade/StackTags branch 2 times, most recently from af86c83 to 148ea82 Compare October 2, 2025 21:12
@github-actions
Copy link

github-actions bot commented Oct 2, 2025

Does the PR have any schema changes?

Looking good! No breaking changes found.

New resources:

  • index.StackTags

Maintainer note: consult the runbook for dealing with any breaking changes.

@rshade rshade force-pushed the rshade/StackTags branch 3 times, most recently from babd800 to ad76dd1 Compare October 7, 2025 18:29
@rshade rshade requested a review from Copilot October 7, 2025 18:31
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new StackTags resource that allows managing multiple stack tags as a single resource, improving the user experience especially for YAML users who can now define tags as a map rather than creating individual StackTag resources for each tag.

  • Introduces pulumiservice:index:StackTags resource with map-based tag management
  • Adds helper method GetStackTags() to API client for retrieving all stack tags
  • Implements complete CRUD operations with proper diff detection and replace-on-change behavior
  • Includes comprehensive unit tests and integration test with YAML example

Reviewed Changes

Copilot reviewed 19 out of 21 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
sdk/python/pulumi_pulumiservice/stack_tags.py Generated Python SDK bindings for StackTags resource
sdk/python/pulumi_pulumiservice/init.py Registers StackTags in Python SDK exports
sdk/nodejs/stackTags.ts Generated Node.js SDK bindings for StackTags resource
sdk/nodejs/index.ts Registers StackTags in Node.js SDK exports
sdk/go/pulumiservice/stackTags.go Generated Go SDK bindings for StackTags resource
sdk/dotnet/StackTags.cs Generated .NET SDK bindings for StackTags resource
provider/pkg/util/property_map.go Adds map[string]string support to property conversion utilities
provider/pkg/resources/stack_tags_plural.go Core StackTags resource implementation with CRUD operations
provider/pkg/pulumiapi/stack_tags.go Adds GetStackTags helper method to API client
provider/cmd/pulumi-resource-pulumiservice/schema.json Schema definition for StackTags resource
examples/yaml-stack-tags-plural/Pulumi.yaml YAML example demonstrating StackTags usage
Comments suppressed due to low confidence (1)

examples/yaml-stack-tags-plural/Pulumi.yaml:1

  • Corrected spelling of 'it's' to 'its'.
name: yaml-stack-tags-plural-example

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@rshade rshade requested review from a team and komalali October 8, 2025 14:07
@rshade
Copy link
Contributor Author

rshade commented Oct 8, 2025

@komalali I tagged you in on the review as you re-opened the ticket. Does this fit the ticket?

@nyobe
Copy link
Contributor

nyobe commented Oct 9, 2025

for my own education, why is StackTag its own resource, rather than tags being a property on the Stack resource?

@rshade
Copy link
Contributor Author

rshade commented Oct 13, 2025

for my own education, why is StackTag its own resource, rather than tags being a property on the Stack resource?

I think it's because the stack is created via the cli, and these are appended to it: https://www.pulumi.com/docs/pulumi-cloud/reference/stack-tags/

@rshade rshade enabled auto-merge (squash) October 13, 2025 21:33
@fnune fnune requested review from nyobe and removed request for a team October 20, 2025 10:32
@rshade rshade force-pushed the rshade/StackTags branch 2 times, most recently from 4efbe4e to a860ca3 Compare October 27, 2025 21:55
Add a new `StackTags` resource that allows managing multiple stack tags
as a single resource, improving the user experience especially for YAML
users who can now define tags as a map rather than creating individual
StackTag resources for each tag.

- **Schema**: Added `pulumiservice:index:StackTags` resource definition
  with support for map[string]string tags property
- **API Client**: Added `GetStackTags()` helper method to retrieve all
  stack tags at once
- **Resource Implementation**: Created `PulumiServiceStackTagsResource`
  with full CRUD support:
  - Create: Iterates through tags map and creates each tag
  - Read: Retrieves all stack tags and filters to managed set
  - Update: Calculates diff (add/remove/modify) and applies changes
  - Delete: Removes all managed tags
  - Diff: Detects changes with proper replace-on-change for org/project/stack
- **Provider Registration**: Registered new resource in provider
- **Unit Tests**: Added comprehensive unit tests for all CRUD operations
- **Integration Test**: Added YAML example and test case demonstrating usage

The StackTags resource manages multiple tags as a unit while respecting
tag immutability in the Pulumi Cloud API. Tag value changes are handled
by deleting the old tag and creating a new one. The resource tracks which
tags it manages in state to avoid interfering with tags created by other
resources or manual operations.

```yaml
stackTags:
  type: pulumiservice:StackTags
  properties:
    organization: my-org
    project: my-project
    stack: my-stack
    tags:
      environment: production
      team: platform
      cost-center: engineering
```

A complete working example is available in `examples/yaml-stack-tags-plural/`
and tested in `TestYamlStackTagsPluralExample`.

Fixes #61
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add StackTags resource

2 participants