SlideShare a Scribd company logo
1 of 72
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS 公式 Webinar
https://amzn.to/JPWebinar
過去資料
https://amzn.to/JPArchive
Solutions Architect 松本 雅博
2020/11/25
AWS CodeBuild
サービスカットシリーズ
[AWS Black Belt Online Seminar]
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
自己紹介
松本 雅博(まつもと まさひろ)
技術統括本部 西日本ソリューション部
ソリューションアーキテクト
関西を中心に、西日本のお客様をご支援
好きなサービス
• Code シリーズ
• AWS CloudFormation, AWS Cloud Development Kit
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS Black Belt Online Seminar とは
「サービス別」「ソリューション別」「業種別」のそれぞれのテーマに分かれて、アマゾ
ン ウェブ サービス ジャパン株式会社が主催するオンラインセミナーシリーズです。
質問を投げることができます!
• 書き込んだ質問は、主催者にしか見えません
• 今後のロードマップに関するご質問は
お答えできませんのでご了承下さい
① 吹き出しをクリック
② 質問を入力
③ Sendをクリック
Twitter ハッシュタグは以下をご利用ください
#awsblackbelt
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
内容についての注意点
• 本資料では2020年11月25日現在のサービス内容および価格についてご説明しています。最新の
情報はAWS公式ウェブサイト(http://aws.amazon.com)にてご確認ください。
• 資料作成には十分注意しておりますが、資料内の価格とAWS公式ウェブサイト記載の価格に相
違があった場合、AWS公式ウェブサイトの価格を優先とさせていただきます。
• 価格は税抜表記となっています。日本居住者のお客様には別途消費税をご請求させていただきま
す。
• AWS does not offer binding price quotes. AWS pricing is publicly available and is
subject to change in accordance with the AWS Customer Agreement available at
http://aws.amazon.com/agreement/. Any pricing information included in this
document is provided only as an estimate of usage charges for AWS services based on
certain information that you have provided. Monthly charges will be based on your
actual use of AWS services, and may vary from the estimates provided.
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
本セミナーの概要
• 本セミナーで学習できること
• AWS CodeBuild
• 対象者
• アーキテクトの方
• 技術者の方
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
本日のアジェンダ
• AWS CodeBuild 概要
• buildspec.yml について
• 機能紹介
• まとめ
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
ソフトウェア開発に関連する AWS サービス
AWS CodeBuild
+ Third Party
AWS
CodeCommit
AWS
CodeBuild
AWS
CodeDeploy
AWS
X-Ray
AWS CodePipeline
MONITORDEPLOYTESTBUILD
SOURCE /
ARTIFACT
AUTHOR
AWS Cloud9
AWS IDE Toolkits
Amazon
CloudWatch
AWS CloudFormation AWS SAMAWS Cloud Development KitMODEL
Amazon CodeGuru
AWS
CodeArtifact
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
ソフトウェア開発に関連する AWS サービス
AWS CodeBuild
+ Third Party
AWS
CodeCommit
AWS
CodeBuild
AWS
CodeDeploy
AWS
X-Ray
AWS CodePipeline
MONITORDEPLOYTESTBUILD
SOURCE /
ARTIFACT
AUTHOR
AWS Cloud9
AWS IDE Toolkits
Amazon
CloudWatch
AWS CloudFormation AWS SAMAWS Cloud Development KitMODEL
Amazon CodeGuru
AWS
CodeArtifact
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS CodeBuild
 フルマネージドなビルドサービスでソースコードの
コンパイル、テスト実行、ソフトウェア
パッケージの作成を実行
 継続的なスケールと同時複数ビルドプロセス
 サーバーの管理は不要
 利用した分のみの支払い(分単位の課金)
 Amazon CloudWatch によるモニタリング可能
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS CodeBuild
 一貫したイミュータブルな環境のために個々の
ビルドを新規 Docker コンテナで実行
 すべてのオフィシャルな AWS CodeBuild イメージ
に Docker と AWS CLI をインストール済み
 ニーズに応じて Docker イメージを作成することに
よってカスタムなビルド環境を提供可能
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS CodeBuild の実行方法
AWS Command
Line Interface
AWS Tools
and SDKs
AWS CodePipeline
AWS CodeBuild
AWS Management
Console
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS CodeBuild の仕組み
AWS Command
Line Interface
AWS Tools
and SDKs
AWS CodePipeline
AWS CodeBuild
AWS Management
Console
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS CodeBuild の仕組み
AWS Command
Line Interface
AWS Tools
and SDKs
AWS CodePipeline
AWS CodeBuild
AWS Management
Console
Amazon Simple
Storage Service (S3)
ソースコード
ビルドプロジェクト
ビルド環境
作成
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS CodeBuild の仕組み
AWS Command
Line Interface
AWS Tools
and SDKs
AWS CodePipeline
AWS CodeBuild
AWS Management
Console
Amazon Simple
Storage Service (S3)
ソースコード
ビルドプロジェクト
ビルド環境
Amazon CloudWatch
Amazon CloudWatch Logs
取得
メトリクス /
ログ送信
メトリクス /
ログ取得
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS CodeBuild の仕組み
AWS Command
Line Interface
AWS Tools
and SDKs
AWS CodePipeline
AWS CodeBuild
AWS Management
Console
Amazon Simple
Storage Service (S3)
ビルドプロジェクト
ビルド環境
アップロード
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS CodeBuild の仕組み
AWS Command
Line Interface
AWS Tools
and SDKs
AWS CodePipeline
AWS CodeBuild
AWS Management
Console
ビルドプロジェクト
ビルド環境
AWS ChatbotAmazon Simple
Notification Service
通知
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS CodeBuild プロジェクトの作成
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS CodeBuild プロジェクトの作成
プロジェクト名を入力
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS CodeBuild プロジェクトの作成
ソースとして Amazon S3 を選択し、
バケット名と オブジェクトキーを入力
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS CodeBuild プロジェクトの作成
オペレーティングシステムに Amazon Linux 2 を選択し、
ランタイムとイメージを指定する
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS CodeBuild プロジェクトの作成
ビルド仕様は buildspec ファイルを使用するを選択
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS CodeBuild プロジェクトの作成
アーティファクトのタイプに Amazon S3 を選択し、
バケット名を入力する
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS CodeBuild プロジェクトの作成
CloudWatch Logs へログを送信する
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
ソースの作成
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
ソースの作成
buildspec のバージョン
ランタイムに Java を指定
jar ファイルを作成
ビルド出力を定義
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
ビルドの実行
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
ビルドの実行
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
本日のアジェンダ
• AWS CodeBuild 概要
• buildspec.yml について
• 機能紹介
• まとめ
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
version:
run-as:
env:
proxy:
batch:
phases:
reports:
artifacts:
cache:
buidspec.yml の構成
buildspec のバージョン
コマンドを実行する Linux ユーザ
環境変数
プロキシサーバ設定
バッチビルド設定
実行するコマンド
テストレポート作成
AWS CodeBuild の出力
キャッシュ設定
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
version:
run-as:
env:
proxy:
batch:
phases:
reports:
artifacts:
cache:
buidspec.yml の構成
(必須)buildspec のバージョン
コマンドを実行する Linux ユーザ
環境変数
プロキシサーバ設定
バッチビルド設定
(必須)実行するコマンド
テストレポート作成
AWS CodeBuild の出力
キャッシュ設定
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
version
• 0.2 の使用を推奨
• 0.1 も引き続き利用可能
• バージョン 0.2 での変更点
• environment_variables → env
• plaintext → variables
• artifacts の type プロパティ廃止
• 同一インスタンスで全てのビルドコマンドを実行
version: 0.2
buildspec のバージョン
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
version
phases:
build:
commands:
- SERVICE_NAME=CodeBuild
- echo ${SERVICE_NAME}
version: 0.2 の場合
Running command echo ${SERVICE_NAME}
CodeBuild
version: 0.1 の場合
Running command echo ${SERVICE_NAME}
version 0.1 は各コマンドが独立して実行される
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
run-as
• Linux 環境でのみ使用可能
• 指定したユーザに読み取りおよび実行権限を付与
• 指定しない場合、すべてのコマンドが root ユーザで実行される
• Phases ブロックでオーバーライド可能
run-as: Linux-user-name
phases:
build:
run-as: Linux-user-name-02
コマンドを実行する Linux ユーザ
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
env
環境変数
env:
shell: shell-tag
variables:
key: "value"
parameter-store:
key: "value"
exported-variables:
- variable
secrets-manager:
key: secret-id:json-key:version-stage:version-id
git-credential-helper: no | yes
• 環境変数には以下を指定可能
• プレーンテキスト
• AWS Systems Manager Parameter Store の値
• AWS Secrets Manager の値
• 利用するシェル
• Bash, /bin/sh
• Powershell.exe, cmd.exe
• Git 認証ヘルパーを利用するか
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
proxy
• アーティファクトのアップロード時、CloudWatch Logs への
ログ送信時に プロキシサーバを利用するか個別に定義可能
• 明示的なプロキシサーバを利用する場合、環境変数の設定が必要
• HTTP_PROXY, HTTPS_PROXY, NO_PROXY
proxy:
upload-artifacts: no | yes
logs: no | yes
プロキシサーバ設定
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
batch
• プロジェクトの同時実行と協調実行の定義を行う
• バッチビルドには 3 つのタイプがある
• build-graph
• build-list
• build-matrix
バッチビルド設定
batch:
fast-fail: false | true
# build-list:
# build-matrix:
# build-graph:
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
batch/build-graph
batch:
fast-fail: false
build-graph:
- identifier: build1
env:
compute-type: BUILD_GENERAL1_SMALL
- identifier: build2
env:
compute-type: BUILD_GENERAL1_MEDIUM
depend-on:
- build1
- identifier: build3
env:
compute-type: BUILD_GENERAL1_LARGE
depend-on:
- build2
build1
build2
build3
ビルド開始
ビルド終了
バッチ内の他のタスクに依存する一連のタスクを定義
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
batch/build-list
batch:
fast-fail: false
build-list:
ignore-failure: true
- identifier: linux_small
env:
compute-type: BUILD_GENERAL1_SMALL
- identifier: windows_medium
env:
type: WINDOWS_SERVER_2019_CONTAINER
image: aws/codebuild/windows-base:2019-1.0
compute-type: BUILD_GENERAL1_MEDIUM
linux_small windows_medium
ビルド開始
ビルド終了
同時に実行されるタスクを定義
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
batch/build-matrix
batch:
build-matrix:
static:
ignore-failure: false
env:
type: LINUX_CONTAINER
privileged-mode: true
dynamic:
env:
image:
- aws/codebuild/amazonlinux2-x86_64-standard:3.0
- aws/codebuild/windows-base:2019-1.0
variables:
MY_VAR:
- VALUE1
- VALUE2
- VALUE3
amazonlinux2
MY_VAR=VALUE1
amazonlinux2
MY_VAR=VALUE2
amazonlinux2
MY_VAR=VALUE3
windows
MY_VAR=VALUE1
windows
MY_VAR=VALUE2
windows
MY_VAR=VALUE3
ビルド開始
ビルド終了
さまざまな環境と並行して実行されるタスクを定義
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
phases:
install:
runtime-versions:
runtime: version
runtime: version
pre_build:
build:
post_build:
phases
run-as: Linux-user-name
commands:
- command
- command
finally:
- command
- command
install
パッケージのインストールのみに利用することを推奨
runtime-versions でランタイムを指定可能
pre_build
ビルド前に実行するコマンドを記述
Amazon ECR へのサイインイン、npm の依存関係インストールなど
build
ビルド中に実行するコマンドを記述
post_build
ビルド後に実行するコマンドを記述
ビルドアーティファクトを jar, war にする,
Docker イメージを Amazon ECR へ Push など
ビルドの各段階で CodeBuild が実行するコマンド記述する
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
reports
• テストレポート とコードカバレッジレポートの2種類
テストレポート の作成
reports:
report-group-name-or-arn:
files:
- location
- location
base-directory: location
discard-paths: no | yes
file-format: report-format
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
reports
• 以下のフォーマットに対応
• Cucumber JSON, JUnitXML, NUnitXML, NUnit3 XML, TestNGXML,
Visual Studio TRX
テストレポート ( JunitXMLの 例 )
reports:
junit-report:
files:
- 'target/surefire-reports/TEST-TestMessageUtil.xml'
file-format: JUNITXML
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
reports
テストレポート
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
reports
コードカバレッジレポート ( JaCoCoXML の例 )
reports:
jacoco-report:
files:
- 'target/site/jacoco/jacoco.xml'
file-format: 'JACOCOXML'
• 以下のフォーマットに対応
• Clover XML, Cobertula XML, JaCoCoXML, SimpleCovJSON
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
reports
コードカバレッジレポート
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
reports
コードカバレッジレポート
• ラインカバレッジ ( C0 : 命令網羅率 )
• line coverage = (total lines covered)/(total number of lines)
• コードのうち、テストで実行された行の割合
• ブランチカバレッジ ( C1 : 分岐網羅率 )
• branch coverage = (total branches covered)/(total number of branches)
• 分岐のうち、テストで実行された分岐の割合
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
artifacts
• アーティファクトの名、アーティファクトに
含めるサブディレクトリとファイルを指定
• secondary-artifacts を利用して、複数のビルド
出力アーティファクトを定義することも可能
CodeBuild の出力を定義
artifacts:
files:
- location
name: artifact-name
discard-paths: no | yes
base-directory: location
secondary-artifacts:
artifactIdentifier:
files:
- location
name: secondary-artifact-name
discard-paths: no | yes
base-directory: location
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
cache
• キャッシュタイプはビルドプロジェクトに対して設定
• キャッシュなし、S3 、ローカル
• S3 キャッシュと, ローカルキャッシュのカスタムキャッシュは
buildspec でキャッシュ対象を指定する
キャッシュの設定
cache:
paths:
- path
- path
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
cache
• S3 キャッシュでは個別のファイルを指定可能
S3 キャッシュの設定
cache:
paths:
- ${ディレクトリ}
- ${ファイル}
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
cache
• ローカルキャッシュのカスタムキャッシュは
ディレクトリのみ指定可能
ローカル キャッシュの設定
cache:
paths:
- ${ディレクトリ}
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
cache
• ソースキャッシュ
• Git メタデータをキャッシュ
• コミット間の変更のみが Pull される
• Docker レイヤーキャッシュ
• Docker レイヤーをキャッシュ
• Linux 環境のみ使用可能
• カスタムキャッシュ
• 上記に該当しない場合
• 個々のファイルは指定できず、ディレクトリのみ指定可能
ローカル キャッシュ
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
本日のアジェンダ
• AWS CodeBuild 概要
• buildspec.yml について
• 機能紹介
• まとめ
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
ビルドをローカルで実行する
git clone https://github.com/aws/aws-codebuild-docker-images.git
cd aws-codebuild-docker-images/ubuntu/standard/4.0
docker build -t aws/codebuild/standard:4.0 .
docker pull amazon/aws-codebuild-local:latest --disable-content-trust=false
ビルドイメージの設定
docker pull amazon/aws-codebuild-local:latest --disable-content-trust=false
wget https://raw.githubusercontent.com/aws/aws-codebuild-docker-images/master/local_builds/codebuild_build.sh
chmod +x codebuild_build.sh
CodeBuild エージェントのイメージとスクリプトを取得
AWS CodeBuild エージェントを使用して、ローカルマシンでビルド可能
• Git と Docker が必要
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• スクリプトはビルドイメージを起動し、カレントディレクトリにあるプロ
ジェクトでビルドを実行する
• ビルドプロジェクトの場所を指定するには -s オプションを利用する
• 出力ディレクトリの指定には –a オプションを利用する
ビルドをローカルで実行する
./codebuild_build.sh -i aws/codebuild/standard:4.0 -a <output directory>
カレントディレクトリのプロジェクトでビルド
./codebuild_build.sh -i aws/codebuild/standard:4.0 –s <build project directory> -a <output directory>
プロジェクトの場所を指定してビルド
AWS CodeBuild エージェントを使用して、ローカルマシンでビルド可能
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS Session Manager でビルド環境へアクセスする
• buildspec.yml に codebuild-breakpoint を埋め込み、
ビルド設定でセッション接続を有効にする
• Session Manager でビルド環境にアクセスし、調査を実施
• ビルドを再開するには codebuild-resume を実行する
マネジメントコンソール、CLI を介して Linux, Windows のビルド環境にアクセス
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS Session Manager でビルド環境へアクセスする
phases:
install:
runtime-versions:
java: corretto11
pre_build:
commands:
- echo Nothing to do in the pre_build
phase...
build:
commands:
- echo Build started on `date`
- mvn install
post_build:
commands:
- echo Build completed on `date`
- codebuild-breakpoint
codebuild-breakpoint コマンドでブレイクポイントをセット
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS Session Manager でビルド環境へアクセスする
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Session Manager でビルド環境へアクセスする
チェックを入れると必要な権限が
ロールに追加される
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Session Manager でビルド環境へアクセスする
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Session Manager でビルド環境へアクセスする
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Session Manager でビルド環境へアクセスする
codebuild-resume
ビルドを再開する
codebuild-resume コマンドでビルドを再開
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• ビルドプロジェクに対して生成される
パブリック可能な URL で認証不要
• CodeCommit や GitHub のマークダウン
ファイルに埋め込み、ビルドステータスを
表示することが可能
ビルドバッジ
埋め込み可能なイメージ(バッジ)として動的に生成されるステータス画像
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
ステータスの通知
通知ルールを設定してビルド状況の通知を受けることが可能
Amazon Simple
Notification Service
AWS Chatbot
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
VPC 内リソースへのアクセス
• プライベートサブネット内のリソースへアクセス
• VPCエンドポイント経由でのみアクセスできるように設定されたサービス
へのアクセス
• 固定 IP アドレスを必要とする外部サービスへの通信に NAT ゲートウェイ,
NAT インスタンスの EIP を使用する
注意点
• NAT ゲートウェイ、NAT インスタンスの代わりにインターネットゲート
ウェイを利用することはできない
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
VPC エンドポイントをサポート
• 連邦情報処理標準(FIPS) 準拠オプションもあり
AWS Cloud
VPC
Private subnet
Instance codebuild
AWS CodeBuild
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
利用料金
インスタンスタイプ メモリ vCPU Linux ビルド(1分) Windows ビルド(1分)
general1.small 3 GB 2 0.005USD
該当なし
general1.medium 7 GB 4 0.01USD
arm1.large 16 GiB 8 0.02USD
general1.large 15 GB 8 0.02USD
general1.2xlarge 144 GiB 72 0.25USD
gpu1.large 244 GiB 32 0.90USD
料金(東京リージョン)
無料利用枠
general1.small 100 分(月)
general1.small で、1 回 5 分 , 月に 300回 ビルドした場合
0.005USD * 5 分 * 300 回 = 7.5USD
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
本日のアジェンダ
• AWS CodeBuild 概要
• buildspec.yml について
• 機能紹介
• まとめ
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
まとめ
• AWS CodeBuild は、フルマネージドなビルドサービスでソースコー
ドのコンパイル、テスト実行、ソフトウェアパッケージの作成を実
行可能
• ローカル環境でのビルド、ビルド環境へログインしての
デバッグも可能
• 22種類のユースケースベースのサンプル
• https://docs.aws.amazon.com/ja_jp/codebuild/latest/userguide
/use-case-based-samples.html
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Q&A
お答えできなかったご質問については
AWS Japan Blog 「https://aws.amazon.com/jp/blogs/news/」にて
後日掲載します。
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS の日本語資料の場所「AWS 資料」で検索
https://amzn.to/JPArchive
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
で[検索]AWS イベント
毎週”W-A個別技術相談会”を実施中
• AWSのソリューションアーキテクト(SA)に
対策などを相談することも可能
• 申込みはイベント告知サイトから
(https://aws.amazon.com/jp/about-aws/events/)
AWS Well-Architected 個別技術相談会
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS 公式 Webinar
https://amzn.to/JPWebinar
過去資料
https://amzn.to/JPArchive
ご視聴ありがとうございました

More Related Content

More from Amazon Web Services Japan

More from Amazon Web Services Japan (20)

202202 AWS Black Belt Online Seminar AWS Managed Rules for AWS WAF の活用
202202 AWS Black Belt Online Seminar AWS Managed Rules for AWS WAF の活用202202 AWS Black Belt Online Seminar AWS Managed Rules for AWS WAF の活用
202202 AWS Black Belt Online Seminar AWS Managed Rules for AWS WAF の活用
 
202203 AWS Black Belt Online Seminar Amazon Connect Tasks.pdf
202203 AWS Black Belt Online Seminar Amazon Connect Tasks.pdf202203 AWS Black Belt Online Seminar Amazon Connect Tasks.pdf
202203 AWS Black Belt Online Seminar Amazon Connect Tasks.pdf
 
SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介
SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介
SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介
 
Amazon QuickSight の組み込み方法をちょっぴりDD
Amazon QuickSight の組み込み方法をちょっぴりDDAmazon QuickSight の組み込み方法をちょっぴりDD
Amazon QuickSight の組み込み方法をちょっぴりDD
 
マルチテナント化で知っておきたいデータベースのこと
マルチテナント化で知っておきたいデータベースのことマルチテナント化で知っておきたいデータベースのこと
マルチテナント化で知っておきたいデータベースのこと
 
機密データとSaaSは共存しうるのか!?セキュリティー重視のユーザー層を取り込む為のネットワーク通信のアプローチ
機密データとSaaSは共存しうるのか!?セキュリティー重視のユーザー層を取り込む為のネットワーク通信のアプローチ機密データとSaaSは共存しうるのか!?セキュリティー重視のユーザー層を取り込む為のネットワーク通信のアプローチ
機密データとSaaSは共存しうるのか!?セキュリティー重視のユーザー層を取り込む為のネットワーク通信のアプローチ
 
パッケージソフトウェアを簡単にSaaS化!?既存の資産を使ったSaaS化手法のご紹介
パッケージソフトウェアを簡単にSaaS化!?既存の資産を使ったSaaS化手法のご紹介パッケージソフトウェアを簡単にSaaS化!?既存の資産を使ったSaaS化手法のご紹介
パッケージソフトウェアを簡単にSaaS化!?既存の資産を使ったSaaS化手法のご紹介
 
202202 AWS Black Belt Online Seminar Amazon Connect Customer Profiles
202202 AWS Black Belt Online Seminar Amazon Connect Customer Profiles202202 AWS Black Belt Online Seminar Amazon Connect Customer Profiles
202202 AWS Black Belt Online Seminar Amazon Connect Customer Profiles
 
Amazon Game Tech Night #24 KPIダッシュボードを最速で用意するために
Amazon Game Tech Night #24 KPIダッシュボードを最速で用意するためにAmazon Game Tech Night #24 KPIダッシュボードを最速で用意するために
Amazon Game Tech Night #24 KPIダッシュボードを最速で用意するために
 
202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨
202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨
202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨
 
[20220126] JAWS-UG 2022初頭までに葬ったAWSアンチパターン大紹介
[20220126] JAWS-UG 2022初頭までに葬ったAWSアンチパターン大紹介[20220126] JAWS-UG 2022初頭までに葬ったAWSアンチパターン大紹介
[20220126] JAWS-UG 2022初頭までに葬ったAWSアンチパターン大紹介
 
202111 AWS Black Belt Online Seminar AWSで構築するSmart Mirrorのご紹介
202111 AWS Black Belt Online Seminar AWSで構築するSmart Mirrorのご紹介202111 AWS Black Belt Online Seminar AWSで構築するSmart Mirrorのご紹介
202111 AWS Black Belt Online Seminar AWSで構築するSmart Mirrorのご紹介
 
202201 AWS Black Belt Online Seminar Apache Spark Performnace Tuning for AWS ...
202201 AWS Black Belt Online Seminar Apache Spark Performnace Tuning for AWS ...202201 AWS Black Belt Online Seminar Apache Spark Performnace Tuning for AWS ...
202201 AWS Black Belt Online Seminar Apache Spark Performnace Tuning for AWS ...
 
202112 AWS Black Belt Online Seminar 店内の「今」をお届けする小売業向けリアルタイム配信基盤のレシピ
202112 AWS Black Belt Online Seminar 店内の「今」をお届けする小売業向けリアルタイム配信基盤のレシピ202112 AWS Black Belt Online Seminar 店内の「今」をお届けする小売業向けリアルタイム配信基盤のレシピ
202112 AWS Black Belt Online Seminar 店内の「今」をお届けする小売業向けリアルタイム配信基盤のレシピ
 
20211209 Ops-JAWS Re invent2021re-cap-cloud operations
20211209 Ops-JAWS Re invent2021re-cap-cloud operations20211209 Ops-JAWS Re invent2021re-cap-cloud operations
20211209 Ops-JAWS Re invent2021re-cap-cloud operations
 
20211203 AWS Black Belt Online Seminar AWS re:Invent 2021アップデート速報
20211203 AWS Black Belt Online Seminar AWS re:Invent 2021アップデート速報20211203 AWS Black Belt Online Seminar AWS re:Invent 2021アップデート速報
20211203 AWS Black Belt Online Seminar AWS re:Invent 2021アップデート速報
 
[AWS EXpert Online for JAWS-UG 18] 見せてやるよ、Step Functions の本気ってやつをな
[AWS EXpert Online for JAWS-UG 18] 見せてやるよ、Step Functions の本気ってやつをな[AWS EXpert Online for JAWS-UG 18] 見せてやるよ、Step Functions の本気ってやつをな
[AWS EXpert Online for JAWS-UG 18] 見せてやるよ、Step Functions の本気ってやつをな
 
20211109 JAWS-UG SRE keynotes
20211109 JAWS-UG SRE keynotes20211109 JAWS-UG SRE keynotes
20211109 JAWS-UG SRE keynotes
 
20211109 bleaの使い方(基本編)
20211109 bleaの使い方(基本編)20211109 bleaの使い方(基本編)
20211109 bleaの使い方(基本編)
 
202110 AWS Black Belt Online Seminar AWS Site-to-Site VPN
202110 AWS Black Belt Online Seminar AWS Site-to-Site VPN202110 AWS Black Belt Online Seminar AWS Site-to-Site VPN
202110 AWS Black Belt Online Seminar AWS Site-to-Site VPN
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 

20201125 AWS Black Belt Online Seminar AWS CodeBuild

  • 1. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS 公式 Webinar https://amzn.to/JPWebinar 過去資料 https://amzn.to/JPArchive Solutions Architect 松本 雅博 2020/11/25 AWS CodeBuild サービスカットシリーズ [AWS Black Belt Online Seminar]
  • 2. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 自己紹介 松本 雅博(まつもと まさひろ) 技術統括本部 西日本ソリューション部 ソリューションアーキテクト 関西を中心に、西日本のお客様をご支援 好きなサービス • Code シリーズ • AWS CloudFormation, AWS Cloud Development Kit
  • 3. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Black Belt Online Seminar とは 「サービス別」「ソリューション別」「業種別」のそれぞれのテーマに分かれて、アマゾ ン ウェブ サービス ジャパン株式会社が主催するオンラインセミナーシリーズです。 質問を投げることができます! • 書き込んだ質問は、主催者にしか見えません • 今後のロードマップに関するご質問は お答えできませんのでご了承下さい ① 吹き出しをクリック ② 質問を入力 ③ Sendをクリック Twitter ハッシュタグは以下をご利用ください #awsblackbelt
  • 4. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 内容についての注意点 • 本資料では2020年11月25日現在のサービス内容および価格についてご説明しています。最新の 情報はAWS公式ウェブサイト(http://aws.amazon.com)にてご確認ください。 • 資料作成には十分注意しておりますが、資料内の価格とAWS公式ウェブサイト記載の価格に相 違があった場合、AWS公式ウェブサイトの価格を優先とさせていただきます。 • 価格は税抜表記となっています。日本居住者のお客様には別途消費税をご請求させていただきま す。 • AWS does not offer binding price quotes. AWS pricing is publicly available and is subject to change in accordance with the AWS Customer Agreement available at http://aws.amazon.com/agreement/. Any pricing information included in this document is provided only as an estimate of usage charges for AWS services based on certain information that you have provided. Monthly charges will be based on your actual use of AWS services, and may vary from the estimates provided.
  • 5. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 本セミナーの概要 • 本セミナーで学習できること • AWS CodeBuild • 対象者 • アーキテクトの方 • 技術者の方
  • 6. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 本日のアジェンダ • AWS CodeBuild 概要 • buildspec.yml について • 機能紹介 • まとめ
  • 7. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. ソフトウェア開発に関連する AWS サービス AWS CodeBuild + Third Party AWS CodeCommit AWS CodeBuild AWS CodeDeploy AWS X-Ray AWS CodePipeline MONITORDEPLOYTESTBUILD SOURCE / ARTIFACT AUTHOR AWS Cloud9 AWS IDE Toolkits Amazon CloudWatch AWS CloudFormation AWS SAMAWS Cloud Development KitMODEL Amazon CodeGuru AWS CodeArtifact
  • 8. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. ソフトウェア開発に関連する AWS サービス AWS CodeBuild + Third Party AWS CodeCommit AWS CodeBuild AWS CodeDeploy AWS X-Ray AWS CodePipeline MONITORDEPLOYTESTBUILD SOURCE / ARTIFACT AUTHOR AWS Cloud9 AWS IDE Toolkits Amazon CloudWatch AWS CloudFormation AWS SAMAWS Cloud Development KitMODEL Amazon CodeGuru AWS CodeArtifact
  • 9. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS CodeBuild  フルマネージドなビルドサービスでソースコードの コンパイル、テスト実行、ソフトウェア パッケージの作成を実行  継続的なスケールと同時複数ビルドプロセス  サーバーの管理は不要  利用した分のみの支払い(分単位の課金)  Amazon CloudWatch によるモニタリング可能
  • 10. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS CodeBuild  一貫したイミュータブルな環境のために個々の ビルドを新規 Docker コンテナで実行  すべてのオフィシャルな AWS CodeBuild イメージ に Docker と AWS CLI をインストール済み  ニーズに応じて Docker イメージを作成することに よってカスタムなビルド環境を提供可能
  • 11. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS CodeBuild の実行方法 AWS Command Line Interface AWS Tools and SDKs AWS CodePipeline AWS CodeBuild AWS Management Console
  • 12. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS CodeBuild の仕組み AWS Command Line Interface AWS Tools and SDKs AWS CodePipeline AWS CodeBuild AWS Management Console
  • 13. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS CodeBuild の仕組み AWS Command Line Interface AWS Tools and SDKs AWS CodePipeline AWS CodeBuild AWS Management Console Amazon Simple Storage Service (S3) ソースコード ビルドプロジェクト ビルド環境 作成
  • 14. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS CodeBuild の仕組み AWS Command Line Interface AWS Tools and SDKs AWS CodePipeline AWS CodeBuild AWS Management Console Amazon Simple Storage Service (S3) ソースコード ビルドプロジェクト ビルド環境 Amazon CloudWatch Amazon CloudWatch Logs 取得 メトリクス / ログ送信 メトリクス / ログ取得
  • 15. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS CodeBuild の仕組み AWS Command Line Interface AWS Tools and SDKs AWS CodePipeline AWS CodeBuild AWS Management Console Amazon Simple Storage Service (S3) ビルドプロジェクト ビルド環境 アップロード
  • 16. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS CodeBuild の仕組み AWS Command Line Interface AWS Tools and SDKs AWS CodePipeline AWS CodeBuild AWS Management Console ビルドプロジェクト ビルド環境 AWS ChatbotAmazon Simple Notification Service 通知
  • 17. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS CodeBuild プロジェクトの作成
  • 18. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS CodeBuild プロジェクトの作成 プロジェクト名を入力
  • 19. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS CodeBuild プロジェクトの作成 ソースとして Amazon S3 を選択し、 バケット名と オブジェクトキーを入力
  • 20. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS CodeBuild プロジェクトの作成 オペレーティングシステムに Amazon Linux 2 を選択し、 ランタイムとイメージを指定する
  • 21. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS CodeBuild プロジェクトの作成 ビルド仕様は buildspec ファイルを使用するを選択
  • 22. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS CodeBuild プロジェクトの作成 アーティファクトのタイプに Amazon S3 を選択し、 バケット名を入力する
  • 23. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS CodeBuild プロジェクトの作成 CloudWatch Logs へログを送信する
  • 24. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. ソースの作成
  • 25. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. ソースの作成 buildspec のバージョン ランタイムに Java を指定 jar ファイルを作成 ビルド出力を定義
  • 26. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. ビルドの実行
  • 27. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. ビルドの実行
  • 28. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 本日のアジェンダ • AWS CodeBuild 概要 • buildspec.yml について • 機能紹介 • まとめ
  • 29. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. version: run-as: env: proxy: batch: phases: reports: artifacts: cache: buidspec.yml の構成 buildspec のバージョン コマンドを実行する Linux ユーザ 環境変数 プロキシサーバ設定 バッチビルド設定 実行するコマンド テストレポート作成 AWS CodeBuild の出力 キャッシュ設定
  • 30. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. version: run-as: env: proxy: batch: phases: reports: artifacts: cache: buidspec.yml の構成 (必須)buildspec のバージョン コマンドを実行する Linux ユーザ 環境変数 プロキシサーバ設定 バッチビルド設定 (必須)実行するコマンド テストレポート作成 AWS CodeBuild の出力 キャッシュ設定
  • 31. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. version • 0.2 の使用を推奨 • 0.1 も引き続き利用可能 • バージョン 0.2 での変更点 • environment_variables → env • plaintext → variables • artifacts の type プロパティ廃止 • 同一インスタンスで全てのビルドコマンドを実行 version: 0.2 buildspec のバージョン
  • 32. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. version phases: build: commands: - SERVICE_NAME=CodeBuild - echo ${SERVICE_NAME} version: 0.2 の場合 Running command echo ${SERVICE_NAME} CodeBuild version: 0.1 の場合 Running command echo ${SERVICE_NAME} version 0.1 は各コマンドが独立して実行される
  • 33. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. run-as • Linux 環境でのみ使用可能 • 指定したユーザに読み取りおよび実行権限を付与 • 指定しない場合、すべてのコマンドが root ユーザで実行される • Phases ブロックでオーバーライド可能 run-as: Linux-user-name phases: build: run-as: Linux-user-name-02 コマンドを実行する Linux ユーザ
  • 34. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. env 環境変数 env: shell: shell-tag variables: key: "value" parameter-store: key: "value" exported-variables: - variable secrets-manager: key: secret-id:json-key:version-stage:version-id git-credential-helper: no | yes • 環境変数には以下を指定可能 • プレーンテキスト • AWS Systems Manager Parameter Store の値 • AWS Secrets Manager の値 • 利用するシェル • Bash, /bin/sh • Powershell.exe, cmd.exe • Git 認証ヘルパーを利用するか
  • 35. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. proxy • アーティファクトのアップロード時、CloudWatch Logs への ログ送信時に プロキシサーバを利用するか個別に定義可能 • 明示的なプロキシサーバを利用する場合、環境変数の設定が必要 • HTTP_PROXY, HTTPS_PROXY, NO_PROXY proxy: upload-artifacts: no | yes logs: no | yes プロキシサーバ設定
  • 36. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. batch • プロジェクトの同時実行と協調実行の定義を行う • バッチビルドには 3 つのタイプがある • build-graph • build-list • build-matrix バッチビルド設定 batch: fast-fail: false | true # build-list: # build-matrix: # build-graph:
  • 37. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. batch/build-graph batch: fast-fail: false build-graph: - identifier: build1 env: compute-type: BUILD_GENERAL1_SMALL - identifier: build2 env: compute-type: BUILD_GENERAL1_MEDIUM depend-on: - build1 - identifier: build3 env: compute-type: BUILD_GENERAL1_LARGE depend-on: - build2 build1 build2 build3 ビルド開始 ビルド終了 バッチ内の他のタスクに依存する一連のタスクを定義
  • 38. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. batch/build-list batch: fast-fail: false build-list: ignore-failure: true - identifier: linux_small env: compute-type: BUILD_GENERAL1_SMALL - identifier: windows_medium env: type: WINDOWS_SERVER_2019_CONTAINER image: aws/codebuild/windows-base:2019-1.0 compute-type: BUILD_GENERAL1_MEDIUM linux_small windows_medium ビルド開始 ビルド終了 同時に実行されるタスクを定義
  • 39. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. batch/build-matrix batch: build-matrix: static: ignore-failure: false env: type: LINUX_CONTAINER privileged-mode: true dynamic: env: image: - aws/codebuild/amazonlinux2-x86_64-standard:3.0 - aws/codebuild/windows-base:2019-1.0 variables: MY_VAR: - VALUE1 - VALUE2 - VALUE3 amazonlinux2 MY_VAR=VALUE1 amazonlinux2 MY_VAR=VALUE2 amazonlinux2 MY_VAR=VALUE3 windows MY_VAR=VALUE1 windows MY_VAR=VALUE2 windows MY_VAR=VALUE3 ビルド開始 ビルド終了 さまざまな環境と並行して実行されるタスクを定義
  • 40. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. phases: install: runtime-versions: runtime: version runtime: version pre_build: build: post_build: phases run-as: Linux-user-name commands: - command - command finally: - command - command install パッケージのインストールのみに利用することを推奨 runtime-versions でランタイムを指定可能 pre_build ビルド前に実行するコマンドを記述 Amazon ECR へのサイインイン、npm の依存関係インストールなど build ビルド中に実行するコマンドを記述 post_build ビルド後に実行するコマンドを記述 ビルドアーティファクトを jar, war にする, Docker イメージを Amazon ECR へ Push など ビルドの各段階で CodeBuild が実行するコマンド記述する
  • 41. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. reports • テストレポート とコードカバレッジレポートの2種類 テストレポート の作成 reports: report-group-name-or-arn: files: - location - location base-directory: location discard-paths: no | yes file-format: report-format
  • 42. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. reports • 以下のフォーマットに対応 • Cucumber JSON, JUnitXML, NUnitXML, NUnit3 XML, TestNGXML, Visual Studio TRX テストレポート ( JunitXMLの 例 ) reports: junit-report: files: - 'target/surefire-reports/TEST-TestMessageUtil.xml' file-format: JUNITXML
  • 43. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. reports テストレポート
  • 44. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. reports コードカバレッジレポート ( JaCoCoXML の例 ) reports: jacoco-report: files: - 'target/site/jacoco/jacoco.xml' file-format: 'JACOCOXML' • 以下のフォーマットに対応 • Clover XML, Cobertula XML, JaCoCoXML, SimpleCovJSON
  • 45. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. reports コードカバレッジレポート
  • 46. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. reports コードカバレッジレポート • ラインカバレッジ ( C0 : 命令網羅率 ) • line coverage = (total lines covered)/(total number of lines) • コードのうち、テストで実行された行の割合 • ブランチカバレッジ ( C1 : 分岐網羅率 ) • branch coverage = (total branches covered)/(total number of branches) • 分岐のうち、テストで実行された分岐の割合
  • 47. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. artifacts • アーティファクトの名、アーティファクトに 含めるサブディレクトリとファイルを指定 • secondary-artifacts を利用して、複数のビルド 出力アーティファクトを定義することも可能 CodeBuild の出力を定義 artifacts: files: - location name: artifact-name discard-paths: no | yes base-directory: location secondary-artifacts: artifactIdentifier: files: - location name: secondary-artifact-name discard-paths: no | yes base-directory: location
  • 48. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. cache • キャッシュタイプはビルドプロジェクトに対して設定 • キャッシュなし、S3 、ローカル • S3 キャッシュと, ローカルキャッシュのカスタムキャッシュは buildspec でキャッシュ対象を指定する キャッシュの設定 cache: paths: - path - path
  • 49. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. cache • S3 キャッシュでは個別のファイルを指定可能 S3 キャッシュの設定 cache: paths: - ${ディレクトリ} - ${ファイル}
  • 50. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. cache • ローカルキャッシュのカスタムキャッシュは ディレクトリのみ指定可能 ローカル キャッシュの設定 cache: paths: - ${ディレクトリ}
  • 51. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. cache • ソースキャッシュ • Git メタデータをキャッシュ • コミット間の変更のみが Pull される • Docker レイヤーキャッシュ • Docker レイヤーをキャッシュ • Linux 環境のみ使用可能 • カスタムキャッシュ • 上記に該当しない場合 • 個々のファイルは指定できず、ディレクトリのみ指定可能 ローカル キャッシュ
  • 52. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 本日のアジェンダ • AWS CodeBuild 概要 • buildspec.yml について • 機能紹介 • まとめ
  • 53. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. ビルドをローカルで実行する git clone https://github.com/aws/aws-codebuild-docker-images.git cd aws-codebuild-docker-images/ubuntu/standard/4.0 docker build -t aws/codebuild/standard:4.0 . docker pull amazon/aws-codebuild-local:latest --disable-content-trust=false ビルドイメージの設定 docker pull amazon/aws-codebuild-local:latest --disable-content-trust=false wget https://raw.githubusercontent.com/aws/aws-codebuild-docker-images/master/local_builds/codebuild_build.sh chmod +x codebuild_build.sh CodeBuild エージェントのイメージとスクリプトを取得 AWS CodeBuild エージェントを使用して、ローカルマシンでビルド可能 • Git と Docker が必要
  • 54. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. • スクリプトはビルドイメージを起動し、カレントディレクトリにあるプロ ジェクトでビルドを実行する • ビルドプロジェクトの場所を指定するには -s オプションを利用する • 出力ディレクトリの指定には –a オプションを利用する ビルドをローカルで実行する ./codebuild_build.sh -i aws/codebuild/standard:4.0 -a <output directory> カレントディレクトリのプロジェクトでビルド ./codebuild_build.sh -i aws/codebuild/standard:4.0 –s <build project directory> -a <output directory> プロジェクトの場所を指定してビルド AWS CodeBuild エージェントを使用して、ローカルマシンでビルド可能
  • 55. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Session Manager でビルド環境へアクセスする • buildspec.yml に codebuild-breakpoint を埋め込み、 ビルド設定でセッション接続を有効にする • Session Manager でビルド環境にアクセスし、調査を実施 • ビルドを再開するには codebuild-resume を実行する マネジメントコンソール、CLI を介して Linux, Windows のビルド環境にアクセス
  • 56. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Session Manager でビルド環境へアクセスする phases: install: runtime-versions: java: corretto11 pre_build: commands: - echo Nothing to do in the pre_build phase... build: commands: - echo Build started on `date` - mvn install post_build: commands: - echo Build completed on `date` - codebuild-breakpoint codebuild-breakpoint コマンドでブレイクポイントをセット
  • 57. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Session Manager でビルド環境へアクセスする
  • 58. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Session Manager でビルド環境へアクセスする チェックを入れると必要な権限が ロールに追加される
  • 59. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Session Manager でビルド環境へアクセスする
  • 60. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Session Manager でビルド環境へアクセスする
  • 61. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Session Manager でビルド環境へアクセスする codebuild-resume ビルドを再開する codebuild-resume コマンドでビルドを再開
  • 62. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. • ビルドプロジェクに対して生成される パブリック可能な URL で認証不要 • CodeCommit や GitHub のマークダウン ファイルに埋め込み、ビルドステータスを 表示することが可能 ビルドバッジ 埋め込み可能なイメージ(バッジ)として動的に生成されるステータス画像
  • 63. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. ステータスの通知 通知ルールを設定してビルド状況の通知を受けることが可能 Amazon Simple Notification Service AWS Chatbot
  • 64. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. VPC 内リソースへのアクセス • プライベートサブネット内のリソースへアクセス • VPCエンドポイント経由でのみアクセスできるように設定されたサービス へのアクセス • 固定 IP アドレスを必要とする外部サービスへの通信に NAT ゲートウェイ, NAT インスタンスの EIP を使用する 注意点 • NAT ゲートウェイ、NAT インスタンスの代わりにインターネットゲート ウェイを利用することはできない
  • 65. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. VPC エンドポイントをサポート • 連邦情報処理標準(FIPS) 準拠オプションもあり AWS Cloud VPC Private subnet Instance codebuild AWS CodeBuild
  • 66. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 利用料金 インスタンスタイプ メモリ vCPU Linux ビルド(1分) Windows ビルド(1分) general1.small 3 GB 2 0.005USD 該当なし general1.medium 7 GB 4 0.01USD arm1.large 16 GiB 8 0.02USD general1.large 15 GB 8 0.02USD general1.2xlarge 144 GiB 72 0.25USD gpu1.large 244 GiB 32 0.90USD 料金(東京リージョン) 無料利用枠 general1.small 100 分(月) general1.small で、1 回 5 分 , 月に 300回 ビルドした場合 0.005USD * 5 分 * 300 回 = 7.5USD
  • 67. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 本日のアジェンダ • AWS CodeBuild 概要 • buildspec.yml について • 機能紹介 • まとめ
  • 68. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. まとめ • AWS CodeBuild は、フルマネージドなビルドサービスでソースコー ドのコンパイル、テスト実行、ソフトウェアパッケージの作成を実 行可能 • ローカル環境でのビルド、ビルド環境へログインしての デバッグも可能 • 22種類のユースケースベースのサンプル • https://docs.aws.amazon.com/ja_jp/codebuild/latest/userguide /use-case-based-samples.html
  • 69. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Q&A お答えできなかったご質問については AWS Japan Blog 「https://aws.amazon.com/jp/blogs/news/」にて 後日掲載します。
  • 70. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS の日本語資料の場所「AWS 資料」で検索 https://amzn.to/JPArchive
  • 71. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. で[検索]AWS イベント 毎週”W-A個別技術相談会”を実施中 • AWSのソリューションアーキテクト(SA)に 対策などを相談することも可能 • 申込みはイベント告知サイトから (https://aws.amazon.com/jp/about-aws/events/) AWS Well-Architected 個別技術相談会
  • 72. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS 公式 Webinar https://amzn.to/JPWebinar 過去資料 https://amzn.to/JPArchive ご視聴ありがとうございました