尝试在buildspec.c.yml中添加云五的无效命令254错误
我试图在构建完成后试图使CloudFront Cache无效,而我得到的是CodeBuild中的以下错误:[Container] 2022/05/16 15:46:11阶段上下文上下文状态代码:command_execution_error消息:错误:错误:错误:错误:执行命令时:AWS CloudFront创建侵入 - distribution-id myid-Paths'/*'。原因:退出状态254
这是我的buildspec定义,
version: 0.2
env:
variables:
APP_NAME: "managerui"
phases:
install:
runtime-versions:
nodejs: 14.x
commands:
- echo install process started
- cd src/UI/managerui/
- ls
- npm install && npm install -g @angular/cli
build:
commands:
- echo build process started now
- ls
- ng build --configuration=production
post_build:
commands:
- echo build process finished, we should uplload to S3 now
- ls
- cd dist/
- ls -la
- aws s3 sync . s3://ett-manager-ui --delete
- aws cloudfront create-invalidation --distribution-id=myid--paths '/*
您看到了任何问题吗?我已经尝试在运行笔记本电脑上运行创建进程指令,并且可以正常工作。.
谢谢
#update
我已经解决了...这是一个缺失的许可问题...我已经添加了
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor1",
"Effect": "Allow",
"Action": [
"cloudfront:UpdateDistribution",
"cloudfront:DeleteDistribution",
"cloudfront:CreateInvalidation"
],
"Resource": "arn:aws:cloudfront::<account_id>:distribution/<distribution_id>"
}
]
}
,而且效果很好。
这可以关闭
I'm trying to invalidate the Cloudfront cache after a build has done and what I get is the following error in Codebuild : [Container] 2022/05/16 15:46:11 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: aws cloudfront create-invalidation --distribution-id myid --paths '/*'. Reason: exit status 254
Here's my BuildSpec definition
version: 0.2
env:
variables:
APP_NAME: "managerui"
phases:
install:
runtime-versions:
nodejs: 14.x
commands:
- echo install process started
- cd src/UI/managerui/
- ls
- npm install && npm install -g @angular/cli
build:
commands:
- echo build process started now
- ls
- ng build --configuration=production
post_build:
commands:
- echo build process finished, we should uplload to S3 now
- ls
- cd dist/
- ls -la
- aws s3 sync . s3://ett-manager-ui --delete
- aws cloudfront create-invalidation --distribution-id=myid--paths '/*
Do you see anything that's wrong?? I've tried running the create-invalidation instruction on my running laptop and it works..
Thanks in advance
#UPDATE
I've resolved... it was a missing permission issue... I've added
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor1",
"Effect": "Allow",
"Action": [
"cloudfront:UpdateDistribution",
"cloudfront:DeleteDistribution",
"cloudfront:CreateInvalidation"
],
"Resource": "arn:aws:cloudfront::<account_id>:distribution/<distribution_id>"
}
]
}
and it works fine.
This can be closed
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论