Skip to content

Commit

Permalink
feat(providers): pulumi project/stack set via env var (#342)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Gershman <andrew@cndr.io>
  • Loading branch information
agershman authored Apr 28, 2024
1 parent 843834b commit 264dfba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -717,14 +717,16 @@ Obtain value in state pulled from Pulumi Cloud REST API:
* `RESOURCE_LOGICAL_NAME` is the [logical name](https://www.pulumi.com/docs/concepts/resources/names/#logicalname) of the resource in the Pulumi program.
* `ATTRIBUTE_TYPE` is either `outputs` or `inputs`.
* `ATTRIBUTE_KEY_PATH` is a [GJSON](https://github.com/tidwall/gjson/blob/master/SYNTAX.md) expression that selects the desired attribute from the resource's inputs or outputs per the chosen `ATTRIBUTE_TYPE` value. You must encode any characters that would otherwise not comply with URI syntax, for example `#` becomes `%23`.
* `project` is the Pulumi project name.
* `stack` is the Pulumi stack name.
* `project` is the Pulumi project name. May also be provided via the `PULUMI_PROJECT` environment variable.
* `stack` is the Pulumi stack name. May also be provided via the `PULUMI_STACK` environment variable.
Environment variables:
- `PULUMI_API_ENDPOINT_URL` is the Pulumi API endpoint URL. Defaults to `https://api.pulumi.com`. You may also provide this as the `pulumi_api_endpoint_url` query parameter.
- `PULUMI_ACCESS_TOKEN` is the Pulumi access token to use for authentication.
- `PULUMI_ORGANIZATION` is the Pulumi organization to use for authentication. You may also provide this as an `organization` query parameter.
- `PULUMI_PROJECT` is the Pulumi project. You may also provide this as a `project` query parameter.
- `PULUMI_STACK` is the Pulumi stack. You may also provide this as a `stack` query parameter.
Examples:
Expand Down
13 changes: 11 additions & 2 deletions pkg/providers/pulumi/pulumi.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,17 @@ func New(l *log.Logger, cfg api.StaticConfig, backend string) *provider {
p.organization = os.Getenv("PULUMI_ORGANIZATION")
}

p.project = cfg.String("project")
p.stack = cfg.String("stack")
if cfg.Exists("project") {
p.project = cfg.String("project")
} else {
p.project = os.Getenv("PULUMI_PROJECT")
}

if cfg.Exists("stack") {
p.stack = cfg.String("stack")
} else {
p.stack = os.Getenv("PULUMI_STACK")
}

p.log.Debugf("pulumi: backend=%q, api_endpoint=%q, organization=%q, project=%q, stack=%q",
p.backend, p.pulumiAPIEndpointURL, p.organization, p.project, p.stack)
Expand Down

0 comments on commit 264dfba

Please sign in to comment.