iainbrighton / cRemoteFile

Communuity Powershell DSC resource to download files over HTTP/HTTPS or AWS S3 files with a checksum
MIT License
6 stars 3 forks source link

Included DSC Resources

These custom Desired State Configuration (DSC) resources utilise .NET stream objects and overcome the OutOfMemoryException errors incurred by the in-built Invoke-WebRequest or Read-S3Object Powershell cmdlets.

cRemoteFile

By default, the MSFT_xRemoteFile will not check that a file has already been download during the Test-TargetResource pass. The cRemoteFile resource will only download a file if it's not present or the MD5 checksum is different/incorrect.

Syntax

cRemoteFile [string]
{
    DestinationPath = [string]
    Uri = [string]
    [Checksum = [string]]
    [Credential = [PSCredential]]
}

Properties

Configuration

Configuration cRemoteFileExample {
    Import-DscResource -ModuleName cRemoteFile
    cRemoteFile MyExampleFile {
        DestinationPath = 'C:\Resources\output.txt'
        Uri = 'http://uri_to_download_from.com/example.txt'
        Checksum = '4767B1052744A0469348BAF3406DA944'
    }
}

cS3RemoteFile

The cS3RemoteFile resource can download a private Amazon Web Services file from S3 - complete with a MD5 checksum. This resource is handy for files/resources that cannot be made publically available due to electronic distribution rights restrictions. This DSC resource requires the AWS Powershell Tools to already be installed on the system executing this resource (obviously the cRemoteFile resource could be used to download the file for installation).

Syntax

cS3RemoteFile [string]
{
    DestinationPath = [string]
    Region = [string]
    BucketName = [string]
    Key = [string]
    Credential = [PSCredential]
    [Checksum = [string]]
}

Properties

Configuration

Configuration cS3RemoteFileExample {
    Import-DscResource -ModuleName cRemoteFile
    cS3RemoteFile MyExampleS3File {
        DestinationPath = 'C:\Resources\output.txt'
        Region = 'eu-central-1'
        BucketName = 'MyAwsS3Bucket'
        Key = 'example.txt'
        Credential = (Get-Credential -Credential 'MyAwsAccessKey')
        Checksum = '4767B1052744A0469348BAF3406DA944'
    }
}

Note: to download publically accessible AWS S3 files use the cRemoteFile resource instead.