Home Reference Source Test
public class | source

Uploader

Constructor Summary

Public Constructor
public

Uploads artifacts to a remote S3 bucket defined inside an array of file globs, of locations inside pipeline input artifacts.

Member Summary

Public Members
public

An array of Artifact objects which have been made available to the CodePipeline action definition.

public

The data object as received from AWS CodePipeline.

public

The parsed contents of the UserParameters string as defined inside the action in the CodePipeline resource.

Method Summary

Public Methods
public

async destinations(): Array[Destination]

Maps all defined src/dest combinations (from Uploader#userParameters) to destination objects ready for upload.

public

async perform(): Boolean

Performs the intended operation and uploads source files from pipeine artifacts to remote S3 locations by assuming the provided roles to provide the correct permission sets.

public

Retrieve validated (and defaulted) parameters which have been defined inside the action in the CodePipeline resource.

Public Constructors

public constructor(data: Object) source

Uploads artifacts to a remote S3 bucket defined inside an array of file globs, of locations inside pipeline input artifacts.

Params:

NameTypeAttributeDescription
data Object

A CodePipeline data event object.

Example:

```
 {
    "CodePipeline.job": {
        "id": "11111111-abcd-1111-abcd-111111abcdef",
        "accountId": "111111111111",
        "data": {
            "actionConfiguration": {
                "configuration": {
                    "FunctionName": "MyLambdaFunctionForAWSCodePipeline",
                    "UserParameters": "...."
                }
            },
            "inputArtifacts": [
                {
                    "location": {
                        "s3Location": {
                            "bucketName": "codepipeline-us-east-2-1234567890",
                            "objectKey": "rj90jda90ja90j09tj09jaf.zip"
                        },
                        "type": "S3"
                    },
                    "revision": null,
                    "name": "ArtifactName"
                }
            ],
            "outputArtifacts": [],
            "artifactCredentials": {
                "secretAccessKey": "....",
                "sessionToken": "....",
                "accessKeyId": "...."
            },
            "continuationToken": "A continuation token if continuing job"
        }
    }
 }
```

Public Members

public artifacts: String source

An array of Artifact objects which have been made available to the CodePipeline action definition.

public data: Object source

The data object as received from AWS CodePipeline.

public parameters: Object source

The parsed contents of the UserParameters string as defined inside the action in the CodePipeline resource. This should be a valid array of objects, similar to the example below:

[
{
  "roleArn": {
    "Fn::GetParam": ["DeployOutput", "Outputs.json", "AssetS3BucketTransferRole"]
  },
  "bucket": {
    "Fn::GetParam": ["DeployOutput", "Outputs.json", "AssetS3Bucket"]
  },
  "prefix": "s3/key/prefix/",
  "src": [
    "BuildOutput::*.js"
  ]
}
]

Public Methods

public async destinations(): Array[Destination] source

Maps all defined src/dest combinations (from Uploader#userParameters) to destination objects ready for upload.

Return:

Array[Destination]

an array of Destination objects

public async perform(): Boolean source

Performs the intended operation and uploads source files from pipeine artifacts to remote S3 locations by assuming the provided roles to provide the correct permission sets.

The promise resolves successfully after all source files have been uploaded.

Return:

Boolean

true if successful, throws otherwise.

public async userParameters(): Object source

Retrieve validated (and defaulted) parameters which have been defined inside the action in the CodePipeline resource.

Return:

Object

valid parameters to be used to construct the state machine input.