Skip to Content
AWS Lambdaのプログラミング
book

AWS Lambdaのプログラミング

by John Chapin, Mike Roberts
March 2025
Intermediate to advanced
278 pages
4h 2m
Japanese
O'Reilly Media, Inc.
Content preview from AWS Lambdaのプログラミング

第4章. AWS Lambda関数を運用する

この作品はAIを使って翻訳されている。ご意見、ご感想をお待ちしている:translation-feedback@oreilly.com

この章では、JavaベースのAWS Lambda関数をビルドしてパッケージ化する、より高度な方法を紹介する。 また、第2章で初めて使用した、AWSのインフラストラクチャー・アズ・コードツール、SAMのサーバーレス指向バージョンについて、より詳しく説明する。 最後に、Lambda関数とサーバーレスアプリケーションが、AWSのセキュリティモデルによってどのような影響を受けるか、また、SAMを使用してサーバーレスアプリケーションに最小特権セキュリティモデルを自動的に適用する方法について説明する。

先に進む前に、もしまだそうしていなければ、本書のコード例をダウンロードすることをお勧めする。

ビルド&パッケージ

Lambdaプラットフォームは、ユーザから提供されるすべてのコードがZIPアーカイブファイルの形式であることを想定している。 使用しているランタイムと実際のビジネスロジックによって、そのZIPファイルはソースコード、コードとライブラリ、またはJavaの場合はコンパイルされたバイトコード(クラスファイル)とライブラリで構成される。

Javaエコシステムにおいて、私たちはしばしばコードをJAR(Java ARchive)ファイルにパッケージ化し、java -jar コマンドで実行したり、他のアプリケーションでライブラリとして使用したりする。 JARファイルは、単にZIPファイルにメタデータを追加したものであることがわかった。Lambdaプラットフォームは、JARファイルを特殊化することはなく、他のLambda言語ランタイムと同じように、ZIPファイルとして扱う。

、Mavenのようなツールを使えば、コードが依存する他のライブラリを指定し、Mavenにそれらのライブラリ(およびそれらのライブラリが持つ可能性のある相互依存関係)の適切なバージョンをダウンロードさせ、コードをJavaクラスファイルにコンパイルし、すべてを1つのJARファイル(しばしばuberjarと呼ばれる)にパッケージすることができる。

ユーバーヤーズ

第2章と第3章では、 、ユーバーイェー・アプローチを使用しているにもかかわらず、先に進む前に呼びかけておく価値のある問題がいくつかある。

まず、uberjarのアプローチでライブラリを解凍し、ターゲットのuberjarファイルにライブラリを重ね合わせる。 以下の例では、ライブラリAにはクラス・ファイルとプロパティ・ファイルが含まれている。 ライブラリBには、別のクラス・ファイルと、ライブラリAのプロパティ・ファイルと同じ名前のプロパティ・ファイルが含まれている。

$ jar tf LibraryA.jar
book/
book/important.properties
book/A.class

$ jar tf LibraryB.jar
book/
book/important.properties
book/B.class

これらのJARファイルを使用してuberjarを作成した場合(前の章で行ったように)、結果には2つのクラス・ファイルと1つのプロパティ・ファイルが含まれることになるが、プロパティ・ファイルはどのソースJARのものなのだろうか?

$ jar tf uberjar.jar book/ book/important.properties ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

AWS におけるセキュリティとマイクロサービスアーキテクチャ

AWS におけるセキュリティとマイクロサービスアーキテクチャ

Gaurav Raje
AWS クックブック

AWS クックブック

John Culkin, Mike Zazon
ハンズオン AWS CDK

ハンズオン AWS CDK

Sam Ward Biddle, Kyle T. Jones
Hands-On AWS CDK

Hands-On AWS CDK

Sam Ward Biddle, Kyle T. Jones

Publisher Resources

ISBN: 9798341636026