

Amazon CodeCatalyst is no longer open to new customers. Existing customers can continue to use the service as normal. For more information, see [How to migrate from CodeCatalyst](migration.md).

# Referencing a variable in the action that defines it
<a name="workflows-working-with-variables-reference-input"></a>

Use the following instructions to reference a variable in the action that defines it.

**Note**  
To reference a variable generated by a GitHub Action, see [Referencing GitHub output parameters](integrations-github-action-referencing.md).

For more information about variables, see [Using variables in workflows](workflows-working-with-variables.md).

**Prerequisite**  
Make sure you have defined the variable you want to reference. For more information, see [Defining a variable](workflows-working-with-variables-define-input.md).

------
#### [ Visual ]

*Not available. Choose YAML to view the YAML instructions.*

------
#### [ YAML ]

**To reference a variable in the action that defines it**

1. Open the CodeCatalyst console at [https://codecatalyst.aws/](https://codecatalyst.aws/).

1. Choose your project.

1. In the navigation pane, choose **CI/CD**, and then choose **Workflows**.

1. Choose the name of your workflow. You can filter by the source repository or branch name where the workflow is defined, or filter by workflow name or status.

1. Choose **Edit**.

1. Choose **YAML**.

1. In the CodeCatalyst action that defines the variable that you want to refer to, add the variable using the following bash syntax:

   ```
   $variable-name
   ```

   For example:

   ```
   MyAction:
       Configuration:
         Steps:
           - Run: $variable-name
   ```

   For more examples, see [Examples of variables](workflows-working-with-variables-ex.md). For more information, see the reference information for your action in the [Workflow YAML definition](workflow-reference.md).

1. (Optional) Choose **Validate** to validate the workflow's YAML code before committing.

1. Choose **Commit**, enter a commit message, and choose **Commit** again.

------