bitbucketから、pipeline経由でAWS s3にアップロードする

bitbucketから、pipeline経由でAWS s3にアップロードする:

bitbucketで差分管理しているリソースを、AWS s3にpipeline経由でアップロードする。

(静的htmlのみ使用するアクセスが少ないwebサイトをs3のhosting機能で運営することにした。)

リポジトリの設定からEnable Pipelinesをonにして、bitbucket-pipelines.ymlを設置する。



image.png


今回は、masterへのcommitのみ、s3にアップロードする。

qiita.rb
# This is a sample build configuration for Other. 
# Check our guides at https://confluence.atlassian.com/x/5Q4SMw for more examples. 
# Only use spaces to indent your .yml configuration. 
# ----- 
# You can specify a custom docker image from Docker Hub as your build environment. 
image: atlassian/default-image:2 
 
pipelines: 
  default: 
    - step: 
        # set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY as environment variables 
        name: Deploy to S3 
        deployment: test   # set to test, staging or production 
        # trigger: manual  # uncomment to have a manual step 
        image: atlassian/pipelines-awscli 
        script: 
          - aws s3 sync --delete . s3://<bucket_name> 
AWS側に、s3にアクセスできるユーザを作成する。

今回は、ユーザ、bitbucketを作成して、s3accessにフルでアクセスできるグループに所属させた


image.png


アクセスキーを、リポジトリの設定→Repository variablesに設定する

AWS_ACCESS_KEY_ID アクセスキーID

AWS_DEFAULT_REGION デフォルトリージョン

AWS_SECRET_ACCESS_KEY 対応するキー



image.png


アップロードに成功



image.png


アクセスキーなどを設定しないと、unable to locate credentials



image.png


コメント

このブログの人気の投稿

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2020-12-01 09:41:49 RSSフィード2020-12-01 09:00 分まとめ(69件)