aws-cdk-lib.aws_codebuild.BuildEnvironmentVariable

interface BuildEnvironmentVariable

LanguageType name
.NETAmazon.CDK.AWS.CodeBuild.BuildEnvironmentVariable
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awscodebuild#BuildEnvironmentVariable
Javasoftware.amazon.awscdk.services.codebuild.BuildEnvironmentVariable
Pythonaws_cdk.aws_codebuild.BuildEnvironmentVariable
TypeScript (source)aws-cdk-lib » aws_codebuild » BuildEnvironmentVariable

Example

const sourceOutput = new codepipeline.Artifact();
const buildAction = new codepipeline_actions.CodeBuildAction({
  actionName: 'Build1',
  input: sourceOutput,
  project: new codebuild.PipelineProject(this, 'Project', {
    buildSpec: codebuild.BuildSpec.fromObject({
      version: '0.2',
      env: {
        'exported-variables': [
          'MY_VAR',
        ],
      },
      phases: {
        build: {
          commands: 'export MY_VAR="some value"',
        },
      },
    }),
  }),
  variablesNamespace: 'MyNamespace', // optional - by default, a name will be generated for you
});

// later:
declare const project: codebuild.PipelineProject;
new codepipeline_actions.CodeBuildAction({
  actionName: 'CodeBuild',
  project,
  input: sourceOutput,
  environmentVariables: {
    MyVar: {
      value: buildAction.variable('MY_VAR'),
    },
  },
});

Properties

NameTypeDescription
valueanyThe value of the environment variable.
type?BuildEnvironmentVariableTypeThe type of environment variable.

value

Type: any

The value of the environment variable.

For plain-text variables (the default), this is the literal value of variable. For SSM parameter variables, pass the name of the parameter here (parameterName property of IParameter). For SecretsManager variables secrets, pass either the secret name (secretName property of ISecret) or the secret ARN (secretArn property of ISecret) here, along with optional SecretsManager qualifiers separated by ':', like the JSON key, or the version or stage (see https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html#build-spec.env.secrets-manager for details).


type?

Type: BuildEnvironmentVariableType (optional, default: PlainText)

The type of environment variable.