

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

# `AWSSupport-TroubleshootLambdaInternetAccess`
<a name="AWSSupport-TroubleshootLambdaInternetAccess"></a>

 **説明** 

 `AWSSupport-TroubleshootLambdaInternetAccess` ランブックは、Amazon Virtual Private Cloud (Amazon VPC) で起動された AWS Lambda 関数のインターネットアクセスに関する問題のトラブルシューティングに役立ちます。サブネットルート、セキュリティグループルール、ネットワークアクセスコントロールリスト (ACL) ルールなどのリソースを確認して、アウトバウンドのインターネットアクセスが許可されていることを確認します。

 [このオートメーションを実行する (コンソール)](https://console.aws.amazon.com/systems-manager/automation/execute/AWSSupport-TroubleshootLambdaInternetAccess) 

**ドキュメントタイプ**

オートメーション

**[所有者]**

Amazon

**[Platforms]** (プラットフォーム)

Linux、macOS、Windows

**パラメータ**
+ AutomationAssumeRole

  タイプ: 文字列

  説明: (オプション) Systems Manager Automation がユーザーに代わってアクションを実行できるようにする AWS Identity and Access Management (IAM) ロールの Amazon リソースネーム (ARN)。ロールを指定しない場合、Systems Manager Automation はこのランブックを開始するユーザーのアクセス許可を使用します。
+ FunctionName

  タイプ: 文字列

  説明: (必須) インターネットアクセスのトラブルシューティングを行う Lambda 関数の名前。
+ destinationIp

  タイプ: 文字列

  説明: (必須) アウトバウンド接続を確立する宛先 IP アドレス。
+ destinationPort

  タイプ: 文字列

  デフォルト: 443

  説明: (オプション) アウトバウンド接続を確立する宛先ポート。

**必要な IAM アクセス許可**

`AutomationAssumeRole` パラメータでは、ランブックを正常に使用するために、次のアクションが必要です。
+  `lambda:GetFunction` 
+  `ec2:DescribeRouteTables` 
+  `ec2:DescribeNatGateways` 
+  `ec2:DescribeSecurityGroups` 
+  `ec2:DescribeNetworkAcls` 

 **ドキュメントステップ** 
+  `aws:executeScript` - Lambda 関数が起動された VPC 内のさまざまなリソースの設定を検証します。
+  `aws:branch` - 指定された Lambda 関数が VPC 内にあるかどうかに基づいて分岐させます。
+  `aws:executeScript` - Lambda 関数が起動されたサブネットのルートテーブルルートを確認し、ネットワークアドレス変換 (NAT) ゲートウェイとインターネットゲートウェイへのルートが存在することを確認します。Lambda 関数がパブリックサブネットにないことを確認します。
+  `aws:executeScript` - `destinationIp` および `destinationPort` パラメータに指定された値に基づいて、Lambda 関数に関連付けられたセキュリティグループがアウトバウンドインターネットアクセスを許可していることを確認します。
+  `aws:executeScript` - `destinationIp` および `destinationPort` パラメータに指定された値に基づいて、Lambda 関数のサブネットに関連付けられた ACL ルールと NAT ゲートウェイがアウトバウンドインターネットアクセスを許可していることを確認します。

 **[出力] ** 

checkVpc.vpc - Lambda 関数が起動された VPC の ID。

checkVpc.subnet - Lambda 関数が起動された サブネットの ID。

checkVpc.securityGroups - Lambda 関数に関連付けられたセキュリティグループ。

 checkNACL.NACL - リソース名を含む分析メッセージ。`LambdaIp` とは、Lambda 関数の エラスティックネットワークインターフェイスのプライベート IP アドレスを指します。`LambdaIpRules` オブジェクトは NAT ゲートウェイへのルートがあるサブネットに対してのみ生成されます。次のコンテンツは出力の例です。

```
{
   "subnet-1234567890":{
      "NACL":"acl-1234567890",
      "destinationIp_Egress":"Allowed",
      "destinationIp_Ingress":"notAllowed",
      "Analysis":"This NACL has an allow rule for Egress traffic but there is no Ingress rule. Please allow the destination IP / destionation port in Ingress rule",
      "LambdaIpRules":{
         "{LambdaIp}":{
            "Egress":"notAllowed",
            "Ingress":"notAllowed",
            "Analysis":"This is a NAT subnet NACL. It does not have ingress or egress rule allowed in it for Lambda's corresponding private ip {LambdaIp} Please allow this IP in your egress and ingress NACL rules"
         }
      }
   },
   "subnet-0987654321":{
      "NACL":"acl-0987654321",
      "destinationIp_Egress":"Allowed",
      "destinationIp_Ingress":"notAllowed",
      "Analysis":"This NACL has an allow rule for Egress traffic but there is no Ingress rule. Please allow the destination IP / destionation port in Ingress rule"
   }
}
```

checkSecurityGroups.secgrps - Lambda 関数に関連付けられているセキュリティグループの分析。次のコンテンツは出力の例です。

```
{
   "sg-123456789":{
      "Status":"Allowed",
      "Analysis":"This security group has allowed destintion IP and port in its outbuond rule."
   }
}
```

checkSubnet.subnets - Lambda 関数に関連付けられた VPC 内のサブネットの分析。次のコンテンツは出力の例です。

```
{
   "subnet-0c4ee6cdexample15":{
      "Route":{
         "DestinationCidrBlock":"8.8.8.0/26",
         "NatGatewayId":"nat-00f0example69fdec",
         "Origin":"CreateRoute",
         "State":"active"
      },
      "Analysis":"This Route Table has an active NAT gateway path. Also, The NAT gateway is launched in public subnet",
      "RouteTable":"rtb-0b1fexample16961b"
   }
}
```