尝试在buildspec.c.yml中添加云五的无效命令254错误

发布于 2025-01-29 12:01:17 字数 1525 浏览 3 评论 0原文

我试图在构建完成后试图使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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文