简体   繁体   English

关于 JS 和列表分布的新手问题

[英]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.在这种情况下,我不确定从哪里开始正确,但任务是使用 javascript 列出分布。 I was thinking that the script should start with var AWS = require("aws-sdk");我在想脚本应该以var AWS = require("aws-sdk");开头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.它应该获取 aws-sdk 并从中使用我需要的值来匹配 X 域并获取该域的 DistributionID 但仍然不确定。 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.下面是我在 bash 中执行的代码,它为我提供了我所拥有的确切信息,但我需要以某种方式转换 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).上面代码的输出是所需的 Id,之后可以用于很多事情,包括失效,但至于将其转换为 JavaScript,我有点不知所措,所以请保持温和,感谢您的光临(或提供)我有任何建议或信息)。

In the CLI you are using the list-distributions method of the cloudfront service.在 CLI 中,您使用的是cloudfront服务的list-distributions方法。 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 .同样,您将使用适用于 JavaScript 的 AWS 开发工具包中AWS.CloudFront客户端的listDistributions方法来执行相同的任务,如此处所述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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