简体   繁体   中英

Newbie question regarding JS and Listing Distributions

In this case I am not sure from where to even start properly, but the task is to use javascript to list the distributions. I was thinking that the script should start with var AWS = require("aws-sdk"); which should get the aws-sdk and from it use the values that I need which is to match X domain and get the DistributionID for that domain but still not sure. Below is a code of what I am executing in bash which provides me with the exact info that I have, but I need to somehow convert the call in javascript.

aws cloudfront list-distributions --profile=my profile name --query "DistributionList.Items[?Aliases.Items!=null] | [?contains(Aliases.Items, 'Specific-Domain.com')].Id" > Id-Output.txt

The output of the code above is the required Id which afterwards can be used for a lot of things including invalidation, but as for converting it to a JavaScript I am little over my head, so please be gentle and thanks for stopping by (or providing me with any suggestion or info).

In the CLI you are using the list-distributions method of the cloudfront service. Similarly, you would use the listDistributions method of the AWS.CloudFront client in the AWS SDK for JavaScript to perform the same task, as documented here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM