Clear CloudFront Cache with AWS CLI | bobbyhadz
zx 의 $ 는 ${} 로 넣은 값을 알아서 quote 한다 — 따옴표를 직접 넣으면(`"/*"`) 따옴표까지 경로가 된다.1
/**
* CloudFront 배포에 대한 캐시를 무효화하려면 경로와 함께 명령을 실행합니다
*
* @param {object} params
* @param {string} params.distributionId
* @param {string} params.paths
* @returns {CreateInvalidationResult}
*/
function createInvalidation({
distributionId,
paths = '/*'
}) {
const result = $`aws cloudfront create-invalidation --distribution-id ${distributionId} --paths ${paths}`
return result
}
Footnotes
-
Getting Started | google/zx: “Everything passed through
${...}will be automatically escaped and quoted.” ↩