Skip to content

Commit

Permalink
Update to add exec outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasjackson committed Apr 11, 2024
1 parent 740d6db commit 4e905a7
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 137 deletions.
4 changes: 2 additions & 2 deletions src/pages/docs/resources/container/container.mdx
Expand Up @@ -141,9 +141,9 @@ The `container` resource allows you to create Docker containers.
```
</Property>

<Property name="fqrn" type="string" required="false" value="" readonly>
<Property name="container_name" type="string" required="false" value="" readonly>
Fully qualified resource name for the container, this value can be used to
access the container from within the Docker network. `fqrn` is also the name
access the container from within the Docker network. `container_name` is also the name
of the created Docker container.

```
Expand Down
4 changes: 2 additions & 2 deletions src/pages/docs/resources/container/sidecar.mdx
Expand Up @@ -169,9 +169,9 @@ to the target container.
```
</Property>

<Property name="fqrn" type="string" required="false" value="" readonly>
<Property name="container_name" type="string" required="false" value="" readonly>
Fully qualified resource name for the container, this value can be used to
access the container from within the Docker network. `fqrn` is also the name
access the container from within the Docker network. `container_name` is also the name
of the created Docker container.

```
Expand Down
39 changes: 39 additions & 0 deletions src/pages/docs/resources/exec/index.mdx
Expand Up @@ -32,6 +32,32 @@ and running container. When targeting an existing container, the `target` field
must be specified. When running in a stand alone container, the `image` block must
be specified.

### Setting outputs

Output variables for the exec resource can be set by echoing a key value pair
to the output file inside the script. An environment variable `${EXEC_OUTPUT}`
is automatically added to the environment of the script and points to the output.

Any outputs set in the script are automatically parsed into a map
and are available via the `output` parameter.

The following example demonstrates how to set an output variable in a script.

```hcl
resource "exec" "inline" {
script = <<-EOF
#!/bin/bash
ls -lha
echo "FOO=BAR" > ${EXEC_OUTPUT}
EOF
}
output "foo" {
value = resource.exec.inline.output.FOO
}
```

## Properties

<Properties>
Expand Down Expand Up @@ -82,6 +108,19 @@ be specified.
}
```
</Property>

<Property name="output" type="map[string]string" required="false" value="" readonly>
Map of output variables set by echoing key value pairs to the output file from the execs
script.

```hcl
resource "exec" "inline" {
script = <<-EOF
echo "FOO=BAR" > ${EXEC_OUTPUT}
EOF
}
```
</Property>
</Properties>

---
Expand Down
69 changes: 0 additions & 69 deletions src/pages/docs/resources/exec/local_exec.mdx

This file was deleted.

64 changes: 0 additions & 64 deletions src/pages/docs/resources/exec/remote_exec.mdx

This file was deleted.

0 comments on commit 4e905a7

Please sign in to comment.