Skip to content

Commit

Permalink
feat(pulumi): add spec.showSecretsInOutput config to Pulumi deploy …
Browse files Browse the repository at this point in the history
…action (#6555)

* fix(pulumi): show secrets in pulumi stack output

* feat(pulumi): Add `spec.showSecretsInOutput` config to Pulumi deploy action

* chore: regenerate docs
  • Loading branch information
BraedonLeonard authored Oct 22, 2024
1 parent 14ec9a8 commit 682e378
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 1 deletion.
13 changes: 13 additions & 0 deletions docs/reference/action-types/Deploy/pulumi.md
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,19 @@ The name of the pulumi stack to use. Defaults to the current environment name.
| -------- | -------- |
| `string` | No |

### `spec.showSecretsInOutput`

[spec](#spec) > showSecretsInOutput

When set to true, stack outputs which are marked as secrets will be shown in the output.

By default, Pulumi will print secret stack outputs as the string '[secret]' instead of
the true content of the output.

| Type | Default | Required |
| --------- | ------- | -------- |
| `boolean` | `false` | No |


## Outputs

Expand Down
17 changes: 17 additions & 0 deletions docs/reference/module-types/pulumi.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,12 @@ deployFromPreview: false

# The name of the pulumi stack to use. Defaults to the current environment name.
stack:

# When set to true, stack outputs which are marked as secrets will be shown in the output.
#
# By default, Pulumi will print secret stack outputs as the string '[secret]' instead of
# the true content of the output.
showSecretsInOutput: false
```
## Configuration Keys
Expand Down Expand Up @@ -707,6 +713,17 @@ The name of the pulumi stack to use. Defaults to the current environment name.
| -------- | -------- |
| `string` | No |

### `showSecretsInOutput`

When set to true, stack outputs which are marked as secrets will be shown in the output.

By default, Pulumi will print secret stack outputs as the string '[secret]' instead of
the true content of the output.

| Type | Default | Required |
| --------- | ------- | -------- |
| `boolean` | `false` | No |


## Outputs

Expand Down
12 changes: 12 additions & 0 deletions plugins/pulumi/src/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface PulumiDeploySpec {
deployFromPreview: boolean
root: string
stack?: string
showSecretsInOutput: boolean
}

export type PulumiDeployConfig = DeployActionConfig<"pulumi", PulumiDeploySpec>
Expand Down Expand Up @@ -129,6 +130,17 @@ export const pulumiDeploySchemaKeys = () => ({
.string()
.allow(null)
.description("The name of the pulumi stack to use. Defaults to the current environment name."),
showSecretsInOutput: joi
.boolean()
.default(false)
.description(
dedent`
When set to true, stack outputs which are marked as secrets will be shown in the output.
By default, Pulumi will print secret stack outputs as the string '[secret]' instead of
the true content of the output.
`
),
})

export const pulumiDeploySchema = createSchema({
Expand Down
6 changes: 5 additions & 1 deletion plugins/pulumi/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,13 @@ export async function previewStack(
}

export async function getStackOutputs({ log, ctx, provider, action }: PulumiParams): Promise<any> {
const args = ["stack", "output", "--json"]
if (action.getSpec("showSecretsInOutput")) {
args.push("--show-secrets")
}
const res = await pulumi(ctx, provider).json({
log,
args: ["stack", "output", "--json"],
args,
env: ensureEnv({ log, ctx, provider, action }),
cwd: getActionStackRoot(action),
})
Expand Down
1 change: 1 addition & 0 deletions plugins/pulumi/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export const gardenPlugin = () =>
cacheStatus: module.spec.cacheStatus || false,
stackReferences: module.spec.stackReferences || [],
deployFromPreview: module.spec.deployFromPreview || false,
showSecretsInOutput: module.spec.showSecretsInOutput || false,
root: module.spec.root || ".",
...omit(module.spec, ["build", "dependencies"]),
},
Expand Down

0 comments on commit 682e378

Please sign in to comment.