aws-cdk-lib.aws_codepipeline.Artifact

class Artifact

LanguageType name
.NETAmazon.CDK.AWS.CodePipeline.Artifact
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awscodepipeline#Artifact
Javasoftware.amazon.awscdk.services.codepipeline.Artifact
Pythonaws_cdk.aws_codepipeline.Artifact
TypeScript (source)aws-cdk-lib » aws_codepipeline » Artifact

An output artifact of an action.

Artifacts can be used as input by some actions.

Example

const lambdaInvokeAction = new codepipeline_actions.LambdaInvokeAction({
  actionName: 'Lambda',
  lambda: new lambda.Function(this, 'Func', {
    runtime: lambda.Runtime.NODEJS_14_X,
    handler: 'index.handler',
    code: lambda.Code.fromInline(`
        const AWS = require('aws-sdk');

        exports.handler = async function(event, context) {
            const codepipeline = new AWS.CodePipeline();
            await codepipeline.putJobSuccessResult({
                jobId: event['CodePipeline.job'].id,
                outputVariables: {
                    MY_VAR: "some value",
                },
            }).promise();
        }
    `),
  }),
  variablesNamespace: 'MyNamespace', // optional - by default, a name will be generated for you
});

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

Initializer

new Artifact(artifactName?: string)

Parameters

  • artifactName string

Properties

NameTypeDescription
bucketNamestringThe artifact attribute for the name of the S3 bucket where the artifact is stored.
objectKeystringThe artifact attribute for The name of the .zip file that contains the artifact that is generated by AWS CodePipeline, such as 1ABCyZZ.zip.
s3LocationLocationReturns the location of the .zip file in S3 that this Artifact represents. Used by Lambda's CfnParametersCode when being deployed in a CodePipeline.
urlstringThe artifact attribute of the Amazon Simple Storage Service (Amazon S3) URL of the artifact, such as https://s3-us-west-2.amazonaws.com/artifactstorebucket-yivczw8jma0c/test/TemplateSo/1ABCyZZ.zip.
artifactName?string

bucketName

Type: string

The artifact attribute for the name of the S3 bucket where the artifact is stored.


objectKey

Type: string

The artifact attribute for The name of the .zip file that contains the artifact that is generated by AWS CodePipeline, such as 1ABCyZZ.zip.


s3Location

Type: Location

Returns the location of the .zip file in S3 that this Artifact represents. Used by Lambda's CfnParametersCode when being deployed in a CodePipeline.


url

Type: string

The artifact attribute of the Amazon Simple Storage Service (Amazon S3) URL of the artifact, such as https://s3-us-west-2.amazonaws.com/artifactstorebucket-yivczw8jma0c/test/TemplateSo/1ABCyZZ.zip.


artifactName?

Type: string (optional)

Methods

NameDescription
atPath(fileName)Returns an ArtifactPath for a file within this artifact.
getMetadata(key)Retrieve the metadata stored in this artifact under the given key.
getParam(jsonFile, keyName)Returns a token for a value inside a JSON file within this artifact.
setMetadata(key, value)Add arbitrary extra payload to the artifact under a given key.
toString()
static artifact(name)A static factory method used to create instances of the Artifact class.

atPath(fileName)

public atPath(fileName: string): ArtifactPath

Parameters

  • fileName string — The name of the file.

Returns

  • ArtifactPath

Returns an ArtifactPath for a file within this artifact.

CfnOutput is in the form "<artifact-name>::<file-name>"


getMetadata(key)

public getMetadata(key: string): any

Parameters

  • key string

Returns

  • any

Retrieve the metadata stored in this artifact under the given key.

If there is no metadata stored under the given key, null will be returned.


getParam(jsonFile, keyName)

public getParam(jsonFile: string, keyName: string): string

Parameters

  • jsonFile string — The JSON file name.
  • keyName string — The hash key.

Returns

  • string

Returns a token for a value inside a JSON file within this artifact.


setMetadata(key, value)

public setMetadata(key: string, value: any): void

Parameters

  • key string
  • value any

Add arbitrary extra payload to the artifact under a given key.

This can be used by CodePipeline actions to communicate data between themselves. If metadata was already present under the given key, it will be overwritten with the new value.


toString()

public toString(): string

Returns

  • string

static artifact(name)

public static artifact(name: string): Artifact

Parameters

  • name string — the (required) name of the Artifact.

Returns

  • Artifact

A static factory method used to create instances of the Artifact class.

Mainly meant to be used from decdk.