-
I'm thoroughly confused by the contract for the Update-CFDistribution cmdlet. There are number of people also confused by it on stack overflow. Examples: https://stackoverflow.com/questions/46732124/aws-powershell-update-cloudfront-distribution The impression I get from error messages is you have to map the response to particular parameters in order to get the update to run, though the list of parameters is not clear. Additionally it's completely surprising from a powershell perspective to have to do this. In general what you'd expect is:
to just work. Instead though if you try doing that with Cloud Front cmdlets you get issues like the following:
I don't know how it is interpreting that property as null - it clearly exists, unless something is kicking in case sensitive:
Is there a clear example of what actual values work for this commandlet? FWIW the version of the cmdlets and powershell I'm using is:
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
I managed to get code like this to run - is this actually what is expected of those calling these cmdlets? Edit: The answer seems to be yes if #214 is to be believed that this plagues other such cmdlets. Accepting my own answer.
|
Beta Was this translation helpful? Give feedback.
-
In the docs I found the list of required parameters, which does look like it requires ~12 parameters |
Beta Was this translation helpful? Give feedback.
-
There is also the (somewhat ugly, but less verbose option of using the .NET SDK (which is imported by default with AWS Powershell)): $awsCreds = Get-AWSCredential
$client = New-Object Amazon.CloudFront.AmazonCloudFrontClient( $awsCreds )
$response = $client.GetDistributionConfig( [Amazon.CloudFront.Model.GetDistributionConfigRequest]$DistributionId )
$eTag = $response.ETag
$distConfig = $response.DistributionConfig
### Make appropriate changes to $distConfig
$request = [Amazon.CloudFront.Model.UpdateDistributionRequest]@{
DistributionConfig = $distConfig
Id = $DistributionId
IfMatch = $eTag
}
$response = $client.UpdateDistribution( $request ) |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
I managed to get code like this to run - is this actually what is expected of those calling these cmdlets?
Edit: The answer seems to be yes if #214 is to be believed that this plagues other such cmdlets. Accepting my own answer.