Accessing data - Amazon CodeCatalyst

Accessing data

Using ADK APIs, you can access data that is set on the actions. Here is some of the data you can access.

Environment variables

CodeCatalyst sets environment variables available at the action runtime. An action can be configured with input variables and pre-defined variables that can be accessed by the action. The variables can be accessed for auditing purposes, metrics, access tokens, and other information. The following ADK API can be used to get both input variables and pre-defined variables: code.getEnvironmentVariable('variableName');. For more information, see ADK Core's getEnvironmentVariable details.

Identifier: my_org/my_action Configuration: MyEnvironment: 'MY_PROJECT'
const projectName = core.getEnvironmentVariable('MyEnvironment')

Action inputs

Action inputs are values passed into an action at runtime. These inputs are defined in the action definition file (action.yml) and can be used to specify parameters. You can access and configure the action inputs in order to customize the behavior of the action based on a specific use case. The following ADK API can be used to get the action inputs: core.getInput(`${inputName}`). For more information, see ADK Core's getInput details.

Identifier: my_org/my_action Configuration: MyInput: 'MY_ACTION_INPUT'
const actionInput = core.getInput('MyInput')

Secrets

Sensitive data like authentication credentials and other values can be stored and protected in secrets with CodeCatalyst. You can then reference the secrets in your workflow definition file. For more information, see Working with secrets.

In the following workflow, the value of the core.getInput(`${StackName}`) secret is assigned to the StackName action input at runtime. For more information, see ADK Core's getInput details.

Actions: ACTIONNAME: Identifier: aws/cdk-deploy@v2 Environment: Name: codecatalyst-cdk-deploy-environment Connections: - Name: codecatalyst-account-connection Role: codecatalyst-cdk-deploy-role Inputs: Sources: - WorkflowSource Configuration: StackName: ${Secrets.MY_SECRET_STACK_NAME} Region: ${Secrets.MY_REGION}
const stackName = core.getInput('StackName')
const region = core.getInput('Region')

Application URLs

Your workflow that deploys an application can display a URL in the workflow diagram. The clickable URL in the CodeCatalyst console can help to quickly verify your application. For more information, see Surfacing the URL of the deployed application.

You can also configure action source code with an output variable to get a URL link for your application. In the following code, the URL is first defined so the variable holds the URL you want to set as the output value. The output variable is named AppUrl in code.setOutput('AppUrl, url); with the value of the url variable. The output variable can then be accessed in a workflow. For more information, see Working with variables.

const url = "https://mycompany.myapp.com";
core.setOutput('AppUrl', url);