diff --git a/examples/cs-environments/MyStack.cs b/examples/cs-environments/MyStack.cs index d72f1f10..2fb7e640 100644 --- a/examples/cs-environments/MyStack.cs +++ b/examples/cs-environments/MyStack.cs @@ -22,5 +22,30 @@ public MyStack() Yaml = new StringAsset(yaml) } ); + + // A tag that will always be placed on the latest revision of the environment + var stableTag = new Pulumi.PulumiService.EnvironmentVersionTag( + "StableTag", + new EnvironmentVersionTagArgs { + Organization = environment.Organization, + Environment = environment.Name, + TagName = "stable", + Revision = environment.Revision + } + ); + + // A tag that will be placed on each new version, and remain on old revisions + var versionTag = new Pulumi.PulumiService.EnvironmentVersionTag( + "VersionTag", + new EnvironmentVersionTagArgs { + Organization = environment.Organization, + Environment = environment.Name, + TagName = environment.Revision.Apply(rev => "v"+rev), + Revision = environment.Revision + }, + new CustomResourceOptions{ + RetainOnDelete = true + } + ); } } diff --git a/examples/go-environments/main.go b/examples/go-environments/main.go index a4966dd1..8c0cf71f 100644 --- a/examples/go-environments/main.go +++ b/examples/go-environments/main.go @@ -1,13 +1,15 @@ package main import ( + "strconv" + "github.com/pulumi/pulumi-pulumiservice/sdk/go/pulumiservice" "github.com/pulumi/pulumi/sdk/v3/go/pulumi" ) func main() { pulumi.Run(func(ctx *pulumi.Context) error { - _, err := pulumiservice.NewEnvironment(ctx, "testing-environment", &pulumiservice.EnvironmentArgs{ + environment, err := pulumiservice.NewEnvironment(ctx, "testing-environment", &pulumiservice.EnvironmentArgs{ Name: pulumi.String("testing-environment-go"), Organization: pulumi.String("service-provider-test-org"), Yaml: pulumi.NewStringAsset(` @@ -20,6 +22,31 @@ func main() { if err != nil { return err } + + // A tag that will always be placed on the latest revision of the environment + _, err = pulumiservice.NewEnvironmentVersionTag(ctx, "StableTag", &pulumiservice.EnvironmentVersionTagArgs{ + Organization: environment.Organization, + Environment: environment.Name, + TagName: pulumi.String("stable"), + Revision: environment.Revision, + }) + if err != nil { + return err + } + + // A tag that will be placed on each new version, and remain on old revisions + _, err = pulumiservice.NewEnvironmentVersionTag(ctx, "VersionTag", &pulumiservice.EnvironmentVersionTagArgs{ + Organization: environment.Organization, + Environment: environment.Name, + TagName: environment.Revision.ApplyT(func(rev int) (string, error) { + return "v" + strconv.Itoa(rev), nil + }).(pulumi.StringOutput), + Revision: environment.Revision, + }, pulumi.RetainOnDelete(true)) + if err != nil { + return err + } + return nil }) } diff --git a/examples/py-environments/__main__.py b/examples/py-environments/__main__.py index f36a5fc0..6b568143 100644 --- a/examples/py-environments/__main__.py +++ b/examples/py-environments/__main__.py @@ -1,7 +1,8 @@ """A Python Pulumi Service Environments program""" import pulumi -from pulumi_pulumiservice import Environment +from pulumi_pulumiservice import Environment, EnvironmentVersionTag +from pulumi import ResourceOptions environment = Environment( "testing-environment", @@ -15,3 +16,26 @@ myNumber: 1 """) ) + +# A tag that will always be placed on the latest revision of the environment +stableTag = EnvironmentVersionTag( + "StableTag", + organization=environment.organization, + environment=environment.name, + tag_name="stable", + revision=environment.revision, +) + +# A tag that will be placed on each new version, and remain on old revisions +versionTag = EnvironmentVersionTag( + "VersionTag", + organization=environment.organization, + environment=environment.name, + tag_name=environment.revision.apply( + lambda revision: "v" + str(revision) + ), + revision=environment.revision, + opts=ResourceOptions( + retain_on_delete=True + ) +) diff --git a/examples/ts-environments/index.ts b/examples/ts-environments/index.ts index 88f806c7..6ae675fe 100644 --- a/examples/ts-environments/index.ts +++ b/examples/ts-environments/index.ts @@ -12,3 +12,21 @@ var environment = new service.Environment("testing-environment", { myNumber: 1` ) }) + +// A tag that will always be placed on the latest revision of the environment +var stableTag = new service.EnvironmentVersionTag("StableTag", { + organization: environment.organization, + environment: environment.name, + tagName: "stable", + revision: environment.revision +}) + +// A tag that will be placed on each new version, and remain on old revisions +var versionTag = new service.EnvironmentVersionTag("VersionTag", { + organization: environment.organization, + environment: environment.name, + tagName: environment.revision.apply((rev: number) => "v"+rev), + revision: environment.revision +}, { + retainOnDelete: true +}) diff --git a/examples/yaml-environments/Pulumi.yaml b/examples/yaml-environments/Pulumi.yaml index 7fc724d4..75a5fa81 100644 --- a/examples/yaml-environments/Pulumi.yaml +++ b/examples/yaml-environments/Pulumi.yaml @@ -8,9 +8,25 @@ resources: organization: service-provider-test-org name: testing-environment-yaml yaml: - fn::stringAsset: > + fn::stringAsset: |- values: myKey1: "myValue1" myNestedKey: myKey2: "myValue2" - myNumber: 1 \ No newline at end of file + myNumber: 1 + stableTag: + type: pulumiservice:EnvironmentVersionTag + properties: + organization: ${testing-environment.organization} + environment: ${testing-environment.name} + tagName: stable + revision: ${testing-environment.revision} + versionTag: + type: pulumiservice:EnvironmentVersionTag + properties: + organization: ${testing-environment.organization} + environment: ${testing-environment.name} + tagName: v${testing-environment.revision} + revision: ${testing-environment.revision} + options: + retainOnDelete: true