2
1

[備忘録] AWSのそんな話聞いてない

Last updated at Posted at 2024-03-07

概要

AWSを触って大事そうなことを殴り書く予定

同一VPC内でLambdaから別のLambdaを呼び出す

VPC内だから特別記述することはないと思っていたら、どうやらLambdaのエンドポイントをVPCに設定しないといけないらしい。

CDKで定義している場合は以下のように定義する。

    vpc.addInterfaceEndpoint('LambdaEndpoint', {
      service: ec2.InterfaceVpcEndpointAwsService.LAMBDA,
      subnets: { subnetType: ec2.SubnetType.PRIVATE_ISOLATED },
    });

ランタイムバージョン更新が自動だとライブラリが動かなくなることがある。

ランタイムのメジャーバージョン自体は以下のように指定していても、マイナーなランタイムパッチとセキュリティパッチが自動更新される。

new lambda.Function(this, 'lambda', {
    runtime: lambda.Runtime.PYTHON_3_9,
});

なので以下のような欄タイムバージョン更新を固定または指定する。
lambdaRuntimeVersionArn はcdk.jsonで定義。

+ const lambdaRuntimeVersionArn  = this.node.tryGetContext('lambdaRuntimeVersionArn');
  
  new lambda.Function(this, 'lambda', {
+     runtimeManagementMode: lambda.RuntimeManagementMode.manual(lambdaRuntimeVersionArn),
      runtime: lambda.Runtime.PYTHON_3_9,
  });

詳しくはこちら

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1