# Artifact

An output artifact of an action.

Artifacts can be used as input by some actions.

- Source: [`aws-codepipeline/lib/artifact.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-codepipeline/lib/artifact.ts#L11)
- Type last changed: v2.179.0 · 18 Feb 2025

## Example

```ts
declare const pipeline: codepipeline.Pipeline;

const sourceOutput = new codepipeline.Artifact();
const sourceAction = new codepipeline_actions.CodeStarConnectionsSourceAction({
  actionName: 'CodeStarConnectionsSourceAction',
  output: sourceOutput,
  connectionArn: 'your-connection-arn',
  owner: 'your-owner',
  repo: 'your-repo',
});

const scanOutput = new codepipeline.Artifact();
const scanAction = new codepipeline_actions.InspectorSourceCodeScanAction({
  actionName: 'InspectorSourceCodeScanAction',
  input: sourceOutput,
  output: scanOutput,
});

pipeline.addStage({
  stageName: 'Source',
  actions: [sourceAction],
});
pipeline.addStage({
  stageName: 'Scan',
  actions: [scanAction],
});
```

## Initializer

```ts
new Artifact(artifactName?: string, artifactFiles?: string[])
```

## Properties

- `artifactFiles`: string[] — The file paths that you want to export as the output artifact for the action.

  This property can only be used in artifacts for `CommandsAction`.

- `artifactName`: string

- `bucketName`: string — The artifact attribute for the name of the S3 bucket where the artifact is stored.

- `objectKey`: 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`: [Location](/cdk/api/v2/docs/aws-cdk-lib.aws_s3.Location.html) — 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`: 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.

## Methods

- `artifact(name: string, files?: string[]): Artifact // chainable` (static) — A static factory method used to create instances of the Artifact class.

  Mainly meant to be used from `decdk`.

  **Parameters**

  - `name` — the (required) name of the Artifact.
  - `files` — file paths that you want to export as the output artifact for the action.

- `atPath(fileName: string): ArtifactPath` — Returns an ArtifactPath for a file within this artifact.

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

  **Parameters**

  - `fileName` — The name of the file.

- `getMetadata(key: string): 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: string, keyName: string): string` — Returns a token for a value inside a JSON file within this artifact.

  **Parameters**

  - `jsonFile` — The JSON file name.
  - `keyName` — The hash key.

- `setMetadata(key: string, value: any): void` — 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(): string`
