AWS Tools for Windows PowerShell
Command Reference

AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Synopsis

Creates signed cookies that grants universal access to private content until a given date (using a canned policy) or tailored access to private content based on an access time window and ip range.

Syntax

CannedPolicy (Default)

New-CFSignedCookie
-ResourceUri <Uri>
-KeyPairId <String>
-PrivateKeyFile <String>
-ExpiresOn <DateTime>

CustomPolicy

New-CFSignedCookie
-ResourceUri <Uri>
-KeyPairId <String>
-PrivateKeyFile <String>
-ExpiresOn <DateTime>
-ActiveFrom <DateTime>
-IpRange <String>

Description

Creates signed cookies that grants universal access to private content until a given date (using a canned policy) or tailored access to private content based on an access time window and ip range.

Parameters

-ActiveFrom <DateTime>
The date from which content can be accessed using the generated cookies.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-ExpiresOn <DateTime>
The expiration date till which content can be accessed using the generated cookies.
Required?True
Position?Named
Accept pipeline input?True (ByPropertyName)
-IpRange <String>
The allowed IP address range of the client making the GET request, in CIDR form (e.g. 192.168.0.1/24). If not specified, a CIDR of 0.0.0.0/0 (i.e. no IP restriction) is used.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-KeyPairId <String>
The key pair id corresponding to the private key file given.
Required?True
Position?Named
Accept pipeline input?True (ByPropertyName)
-PrivateKeyFile <String>
The private key file. RSA private key (.pem) are supported.
Required?True
Position?Named
Accept pipeline input?True (ByPropertyName)
-ResourceUri <Uri>
The URL or path that uniquely identifies a resource within a distribution. For standard distributions the resource URL will be "http://" + distributionName + "/" + path (may also include URL parameters. For distributions with the HTTPS required protocol, the resource URL must start with "https://". RTMP resources do not take the form of a URL, and instead the resource path is nothing but the stream's name.
Required?True
Position?Named
Accept pipeline input?True (ByPropertyName)

Outputs

This cmdlet returns an Amazon.CloudFront.CookiesForCannedPolicy object containing signed cookies to a resource using a canned policy.
This cmdlet returns an Amazon.CloudFront.CookiesForCustomPolicy object containing signed cookies to a resource using a custom policy.

Examples

Example 1

$params = @{
"ResourceUri"="http://xyz.cloudfront.net/image1.jpeg"
"KeyPairId"="AKIAIOSFODNN7EXAMPLE"
"PrivateKeyFile"="C:\pk-AKIAIOSFODNN7EXAMPLE.pem"
"ExpiresOn"=(Get-Date).AddYears(1)
}
New-CFSignedCookie @params

Expires
-------
[CloudFront-Expires, 1472227284]
Creates a signed cookie to the specified resource using a canned policy. The cookie will be valid for one year.

Example 2

$start = (Get-Date).AddHours(24)
$params = @{
"ResourceUri"="http://xyz.cloudfront.net/content/*.jpeg"
"KeyPairId"="AKIAIOSFODNN7EXAMPLE"
"PrivateKeyFile"="C:\pk-AKIAIOSFODNN7EXAMPLE.pem"
"ExpiresOn"=$start.AddDays(7)
"ActiveFrom"=$start
}

New-CFSignedCookie @params

Policy
------
[CloudFront-Policy, eyJTd...wIjo...
Creates a signed cookie to the specified resources using a custom policy. The cookie will be valid in 24 hours and will expire one week afterward.

Example 3

$start = (Get-Date).AddHours(24)
$params = @{
"ResourceUri"="http://xyz.cloudfront.net/content/*.jpeg"
"KeyPairId"="AKIAIOSFODNN7EXAMPLE"
"PrivateKeyFile"="C:\pk-AKIAIOSFODNN7EXAMPLE.pem"
"ExpiresOn"=$start.AddDays(7)
"ActiveFrom"=$start
"IpRange"="192.0.2.0/24"
}

New-CFSignedCookie @params

Policy ------ [CloudFront-Policy, eyJTd...wIjo...
Creates a signed cookie to the specified resources using a custom policy. The cookie will be valid in 24 hours and will expire one week afterward. Access to the resources is restricted to the specified ip range.

Supported Version

AWS Tools for PowerShell: 2.x.y.z