Variable

class aws_cdk.aws_codepipeline.Variable(*, variable_name, default_value=None, description=None)

Bases: object

Pipeline-Level variable.

ExampleMetadata:

infused

Example:

# source_action: codepipeline_actions.S3SourceAction
# source_output: codepipeline.Artifact
# deploy_bucket: s3.Bucket


# Pipeline-level variable
variable = codepipeline.Variable(
    variable_name="bucket-var",
    description="description",
    default_value="sample"
)

codepipeline.Pipeline(self, "Pipeline",
    pipeline_type=codepipeline.PipelineType.V2,
    variables=[variable],
    stages=[codepipeline.StageProps(
        stage_name="Source",
        actions=[source_action]
    ), codepipeline.StageProps(
        stage_name="Deploy",
        actions=[
            codepipeline_actions.S3DeployAction(
                action_name="DeployAction",
                # can reference the variables
                object_key=f"{variable.reference()}.txt",
                input=source_output,
                bucket=deploy_bucket
            )
        ]
    )
    ]
)
Parameters:
  • variable_name (str) – The name of a pipeline-level variable.

  • default_value (Optional[str]) – The default value of a pipeline-level variable. Default: - No default value.

  • description (Optional[str]) – The description of a pipeline-level variable. It’s used to add additional context about the variable, and not being used at time when pipeline executes. Default: - No description.

Methods

reference()

Reference the variable name at Pipeline actions.

Return type:

str

Returns:

The variable name in a format that can be referenced at Pipeline actions

Attributes

variable_name

The name of a pipeline-level variable.