使用AWS Code Builder将元数据标签添加到S3存储桶中的对象中

问题描述 投票:1回答:1

我有一个简单的Angular SPA项目,该项目从AWS S3存储桶中托管。

  • 存储桶中的对象需要一些元数据标签(内容类型,缓存控件等),以确保内容正确加载并经常更新。

  • [我正在使用AWS代码构建,使用下面的buildspec.yml文件将项目部署到S3存储桶:

version: 0.2

phases:
  pre_build:
    commands:
      - echo Starting Build Now
      - npm install
  build:
    commands:
      - echo Build ready for manufacturing of the artifact
      - npm build
  post_build:
    commands:
      - aws s3 sync $BUILD_OUTPUT_LOCATION s3://$BUCKET_NAME --delete
      - echo Build completed successfully

在此buildspec.yml文件的后期构建中,是否有命令将必要的元数据标签添加到要同步的文件中的S3存储桶中?

amazon-web-services amazon-s3 aws-codepipeline aws-codebuild
1个回答
0
投票

使用参数直接从aws cli添加元标记,类似:

$ aws s3 cp s3://bucketname/ s3://bucketname/ --recursive --metadata-directive REPLACE --cache-control max-age=86400

-或-

$ aws s3 sync $BUILD_OUTPUT_LOCATION s3://$BUCKET_NAME --delete  --cache-control max-age=86400
© www.soinside.com 2019 - 2024. All rights reserved.