【问题标题】:Trying to add a CloudFront invalidation command in buildspec.yml throws 254 error尝试在 buildspec.yml 中添加 CloudFront 失效命令会引发 254 错误
【发布时间】:2022-12-15 15:41:14
【问题描述】:

我试图在构建完成后使 Cloudfront 缓存无效,我得到的是 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

这是我的 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 '/*

你看有什么不对的地方吗??我试过在我正在运行的笔记本电脑上运行创建失效指令并且它有效..

提前致谢

#更新

我已经解决了……这是一个缺少权限的问题……我已经添加了

{
    "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>"
        }
    ]
}

它工作正常。

这个可以关闭

【问题讨论】:

  • 您在哪里添加该权限?
  • 我刚刚尝试过,它通过将它们添加到 CodePipeline 使用的服务角色中来工作;)

标签: amazon-cloudfront aws-codebuild


【解决方案1】:

你能完全分享过程细节吗

【讨论】:

    猜你喜欢
    • 2022-01-09
    • 2018-02-14
    • 2015-05-23
    • 2020-05-03
    • 2020-06-28
    • 1970-01-01
    • 2018-11-26
    • 2015-08-09
    • 2018-06-24
    相关资源
    最近更新 更多