

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# Lambda 関数、Amazon VPC、およびサーバーレスアーキテクチャを使用して静的アウトバウンド IP アドレスを生成する
<a name="generate-a-static-outbound-ip-address-using-a-lambda-function-amazon-vpc-and-a-serverless-architecture"></a>

*Thomas Scott、Amazon Web Services*

## 概要
<a name="generate-a-static-outbound-ip-address-using-a-lambda-function-amazon-vpc-and-a-serverless-architecture-summary"></a>

このパターンでは、サーバーレスアーキテクチャを使用して、Amazon Web Services (AWS) クラウドで静的アウトバウンド IP アドレスを生成する方法を説明します。組織がセキュアファイル転送プロトコル (SFTP) を使用して別の事業体にファイルを送信したい場合、この方法を利用することができる。つまり、事業体は、ファイアウォールを通過するファイルを許可する IP アドレスにアクセスできる必要があります。 

このパターンのアプローチは、「[Elastic IP アドレス](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html)」をアウトバウンド IP アドレスとして使用する AWS Lambda 関数を作成するのに役立ちます。このパターンの手順に従うことで、Lambda 関数と、静的 IP アドレスを持つインターネットゲートウェイ経由でアウトバウンドトラフィックをルーティングする仮想プライベートクラウド (VPC) を作成できます。静的 IP アドレスを使用するには、Lambda 関数を VPC とそのサブネットにアタッチします。 

## 前提条件と制限事項
<a name="generate-a-static-outbound-ip-address-using-a-lambda-function-amazon-vpc-and-a-serverless-architecture-prereqs"></a>

**前提条件**
+ アクティブな AWS アカウント。 
+ AWS Identity and Access Management (IAM) アクセス権限で、Lambda 関数の作成とデプロイ、VPC とそのサブネットの作成が可能です。詳細については、AWS Lambda ドキュメントの「[実行ロールとユーザー権限](https://docs.aws.amazon.com/lambda/latest/dg/configuration-vpc.html#vpc-permissions)」を参照してください。
+ infrastructure as code (IaC) を使用してこのパターンのアプローチを実装する予定であれば、AWS Cloud9 のような統合開発環境 (IDE) が必要です。詳細については、AWS Cloud9 ドキュメントにある「[AWS Cloud9 とは?](https://docs.aws.amazon.com/cloud9/latest/user-guide/welcome.html)」を参照してください。

## アーキテクチャ
<a name="generate-a-static-outbound-ip-address-using-a-lambda-function-amazon-vpc-and-a-serverless-architecture-architecture"></a>

このパターンのサーバーレスアーキテクチャを次の図に示します。

![\[AWS クラウド VPC architecture with two availability zones, public and private subnets, NAT gateways, and a Lambda function.\]](http://docs.aws.amazon.com/ja_jp/prescriptive-guidance/latest/patterns/images/pattern-img/eb1d0b05-df33-45ae-b27e-36090055b300/images/c15cc6da-ce4e-4ea0-9feb-de1c845d3ce8.png)


この図表は、次のワークフローを示しています:

1. アウトバウンドトラフィックは `NAT gateway 1` の `Public subnet 1` から離れます。

1. アウトバウンドトラフィックは `NAT gateway 2` の `Public subnet 2` から離れます。

1. Lambda 関数は `Private subnet 1` または `Private subnet 2` で実行できます。

1. `Private subnet 1` と `Private subnet 2` はパブリックサブネットの NAT ゲートウェイにトラフィックをルーティングします。

1. NAT ゲートウェイは、パブリックサブネットからインターネットゲートウェイにアウトバウンドトラフィックを送信します。

1. アウトバウンドデータは、インターネットゲートウェイから外部サーバーに転送されます。



テクノロジースタック
+ Lambda
+ Amazon Virtual Private Cloud (Amazon VPC)

 

**自動化とスケール**

異なるアベイラビリティーゾーンにある 2 つのパブリックサブネットと 2 つのプライベートサブネットを使用することで、高可用性 (HA) を確保できます。1 つのアベイラビリティーゾーンが利用できなくなっても、パターンのソリューションは引き続き機能します。

## ツール
<a name="generate-a-static-outbound-ip-address-using-a-lambda-function-amazon-vpc-and-a-serverless-architecture-tools"></a>
+ 「[AWS Lambda](https://docs.aws.amazon.com/lambda/latest/dg/welcome.html)」 – AWS Lambda はサーバーのプロビジョニングや管理を行わずにコードの実行を支援できるコンピューティングサービスです。Lambda は必要に応じてコードを実行し、1 日あたり数個のリクエストから 1 秒あたり数千のリクエストまで自動的にスケールします。課金は実際に消費したコンピューティング時間に対してのみ発生します。コードが実行されていない場合、料金は発生しません。
+ 「[Amazon VPC](https://docs.aws.amazon.com/vpc/)」— Amazon Virtual Private Cloud (Amazon VPC) では、AWS クラウドの論理的に隔離されたセクションをプロビジョニングすることで、ユーザーが定義した仮想ネットワーク内で AWS リソースを起動できます。仮想ネットワークは、お客様自身のデータセンターで運用されていた従来のネットワークによく似ていますが、AWS のスケーラブルなインフラストラクチャを使用できるというメリットがあります。

## エピック
<a name="generate-a-static-outbound-ip-address-using-a-lambda-function-amazon-vpc-and-a-serverless-architecture-epics"></a>

### VPC を新規作成する
<a name="create-a-new-vpc"></a>


| タスク | 説明 | 必要なスキル | 
| --- | --- | --- | 
| 新しい VPC を作成します。 | AWS マネジメントコンソールにサインインし、Amazon VPC コンソールを開いて、`10.0.0.0/25`** **を IPv4 CIDR 範囲とする `Lambda VPC` という名前の VPC を作成します。VPC の作成に関する詳細は、Amazon VPC ドキュメントの「[Amazon VPC の使用開始](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-getting-started.html#getting-started-create-vpc)」を参照してください。  | AWS 管理者 | 

### 2 つのパブリックサブネットを作成します。
<a name="create-two-public-subnets"></a>


| タスク | 説明 | 必要なスキル | 
| --- | --- | --- | 
| 最初のパブリックサブネットを作成します。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/prescriptive-guidance/latest/patterns/generate-a-static-outbound-ip-address-using-a-lambda-function-amazon-vpc-and-a-serverless-architecture.html) | AWS 管理者 | 
| 2 番目のパブリックサブネットを作成します。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/prescriptive-guidance/latest/patterns/generate-a-static-outbound-ip-address-using-a-lambda-function-amazon-vpc-and-a-serverless-architecture.html) | AWS 管理者 | 

### プライベートサブネットを 2 つ作成する
<a name="create-two-private-subnets"></a>


| タスク | 説明 | 必要なスキル | 
| --- | --- | --- | 
| 最初のプライベートサブネットを作成します。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/prescriptive-guidance/latest/patterns/generate-a-static-outbound-ip-address-using-a-lambda-function-amazon-vpc-and-a-serverless-architecture.html) | AWS 管理者 | 
| 2 番目のプライベートサブネットを作成する | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/prescriptive-guidance/latest/patterns/generate-a-static-outbound-ip-address-using-a-lambda-function-amazon-vpc-and-a-serverless-architecture.html) | AWS 管理者 | 

### NAT ゲートウェイ用に 2 つの Elastic IP アドレス作成する
<a name="create-two-elastic-ip-addresses-for-your-nat-gateways"></a>


| タスク | 説明 | 必要なスキル | 
| --- | --- | --- | 
|  最初の Elastic IP アドレスを作成します。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/prescriptive-guidance/latest/patterns/generate-a-static-outbound-ip-address-using-a-lambda-function-amazon-vpc-and-a-serverless-architecture.html)この Elastic IP アドレスは、最初の NAT ゲートウェイに使用されます。  | AWS 管理者 | 
| 2 番目の Elastic IP アドレスを作成します。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/prescriptive-guidance/latest/patterns/generate-a-static-outbound-ip-address-using-a-lambda-function-amazon-vpc-and-a-serverless-architecture.html)この Elastic IP アドレスは 2 番目の NAT ゲートウェイに使用されます。 | AWS 管理者 | 

### インターネットゲートウェイを作成する
<a name="create-an-internet-gateway"></a>


| タスク | 説明 | 必要なスキル | 
| --- | --- | --- | 
| インターネットゲートウェイを作成します。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/prescriptive-guidance/latest/patterns/generate-a-static-outbound-ip-address-using-a-lambda-function-amazon-vpc-and-a-serverless-architecture.html) | AWS 管理者 | 
| インターネットゲートウェイを VPC にアタッチします。 | 作成したインターネットゲートウェイを選択して、[**アクション]、[VPC にアタッチ**] を選択します。 | AWS 管理者 | 

### NAT ゲートウェイを 2 つ作成します。
<a name="create-two-nat-gateways"></a>


| タスク | 説明 | 必要なスキル | 
| --- | --- | --- | 
| 最初の NAT ゲートウェイを作成します。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/prescriptive-guidance/latest/patterns/generate-a-static-outbound-ip-address-using-a-lambda-function-amazon-vpc-and-a-serverless-architecture.html) | AWS 管理者 | 
| 2 番目の NAT ゲートウェイを作成します。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/prescriptive-guidance/latest/patterns/generate-a-static-outbound-ip-address-using-a-lambda-function-amazon-vpc-and-a-serverless-architecture.html) | AWS 管理者 | 

### パブリックサブネットとプライベートサブネットのルートテーブルを作成します。
<a name="create-route-tables-for-your-public-and-private-subnets"></a>


| タスク | 説明 | 必要なスキル | 
| --- | --- | --- | 
| パブリックワンサブネット用のルートテーブルを作成します。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/prescriptive-guidance/latest/patterns/generate-a-static-outbound-ip-address-using-a-lambda-function-amazon-vpc-and-a-serverless-architecture.html) | AWS 管理者 | 
| パブリック2 サブネットのルートテーブルを作成します。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/prescriptive-guidance/latest/patterns/generate-a-static-outbound-ip-address-using-a-lambda-function-amazon-vpc-and-a-serverless-architecture.html) | AWS 管理者 | 
| プライベートワンサブネットのルートテーブルを作成します。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/prescriptive-guidance/latest/patterns/generate-a-static-outbound-ip-address-using-a-lambda-function-amazon-vpc-and-a-serverless-architecture.html) | AWS 管理者 | 
| プライベートツーサブネットのルートテーブルを作成します。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/prescriptive-guidance/latest/patterns/generate-a-static-outbound-ip-address-using-a-lambda-function-amazon-vpc-and-a-serverless-architecture.html) | AWS 管理者 | 

### Lambda 関数を作成し、VPC に追加して、ソリューションをテストする
<a name="create-the-lambda-function-add-it-to-the-vpc-and-test-the-solution"></a>


| タスク | 説明 | 必要なスキル | 
| --- | --- | --- | 
| 新しい Lambda 関数の作成 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/prescriptive-guidance/latest/patterns/generate-a-static-outbound-ip-address-using-a-lambda-function-amazon-vpc-and-a-serverless-architecture.html) | AWS 管理者 | 
| Lambda 関数 を VPC に追加します。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/prescriptive-guidance/latest/patterns/generate-a-static-outbound-ip-address-using-a-lambda-function-amazon-vpc-and-a-serverless-architecture.html) | AWS 管理者 | 
| 外部サービスを呼び出すコードを記述します。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/prescriptive-guidance/latest/patterns/generate-a-static-outbound-ip-address-using-a-lambda-function-amazon-vpc-and-a-serverless-architecture.html) | AWS 管理者 | 

## 関連リソース
<a name="generate-a-static-outbound-ip-address-using-a-lambda-function-amazon-vpc-and-a-serverless-architecture-resources"></a>
+ [VPC 内のリソースにアクセスするように Lambda 関数を設定する](https://docs.aws.amazon.com/lambda/latest/dg/configuration-vpc.html)